From b1e5734ef566af5d49ba17d05ca0ab7b56d6666d Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 9 May 2017 03:55:30 -0700 Subject: [MSO-8] Additional fixes for the second rebase DB fixes + BPMN flows and groovy fixes + Fix issue with CloudConfig file not reloaded properly when it's wrong (JSON error or model hierarchy mistake) at MSO startup Change-Id: I2853030b78499e2a761706b643ea210955e72de3 Signed-off-by: Determe, Sebastien (sd378r) [MSO-8] Restore files removed in patch set 2 Those groovy files must be there Change-Id: I9a47ac3d9c8fc06774a1b8f518491b1b0b00af04 Signed-off-by: Determe, Sebastien (sd378r) --- .../mso/bpmn/common/scripts/AaiUtil.groovy | 198 +- .../scripts/AbstractServiceTaskProcessor.groovy | 30 + .../common/scripts/AllottedResourceUtils.groovy | 312 ++ .../bpmn/common/scripts/CreateAAIVfModule.groovy | 27 +- .../common/scripts/CreateGenericVNFUtils.groovy | 164 -- .../common/scripts/GenerateVfModuleName.groovy | 6 +- .../bpmn/common/scripts/GenericDeleteVnf.groovy | 1 - .../bpmn/common/scripts/GenericGetService.groovy | 111 +- .../mso/bpmn/common/scripts/GenericGetVnf.groovy | 2 +- .../bpmn/common/scripts/GenericPutService.groovy | 6 +- .../mso/bpmn/common/scripts/GenericUtils.groovy | 20 + .../bpmn/common/scripts/SDNCAdapterUtils.groovy | 2 +- .../bpmn/common/scripts/UpdateAAIGenericVnf.groovy | 31 +- .../bpmn/common/scripts/UpdateAAIVfModule.groovy | 8 +- .../mso/bpmn/common/scripts/VfModuleBase.groovy | 246 +- .../workflow/service/AbstractCallbackService.java | 352 +++ .../service/SDNCAdapterCallbackServiceImpl.java | 235 +- .../service/VnfAdapterNotifyServiceImpl.java | 763 ++--- .../workflow/service/WorkflowMessageResource.java | 103 +- .../resources/subprocess/GenericGetService.bpmn | 210 +- .../mso/bpmn/common/scripts/AaiUtilTest.groovy | 690 +++-- .../common/CreateAAIVfModuleVolumeGroupTest.java | 272 +- .../mso/bpmn/common/GenericGetServiceTest.java | 1010 +++---- .../bpmn/common/PrepareUpdateAAIVfModuleTest.java | 8 +- .../mso/bpmn/common/SDNCAdapterV1Test.java | 22 +- .../mso/bpmn/common/UpdateAAIGenericVnfTest.java | 6 +- .../mso/bpmn/common/UpdateAAIVfModuleTest.java | 6 +- .../openecomp/mso/bpmn/common/WorkflowTest.java | 320 +- .../Archive/drop_mariadb_engine_7.5.6.sql | 149 +- .../Archive/mariadb_engine_7.5_patch_7.5.6.sql | 443 ++- .../VfModularity/UpdateAAIVfModuleRequest.xml | 18 +- .../__files/VfModularity/VfModule-supercool.xml | 4 +- .../src/test/resources/mso.bpmn.urn.properties | 11 +- .../bpmn/core/decomposition/AllottedResource.java | 38 + .../bpmn/core/decomposition/HomingSolution.java | 49 + .../mso/bpmn/core/decomposition/InstanceData.java | 37 + .../mso/bpmn/core/decomposition/JsonWrapper.java | 140 + .../mso/bpmn/core/decomposition/ModelInfo.java | 101 + .../bpmn/core/decomposition/ModuleResource.java | 60 + .../bpmn/core/decomposition/NetworkResource.java | 42 + .../core/decomposition/ResourceDecomposition.java | 70 + .../core/decomposition/ServiceDecomposition.java | 159 + .../core/decomposition/ServiceInstanceData.java | 23 + .../mso/bpmn/core/decomposition/VnfResource.java | 91 + .../CreateGenericALaCarteServiceInstance.groovy | 262 ++ .../CreateGenericMacroServiceNetworkVnf.groovy | 1540 +++++----- .../scripts/CreateServiceInstance.groovy | 262 -- .../scripts/CreateVfModuleInfra.groovy | 303 +- .../scripts/CreateVfModuleVolumeInfraV1.groovy | 607 ++-- .../infrastructure/scripts/CreateVnfInfra.groovy | 70 - .../scripts/DelServiceInstance.groovy | 353 --- .../DeleteGenericALaCarteServiceInstance.groovy | 353 +++ .../DeleteGenericMacroServiceNetworkVnf.groovy | 934 +++--- .../scripts/DeleteNetworkInstance.groovy | 834 +++--- .../scripts/DoCreateNetworkInstance.groovy | 129 +- .../scripts/DoCreateServiceInstance.groovy | 92 +- .../scripts/DoCreateServiceInstanceRollback.groovy | 28 +- .../infrastructure/scripts/DoCreateVfModule.groovy | 81 +- .../scripts/DoCreateVfModuleRollback.groovy | 68 +- .../scripts/DoCreateVfModuleVolumeV1.groovy | 5 +- .../bpmn/infrastructure/scripts/DoCreateVnf.groovy | 976 ++++--- .../scripts/DoCreateVnfAndModules.groovy | 654 +++-- .../scripts/DoDeleteNetworkInstance.groovy | 86 +- .../scripts/DoDeleteServiceInstance.groovy | 840 +++--- .../scripts/DoDeleteVnfAndModules.groovy | 740 +++-- .../scripts/DoUpdateNetworkInstance.groovy | 16 +- .../infrastructure/scripts/DoUpdateVfModule.groovy | 1840 ++++++------ .../scripts/UpdateNetworkInstanceInfra.groovy | 1639 ----------- .../infrastructure/scripts/UpdateVfModule.groovy | 66 +- .../scripts/UpdateVfModuleVolume.groovy | 72 +- .../CreateGenericALaCarteServiceInstance.bpmn | 336 +++ .../CreateGenericMacroServiceNetworkVnf.bpmn | 2416 ++++++++-------- .../resources/process/CreateServiceInstance.bpmn | 336 --- .../resources/process/CreateVfModuleInfra.bpmn | 354 +-- .../src/main/resources/process/CreateVnfInfra.bpmn | 5 +- .../main/resources/process/DelServiceInstance.bpmn | 331 --- .../DeleteGenericALaCarteServiceInstance.bpmn | 331 +++ .../DeleteGenericMacroServiceNetworkVnf.bpmn | 1524 +++++----- .../src/main/resources/process/DeleteVnfInfra.bpmn | 2 +- .../process/UpdateNetworkInstanceInfra.bpmn | 1014 ------- .../subprocess/DoCreateNetworkInstance.bpmn | 208 +- .../subprocess/DoCreateServiceInstance.bpmn | 805 +++--- .../DoCreateServiceInstanceRollback.bpmn | 707 ++--- .../src/main/resources/subprocess/DoCreateVnf.bpmn | 312 +- .../subprocess/DoCreateVnfAndModules.bpmn | 74 +- .../subprocess/DoDeleteServiceInstance.bpmn | 693 ++--- .../resources/subprocess/DoDeleteVfModule.bpmn | 27 +- .../subprocess/DoDeleteVnfAndModules.bpmn | 355 ++- .../scripts/UpdateNetworkInstanceInfraTest.groovy | 3055 -------------------- .../infrastructure/CreateVfModuleInfraTest.java | 122 +- .../UpdateNetworkInstanceInfraTest.java | 840 ------ .../UpdateVfModuleVolumeInfraV1Test.java | 284 +- .../__files/CreateVfModule_VID_request.json | 69 + .../CreateVfModule_VID_request_noPreloads.json | 79 + .../__files/VfModularity/DBUpdateResponse.xml | 4 + .../GenerateVfModuleName_AAIResponse_Success.xml | 51 + .../resources/__files/VfModularity/GenericVnf.xml | 76 +- .../VfModularity/SDNCSITopologyAssignCallback.xml | 11 + .../VfModularity/SDNCTopologyActivateCallback.xml | 13 + .../VfModularity/SDNCTopologyAssignCallback.xml | 16 + .../SDNCTopologyChangeAssignCallback.xml | 13 + .../VfModularity/SDNCTopologyQueryCallback.xml | 315 ++ .../SDNCTopologyQueryCallbackVfModule.xml | 141 + .../VfModularity/VNFAdapterRestCreateCallback.xml | 55 + .../VfModularity/VNFAdapterRestUpdateCallback.xml | 16 + .../VNFAdapterRestVolumeGroupCallback.xml | 15 + .../__files/VfModularity/VfModule-lukewarm.xml | 10 + .../__files/VfModularity/VfModule-new.xml | 16 +- .../__files/VfModularity/VfModule-supercool.xml | 52 +- .../src/test/resources/mso.bpmn.urn.properties | 6 +- .../openecomp/mso/bpmn/mock/StubResponseAAI.java | 130 + .../java/org/openecomp/mso/rest/APIResponse.java | 27 +- .../java/org/openecomp/mso/rest/HttpHeader.java | 65 + .../org/openecomp/mso/rest/APIResponseESTest.java | 11 +- .../org/openecomp/mso/rest/HttpHeaderESTest.java | 99 + .../mso/rest/HttpHeaderESTestscaffolding.java | 98 + 116 files changed, 15951 insertions(+), 19014 deletions(-) create mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy delete mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy create mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/AllottedResource.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/HomingSolution.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/InstanceData.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/JsonWrapper.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ModelInfo.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ModuleResource.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/NetworkResource.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ResourceDecomposition.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ServiceDecomposition.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ServiceInstanceData.java create mode 100644 bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/VnfResource.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateServiceInstance.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DelServiceInstance.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfra.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateServiceInstance.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/DelServiceInstance.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstanceInfra.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml create mode 100644 bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/HttpHeader.java create mode 100644 bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTest.java create mode 100644 bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTestscaffolding.java (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy index 95a577c946..b50bf68207 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy @@ -27,17 +27,19 @@ import org.openecomp.mso.rest.RESTClient import org.openecomp.mso.rest.RESTConfig class AaiUtil { - + public MsoUtils utils = new MsoUtils() - public static final String AAI_NAMESPACE_STRING = 'http://org.openecomp.aai.inventory/' + public static final String AAI_NAMESPACE_STRING_KEY = 'URN_mso_workflow_global_default_aai_namespace' public static final String DEFAULT_VERSION_KEY = 'URN_mso_workflow_global_default_aai_version' - + + private String aaiNamespace = null; + private AbstractServiceTaskProcessor taskProcessor public AaiUtil(AbstractServiceTaskProcessor taskProcessor) { this.taskProcessor = taskProcessor } - + public String getNetworkGenericVnfEndpoint(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String endpoint = execution.getVariable("URN_aai_endpoint") @@ -52,7 +54,7 @@ class AaiUtil { taskProcessor.logDebug('AaiUtil.getNetworkGenericVnfUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - + public String getNetworkVpnBindingUri(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'vpn_binding') @@ -73,7 +75,7 @@ class AaiUtil { taskProcessor.logDebug('AaiUtil.getNetworkTableReferencesUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - + public String getNetworkVceUri(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'vce') @@ -110,7 +112,7 @@ class AaiUtil { taskProcessor.logDebug('AaiUtil.getCloudInfrastructureCloudRegionEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled) return endpoint + uri } - + public String getCloudInfrastructureCloudRegionUri(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'cloud_region') @@ -131,7 +133,7 @@ class AaiUtil { taskProcessor.logDebug('AaiUtil.getSearchNodesQueryUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - + public String getSearchNodesQueryEndpoint(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String endpoint = execution.getVariable("URN_aai_endpoint") @@ -139,7 +141,7 @@ class AaiUtil { taskProcessor.logDebug('AaiUtil.getSearchNodesQueryEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled) return endpoint + uri } - + public String getSearchGenericQueryUri(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'generic_query') @@ -151,37 +153,39 @@ class AaiUtil { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') resourceName = resourceName.replaceAll('-', '_') - + def versionWithResourceKey = "URN_mso_workflow_default_aai_${resourceName}_version" def versionWithProcessKey = "URN_mso_workflow_custom_${processKey}_aai_version" def version = execution.getVariable(versionWithProcessKey) if (version) { taskProcessor.logDebug("AaiUtil.getVersion() - using flow specific ${versionWithProcessKey}=${version}", isDebugLogEnabled) - return version + return version } - + version = execution.getVariable(versionWithResourceKey) if (version) { taskProcessor.logDebug("AaiUtil.getVersion() - using resource specific ${versionWithResourceKey}=${version}", isDebugLogEnabled) return version } - + version = execution.getVariable(DEFAULT_VERSION_KEY) if (version) { taskProcessor.logDebug("AaiUtil.getVersion() - using default version ${DEFAULT_VERSION_KEY}=${version}", isDebugLogEnabled) return version } - + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}") } - + public String getUri(Execution execution, resourceName) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def processKey = taskProcessor.getMainProcessKey(execution) - resourceName = resourceName.replaceAll('-', '_') + + //set namespace + setNamespace(execution) // Check for flow+resource specific first def key = "URN_mso_workflow_${processKey}_aai_${resourceName}_uri" @@ -190,7 +194,7 @@ class AaiUtil { taskProcessor.logDebug("AaiUtil.getUri() - using flow+resource specific key: ${key}=${uri}", isDebugLogEnabled) return uri } - + // Check for versioned key def version = getVersion(execution, resourceName, processKey) key = "URN_mso_workflow_default_aai_v${version}_${resourceName}_uri" @@ -204,17 +208,80 @@ class AaiUtil { (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file') } + public String setNamespace(Execution execution) { + def key = AAI_NAMESPACE_STRING_KEY + aaiNamespace = execution.getVariable(key) + if (aaiNamespace == null ) { + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file') + } + } + + /** + * This method can be used for getting the building namespace out of uri. + * NOTE: A getUri() method needs to be invoked first. + * Alternative method is the getNamespaceFromUri(Execution execution, String uri) + * return namespace (plus version from uri) + * + * @param url + * + * @return namespace + */ + public String getNamespaceFromUri(String uri) { - String namespace = AAI_NAMESPACE_STRING + if (aaiNamespace == null) { + throw new Exception('Internal Error: AAI Namespace has not been set yet. A getUri() method needs to be invoked first.') + } + String namespace = aaiNamespace if(uri!=null){ - return namespace + uri.substring(uri.indexOf("v"), uri.indexOf("v")+2) + String version = getVersionFromUri(uri) + return namespace + "v"+version }else{ return namespace } } - + /** + * This method can be used for building namespace with aai version out of uri. + * NOTE: 2 arguments: Execution execution & String uri + * @param execution + * @param url + * + * @return namespace + */ + public String getNamespaceFromUri(Execution execution, String uri) { + String namespace = execution.getVariable(AAI_NAMESPACE_STRING_KEY) + if (namespace == null ) { + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + AAI_NAMESPACE_STRING_KEY + ' not defined in the MSO URN properties file') + } + if(uri!=null){ + String version = getVersionFromUri(uri) + return namespace + "v"+version + }else{ + return namespace + } + } + + /** + * This is used to extract the version from uri. + * + * @param uri + * + * @return version + */ + private String getVersionFromUri(String uri) { + def version = "" + def savedVersion = "" + for (int x=2; x<6; x++) { + version = uri.substring(uri.indexOf("v")+1, uri.indexOf("v")+x) + if (!Character.isDigit(version.charAt(version.size()-1))) { + break + } + savedVersion = version + } + return savedVersion + } + /** * This reusable method can be used for making AAI Get Calls. The url should * be passed as a parameter along with the execution. The method will @@ -232,16 +299,16 @@ class AaiUtil { String uuid = UUID.randomUUID() taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled) taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) - + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) RESTConfig config = new RESTConfig(url); RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml"); - + if (basicAuthCred != null && !"".equals(basicAuthCred)) { client.addAuthorizationHeader(basicAuthCred) } - + APIResponse apiResponse = client.get() return apiResponse @@ -252,6 +319,7 @@ class AaiUtil { taskProcessor.logDebug( "======== COMPLETED Execute AAI Get Process ======== ", isDebugEnabled) } + /** * This reusable method can be used for making AAI httpPut Calls. The url should * be passed as a parameter along with the execution and payload. The method will @@ -287,7 +355,7 @@ class AaiUtil { } taskProcessor.logDebug( "======== Completed Execute AAI Put Process ======== ", isDebugEnabled) } - + /** * This reusable method can be used for making AAI httpPatch Calls. The url should * be passed as a parameter along with the execution and payload. The method will @@ -345,7 +413,7 @@ class AaiUtil { taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) - + RESTConfig config = new RESTConfig(url); RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml"); if (basicAuthCred != null && !"".equals(basicAuthCred)) { @@ -379,8 +447,9 @@ class AaiUtil { try{ String uuid = UUID.randomUUID() taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled) + taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) - + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) RESTConfig config = new RESTConfig(url); RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml").addAuthorizationHeader(authHeader); @@ -398,11 +467,11 @@ class AaiUtil { } taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled) } - + /** - * This reusable method can be used for making AAI Post Calls. The url should - * be passed as a parameter along with the execution. The method will - * return an APIResponse. + * This reusable method can be used for making AAI Post Calls. The url + * and payload should be passed as a parameters along with the execution. + * The method will return an APIResponse. * * @param execution * @param url @@ -421,6 +490,7 @@ class AaiUtil { String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) RESTConfig config = new RESTConfig(url); RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml"); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { client.addAuthorizationHeader(basicAuthCred) } @@ -435,7 +505,49 @@ class AaiUtil { taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled) } - /** Utilitty to get the Cloud Region from AAI + /** + * This reusable method can be used for making AAI Post Calls. The url + * and payload should be passed as a parameters along with the execution. + * The method will return an APIResponse. + * + * @param execution + * @param url + * @param payload + * @param authenticationHeader - addAuthenticationHeader value + * @param headerName - name of header you want to add, i.e. addHeader(headerName, headerValue) + * @param headerValue - the header's value, i.e. addHeader(headerName, headerValue) + * + * @return APIResponse + */ + public APIResponse executeAAIPostCall(Execution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled) + try{ + taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) + + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) + + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addAuthorizationHeader(authenticationHeaderValue).addHeader(headerName, headerValue) + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + APIResponse apiResponse = client.httpPost(payload) + + return apiResponse + + }catch(Exception e){ + taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled) + return e + } + taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled) + } + + + + + + /* Utility to get the Cloud Region from AAI * Returns String cloud region id, (ie, cloud-region-id) * @param execution * @param url - url for AAI get cloud region @@ -479,7 +591,7 @@ class AaiUtil { return "ERROR" } } else { // not 200 - if (returnCode == "404") { + if (returnCode == "404") { if (backend == "PO") { regionId = inputCloudRegion } else { // backend not "PO" @@ -487,10 +599,10 @@ class AaiUtil { } taskProcessor.utils.log("DEBUG", "Cloud Region value for code='404' of " + backend + " is: " + regionId, isDebugEnabled) return regionId - } else { - taskProcessor.utils.log("ERROR", "Call AAI Cloud Region is NOT Successful.", isDebugEnabled) - return "ERROR" - } + } else { + taskProcessor.utils.log("ERROR", "Call AAI Cloud Region is NOT Successful.", isDebugEnabled) + return "ERROR" + } } }catch(Exception e) { taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled) @@ -511,19 +623,18 @@ class AaiUtil { return ret } - /** - * Get the lowest unused VF Module index from AAI response for a given module type. The criteria for + * Get the lowest unused VF Module index from AAI response for a given module type. The criteria for * determining module type is specified by "key" parameter (for example, "persona-model-id"), * the value for filtering is specified in "value" parameter - * + * * @param execution * @param aaiVnfResponse * @param key * @param value * * @return moduleIndex - * + * */ public int getLowestUnusedVfModuleIndexFromAAIVnfResponse(Execution execution, String aaiVnfResponse, String key, String value) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") @@ -531,7 +642,7 @@ class AaiUtil { String vfModulesText = taskProcessor.utils.getNodeXml(aaiVnfResponse, "vf-modules") if (vfModulesText == null || vfModulesText.isEmpty()) { taskProcessor.utils.log("DEBUG", "There are no VF modules in this VNF yet", isDebugEnabled) - return 0 + return 0 } else { def xmlVfModules= new XmlSlurper().parseText(vfModulesText) @@ -548,15 +659,14 @@ class AaiUtil { matchingVfModules = matchingVfModules + taskProcessor.utils.removeXmlPreamble(vfModuleXml) } } - matchingVfModules = matchingVfModules + "" + matchingVfModules = matchingVfModules + "" taskProcessor.utils.log("DEBUG", "Matching VF Modules: " + matchingVfModules, isDebugEnabled) String lowestUnusedIndex = taskProcessor.utils.getLowestUnusedIndex(matchingVfModules) return Integer.parseInt(lowestUnusedIndex) - } + } } else { return 0 } } - } \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index d7aa97906c..e86f77c890 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -697,6 +697,10 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess /** * Constructs a workflow message callback URL for the specified message type and correlator. + * This type of callback URL is used when a workflow wants an MSO adapter (like the SDNC + * adapter) to call it back. In other words, this is for callbacks internal to the MSO + * complex. Use createWorkflowMessageAdapterCallbackURL if the callback + * will come from outside the MSO complex. * @param messageType the message type (e.g. SDNCAResponse or VNFAResponse) * @param correlator the correlator value (e.g. a request ID) */ @@ -717,4 +721,30 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') + '/' + UriUtils.encodePathSegment(correlator, 'UTF-8') } + + /** + * + * Constructs a workflow message callback URL for the specified message type and correlator. + * This type of callback URL is used when a workflow wants a system outside the MSO complex + * to call it back through the Workflow Message Adapter. + * @param messageType the message type (e.g. SNIROResponse) + * @param correlator the correlator value (e.g. a request ID) + */ + public String createWorkflowMessageAdapterCallbackURL(Execution execution, String messageType, String correlator) { + String endpoint = (String) execution.getVariable('URN_mso_adapters_workflow_message_endpoint') + + if (endpoint == null || endpoint.isEmpty()) { + ExceptionUtil exceptionUtil = new ExceptionUtil() + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, + 'mso:adapters:workflow:message:endpoint URN mapping is not set') + } + + while (endpoint.endsWith('/')) { + endpoint = endpoint.substring(0, endpoint.length()-1) + } + + return endpoint + + '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') + + '/' + UriUtils.encodePathSegment(correlator, 'UTF-8') + } } \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy new file mode 100644 index 0000000000..540fe036fc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -0,0 +1,312 @@ +package org.openecomp.mso.bpmn.common.scripts + +import org.apache.commons.lang3.StringEscapeUtils; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution; +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; + +class AllottedResourceUtils { + + private AbstractServiceTaskProcessor taskProcessor + ExceptionUtil exceptionUtil = new ExceptionUtil() + MsoUtils utils; + + public AllottedResourceUtils(AbstractServiceTaskProcessor taskProcessor) { + this.taskProcessor = taskProcessor + this.utils = taskProcessor.utils + } + + /*Used on Create - called from DoCreate + * Using Consuming ServiceInstanceId get related Allotted Resources Orchestration status from AAI + * 1) get related AR links for CSI 2) get AR from AR links + * return: null -> AR Not found + * return: " " -> AR found with empty orchStatus + * return: orchStatus - > AR found with this orchStatus + * setsVariable aaiARGetResponse + */ + public String getAROrchStatus (Execution execution) { + + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** getAROrchStatus *****", isDebugEnabled) + String msg = "" + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String arType = execution.getVariable("allottedResourceType") + String arRole = execution.getVariable("allottedResourceRole") + String siXml = execution.getVariable("CSI_service") + String ar = null + String orchStatus = null + XmlParser xmlParser = new XmlParser() + utils.log("DEBUG","getAROrchStatus siXml:" + siXml, isDebugEnabled) + try { + if (!isBlank(siXml)) { + def groovy.util.Node siNode = xmlParser.parseText(siXml) + def groovy.util.Node relationshipList = utils.getChildNode(siNode, 'relationship-list') + if (relationshipList != null) { + def groovy.util.NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship') + for (groovy.util.Node relationship in relationships) { + def groovy.util.Node relatedTo = utils.getChildNode(relationship, 'related-to') + if ((relatedTo != null) && (relatedTo.text().equals('allotted-resource'))) { + utils.log("DEBUG","getARORchStatus AR found", isDebugEnabled) + def groovy.util.Node relatedLink = utils.getChildNode(relationship, 'related-link') + if (relatedLink != null){ + ar = getARbyLink(execution, relatedLink.text(), arRole) + if (!isBlank(ar)) + { + orchStatus = execution.getVariable("aaiAROrchStatus") + break + } + } + } + } + } + } + }catch(Exception e){ + utils.log("DEBUG", " Error encountered in getAROrchStatus" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in getAROrchStatus" + e.getMessage()) + } + utils.log("DEBUG"," *****Exit getAROrchStatus **** OrchStatus:" + orchStatus, isDebugEnabled) + return orchStatus + } + + // get Allotted Resource by AllottedResourceId + // used on Delete - called from doDeleteAR + // setsVariable aaiARGetResponse + public String getARbyId (Execution execution, String allottedResourceId) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** getARbyId ***** ", isDebugEnabled) + String arLink = getARLinkbyId(execution, allottedResourceId) + String ar = null + if (!isBlank(arLink)) + { + ar = getARbyLink(execution, arLink, "") + } + utils.log("DEBUG", " ***** Exit GetARbyId ***** AR:" + ar, isDebugEnabled) + return ar; + } + + // get Allotted Resource Link by AllottedResourceId using Nodes Query + // used on Delete - called from getARbyId + public String getARLinkbyId (Execution execution, String allottedResourceId) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** getARLinkbyId ***** ", isDebugEnabled) + String arLink = null + try { + AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) + String aaiNQUri = aaiUriUtil.getSearchNodesQueryEndpoint(execution) + String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + String aaiUrl = "${aaiNQUri}?search-node-type=allotted-resource&filter=id:EQUALS:${allottedResourceId}" + + utils.log("DEBUG", "getARLinkbyId url: \n" + aaiUrl, isDebugEnabled) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, aaiUrl) + int responseCode = response.getStatusCode() + utils.log("DEBUG", " GET AR response code is: " + responseCode, isDebugEnabled) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + utils.log("DEBUG", "GET AR:" + aaiResponse, isDebugEnabled) + if(responseCode == 200 || responseCode == 202){ + utils.log("DEBUG", "GET AR Received a Good Response Code", isDebugEnabled) + if(utils.nodeExists(aaiResponse, "result-data")){ + utils.log("DEBUG", "Query for AllottedResource Url Response Does Contain Data" , isDebugEnabled) + arLink = utils.getNodeText1(aaiResponse, "resource-link") + }else{ + utils.log("DEBUG", "GET AR Response Does NOT Contain Data" , isDebugEnabled) + } + }else if(responseCode == 404){ + utils.log("DEBUG", "GET AR received a Not Found (404) Response", isDebugEnabled) + } + else{ + utils.log("DEBUG", " GET AR received a Bad Response: \n" + aaiResponse, isDebugEnabled) + buildAAIErrorResponse(execution, aaiResponse, "Error retrieving AR from AAI") + } + }catch(Exception e){ + utils.log("DEBUG", " Error encountered within GetAaiAR" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetARbyId" + e.getMessage()) + } + utils.log("DEBUG", " ***** Exit GetARLinkbyId ***** Link:" + arLink, isDebugEnabled) + return arLink + } + + // get Allotted resource using Link + // used on Create called from getARORchStatus + // used on Delete called from getARbyId + // setsVariable aaiARPath - used for Patch in create + public String getARbyLink (Execution execution, String link, String role) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** getARbyLink ***** ", isDebugEnabled) + String ar = null + String arUrl = null + try { + AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + String arEndpoint = "" + + if(!isBlank(link)) { + utils.log("DEBUG", "Incoming AR Resource Link is: " + link, isDebugEnabled) + String[] split = link.split("/aai/") + arEndpoint = "/aai/" + split[1] + } + + arUrl = "${aai_endpoint}" + arEndpoint + + utils.log("DEBUG", "GET AR Aai Path is: \n" + arUrl, isDebugEnabled) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, arUrl) + int responseCode = response.getStatusCode() + utils.log("DEBUG", " GET AR response code is: " + responseCode, isDebugEnabled) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + utils.log("DEBUG", "GET AR:" + aaiResponse, isDebugEnabled) + if(responseCode == 200 || responseCode == 202){ + utils.log("DEBUG", "GET AR Received a Good Response Code", isDebugEnabled) + if(utils.nodeExists(aaiResponse, "allotted-resource")){ + if (!isBlank(role)) + { + if (utils.nodeExists(aaiResponse, "role") && role.equals(utils.getNodeText1(aaiResponse, "role"))) { + ar = aaiResponse + }else{ + utils.log("DEBUG", "AAI AR does not match input role:" + role, isDebugEnabled) + } + } + else + { + ar = aaiResponse + } + } + else + { + utils.log("DEBUG", "GET AR Does NOT Contain Data" , isDebugEnabled) + } + }else if(responseCode == 404){ + utils.log("DEBUG", "GET AR received a Not Found (404) Response", isDebugEnabled) + } + else{ + utils.log("DEBUG", " GET AR received a Bad Response: \n" + aaiResponse, isDebugEnabled) + buildAAIErrorResponse(execution, aaiResponse, "Error retrieving AR from AAI") + } + }catch(Exception e){ + utils.log("DEBUG", " Error encountered within GetAaiAR" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetAaiAR" + e.getMessage()) + } + if (!isBlank(ar)) + { + execution.setVariable("aaiARGetResponse", ar) + execution.setVariable("aaiARPath", arUrl) + + String resourceVersion = null + if (utils.nodeExists(ar, "resource-version")) { + resourceVersion = utils.getNodeText1(ar, "resource-version") + execution.setVariable("aaiARResourceVersion", resourceVersion) + } + + String orchStatus = null + if (utils.nodeExists(ar, "orchestration-status")) { + orchStatus= utils.getNodeText1(ar, "orchestration-status") + } + else + { + orchStatus = " " + } + execution.setVariable("aaiAROrchStatus", orchStatus) + } + utils.log("DEBUG", " ***** Exit GetARbyLink ***** AR:" + ar, isDebugEnabled) + return ar + } + + public void updateAROrchStatus(Execution execution, String status, String aaiARPath){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** updaAROrchStatus *** ", isDebugEnabled) + try{ + + String updateReq = """ + { + "orchestration-status": "Created"" + } + """ + + utils.log("DEBUG", 'AAI AR URI: ' + aaiARPath, isDebugEnabled) + + AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) + APIResponse apiResponse = aaiUriUtil.executeAAIPatchCall(execution, aaiARPath, updateReq) + def aaiResponse = StringEscapeUtils.unescapeXml(apiResponse.getResponseBodyAsString()) + def responseCode = apiResponse.getStatusCode() + + utils.logAudit("AAI Response Code: " + responseCode) + utils.logAudit("AAI Response: " + aaiResponse) + if(responseCode == 200){ + utils.log("DEBUG", "UpdateAR Good REST Response is: " + "\n" + aaiResponse, isDebugEnabled) + }else{ + utils.log("DEBUG", "UpdateAROrchStatus Bad REST Response!", isDebugEnabled) + buildAAIErrorResponse(execution, aaiResponse, "Error updating AR OrchStatus in AAI") + } + + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException ", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", "Exception in updateAR. Exception is:\n" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error in updateAROrchStatus.' + e.getMessage()) + } + utils.log("DEBUG", " *** Exit updateAROrchStatus *** ", isDebugEnabled) + } + + //Sets Variable "wasDeleted" + public void deleteAR(Execution execution, String aaiARPath){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** deleteAR *** aaiARPath:" + aaiARPath, isDebugEnabled) + try { + AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) + APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, aaiARPath) + int responseCode = response.getStatusCode() + execution.setVariable("deleteARResponseCode", responseCode) + + utils.log("DEBUG", " Delete AR response code:" + responseCode, isDebugEnabled) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("aaiARDeleteResponse", aaiResponse) + + utils.log("DEBUG", "Delete AR Response:" + aaiResponse) + //Process Response + if(responseCode == 204){ + utils.log("DEBUG", " Delete AR Received a Good Response", isDebugEnabled) + execution.setVariable("wasDeleted", "true") + }else if(responseCode == 404){ + utils.log("DEBUG", " Delete AR Received a Not Found (404) Response", isDebugEnabled) + }else if(responseCode == 412){ + utils.log("DEBUG", "Delete AR Received a Resource Version Mismatch Error: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 412, "DeleteAR Received a resource-version Mismatch Error Response from AAI") + }else{ + utils.log("DEBUG", "Delete AR Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) + buildAAIErrorResponse(execution, aaiResponse, "Error deleting AR in AAI") + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error encountered in deleteAR!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Delete AR") + } + utils.log("DEBUG", " *** Exit deleteAR *** ", isDebugEnabled) + } + + public void buildAAIErrorResponse(Execution execution, String response, String errorMessage){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** BuildAAIErrorResponse*** ", isDebugEnabled) + + if((response != null) && (response.contains("Fault") || response.contains("RESTFault"))){ + WorkflowException workflowException = exceptionUtil.MapAAIExceptionToWorkflowException(response, execution) + execution.setVariable("WorkflowException", workflowException) + }else{ + exceptionUtil.buildWorkflowException(execution, 500, errorMessage) + } + + utils.log("DEBUG", " *** Exit BuildAAIErrorResponse Process*** ", isDebugEnabled) + throw new BpmnError("MSOWorkflowException") + } + +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy index 986111ccda..9cf22aaf4a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -159,7 +159,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ AaiUtil aaiUriUtil = new AaiUtil(this) def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) - String aaiNamespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) logDebug('AAI namespace is: ' + aaiNamespace, isDebugEnabled) execution.setVariable("CAAIVfMod_aaiNamespace","${aaiNamespace}") @@ -258,8 +258,8 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ ${execution.getVariable("CAAIVfMod_vnfType")} ${execution.getVariable("CAAIVfMod_serviceId")} active - ${execution.getVariable("CAAIVfMod_vnfPersonaId")} - ${execution.getVariable("CAAIVfMod_vnfPersonaVer")} + ${execution.getVariable("CAAIVfMod_vnfPersonaId")} + ${execution.getVariable("CAAIVfMod_vnfPersonaVer")} """ as String execution.setVariable("CAAIVfMod_createGenericVnfPayload", payload) @@ -305,8 +305,19 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ def aaiVnfResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") AaiUtil aaiUtil = new AaiUtil(this) def personaModelId = execution.getVariable("CAAIVfMod_personaId") + + // Check if the response includes model-invariant-id or persona-model-id + // note: getRequiredNodeText() throws an exception if the field is missing + // need to retun a null for the subsequent "either/or" logic to work properly +// def modelInvariantId = getRequiredNodeText(execution, aaiVnfResponse,'model-invariant-id') + def modelInvariantId = getNodeText(aaiVnfResponse,'model-invariant-id', null) + def fieldToCheck = 'model-invariant-id' + if (!modelInvariantId) { + fieldToCheck = 'persona-model-id' + } + moduleIndex = aaiUtil.getLowestUnusedVfModuleIndexFromAAIVnfResponse(execution, aaiVnfResponse, - "persona-model-id", personaModelId) + fieldToCheck, personaModelId) } def moduleIndexString = String.valueOf(moduleIndex) @@ -324,11 +335,11 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ String payload = """ ${newModuleId} ${execution.getVariable("CAAIVfMod_moduleName")} - ${execution.getVariable("CAAIVfMod_personaId")} - ${execution.getVariable("CAAIVfMod_personaVer")} - ${execution.getVariable("CAAIVfMod_modelCustomizationId")} + ${execution.getVariable("CAAIVfMod_personaId")} + ${execution.getVariable("CAAIVfMod_personaVer")} + ${execution.getVariable("CAAIVfMod_modelCustomizationId")} ${isBaseModule} - pending-create + PendingCreate ${moduleIndex} """ as String execution.setVariable("CAAIVfMod_createVfModulePayload", payload) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy deleted file mode 100644 index 887eb7456d..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy +++ /dev/null @@ -1,164 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.bpmn.common.scripts - -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; - -import org.camunda.bpm.engine.runtime.Execution; -import org.camunda.bpm.engine.delegate.BpmnError - -/** - * Please describe the CreateGenericVNFUtils.groovy class - * - */ -class CreateGenericVNFUtils{ - - String Prefix="CRTGVNF_" - - def utils=new MsoUtils() - - private AbstractServiceTaskProcessor taskProcessor - - public CreateGenericVNFUtils(AbstractServiceTaskProcessor taskProcessor) { - this.taskProcessor = taskProcessor - } - - /** - * This method is executed during the Initialization task of the process. - * - * @param execution - * - */ - - public APIResponse queryAAI(Execution execution, String path){ - - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - utils.log("DEBUG", " ======== STARTED queryAAI Process ======== ", isDebugEnabled) - - def uuid = execution.getVariable("CRTGVNF_uuid") - utils.log("DEBUG", "UUID is: " + uuid, isDebugEnabled) - - //Setting request path - String queryAAIRequestPath = execution.getVariable("URN_aai_endpoint")+path -// execution.setVariable("CRTGVNF_queryAAIRequestPath", queryAAIRequestPath) - utils.log("DEBUG", "QueryAAIRequest Path is: " + "\n" + queryAAIRequestPath, isDebugEnabled) - - try { - AaiUtil aaiUtil = new AaiUtil(taskProcessor) - return aaiUtil.executeAAIGetCall(execution, queryAAIRequestPath) - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing queryAAI. Exception is:\n" + e, isDebugEnabled) - execution.setVariable("CRTGVNF_dataValidationFlag", false) - execution.setVariable("CRTGVNF_ErrorResponse", "Error Occured during queryAAI Method:\n" + e.getMessage()) - } - utils.log("DEBUG", "======== COMPLETED queryAAI Process ======== ", isDebugEnabled) -} - - public String buildSDNCRequest(Execution 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("CRTGVNF_sdncCallbackUrl") - def requestId = execution.getVariable("CRTGVNF_requestId") - def serviceType = execution.getVariable("CRTGVNF_serviceType") - def vnfType = execution.getVariable("CRTGVNF_vnfType") - def vnfName = execution.getVariable("CRTGVNF_vnfName") - def tenantId = execution.getVariable("CRTGVNF_tenantId") - def source = execution.getVariable("CRTGVNF_source") - String vnfId = svcInstId - String sdncVNFParamsXml = "" - - if(execution.getVariable("CRTGVNF_vnfParamsExistFlag") == true){ - sdncVNFParamsXml = buildSDNCParamsXml(execution) - }else{ - sdncVNFParamsXml = "" - } - - String sdncRequest = - """ - - ${uuid} - ${svcInstId} - ${action} - vnf-topology-operation - ${callbackURL} - - - - ${requestId} - VNFActivateRequest - ${source} - - - ${serviceType} - ${vnfId} - notsurewecare - - - ${vnfId} - ${vnfType} - ${vnfName} - ${tenantId} -${sdncVNFParamsXml} - - - """ - - return sdncRequest - - } - - public String buildSDNCParamsXml(Execution execution){ - - String params = "" - StringBuilder sb = new StringBuilder() - Map paramsMap = execution.getVariable("CRTGVNF_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 - } - -} - - - - - diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy index fba5cbe1b0..53678ec749 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -120,7 +120,11 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ String matchingVfModules = "" for (i in 0..vfModulesSize-1) { def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) - def personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id") + def personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "model-invariant-id") + if (!personaModelIdFromAAI) { + // check old attribute name + personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id") + } if (personaModelIdFromAAI != null && personaModelIdFromAAI.equals(personaModelId)) { matchingVfModules = matchingVfModules + utils.removeXmlPreamble(vfModuleXml) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy index 1bd4383b74..344bba29bd 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy @@ -67,7 +67,6 @@ import org.springframework.web.util.UriUtils * * * Out Mapping Variables: - * @param - GENDV_vnf * @param - GENDV_SuccessIndicator * @param - GENDV_FoundIndicator * @param - WorkflowException diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy index 70ce1ba5cf..2e65339270 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy @@ -64,6 +64,13 @@ import org.springframework.web.util.UriUtils * Variable Mapping Below: * * In Mapping Variables: + * For Allotted-Resource: + * @param - GENGS_allottedResourceId + * @param - GENGS_type + * @param (Optional) - GENGS_serviceInstanceId + * @param (Optional) - GENGS_serviceType + * @param (Optional) - GENGS_globalCustomerId + * * For Service-Instance: * @param - GENGS_serviceInstanceId or @param - GENGS_serviceInstanceName * @param - GENGS_type @@ -82,6 +89,7 @@ import org.springframework.web.util.UriUtils * @param - WorkflowException * * + * @author cb645j */ class GenericGetService extends AbstractServiceTaskProcessor{ @@ -94,20 +102,24 @@ class GenericGetService extends AbstractServiceTaskProcessor{ * variables the calling flow provided. * * @param - execution + * + * @author cb645j */ public void preProcessRequest(Execution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService PreProcessRequest Process*** ", isDebugEnabled) - execution.setVariable("GENGS_obtainServiceInstanceUrl", false) + execution.setVariable("GENGS_obtainObjectsUrl", false) execution.setVariable("GENGS_obtainServiceInstanceUrlByName", false) execution.setVariable("GENGS_SuccessIndicator", false) execution.setVariable("GENGS_FoundIndicator", false) + execution.setVariable("GENGS_resourceLink", null) execution.setVariable("GENGS_siResourceLink", null) try{ // Get Variables + String allottedResourceId = execution.getVariable("GENGS_allottedResourceId") String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") String serviceInstanceName = execution.getVariable("GENGS_serviceInstanceName") String serviceType = execution.getVariable("GENGS_serviceType") @@ -116,7 +128,21 @@ class GenericGetService extends AbstractServiceTaskProcessor{ if(type != null){ utils.log("DEBUG", "Incoming GENGS_type is: " + type, isDebugEnabled) - if(type.equalsIgnoreCase("service-instance")){ + if(type.equalsIgnoreCase("allotted-resource")){ + if(isBlank(allottedResourceId)){ + utils.log("DEBUG", "Incoming allottedResourceId is null. Allotted Resource Id is required to Get an allotted-resource.", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming allottedResourceId is null. Allotted Resource Id is required to Get an allotted-resource.") + }else{ + utils.log("DEBUG", "Incoming Allotted Resource Id is: " + allottedResourceId, isDebugEnabled) + if(isBlank(globalCustomerId) || isBlank(serviceType) || isBlank(serviceInstanceId)){ + execution.setVariable("GENGS_obtainObjectsUrl", true) + }else{ + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled) + } + } + }else if(type.equalsIgnoreCase("service-instance")){ if(isBlank(serviceInstanceId) && isBlank(serviceInstanceName)){ utils.log("DEBUG", "Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.", isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.") @@ -124,7 +150,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{ utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) utils.log("DEBUG", "Incoming Service Instance Name is: " + serviceInstanceName, isDebugEnabled) if(isBlank(globalCustomerId) || isBlank(serviceType)){ - execution.setVariable("GENGS_obtainServiceInstanceUrl", true) + execution.setVariable("GENGS_obtainObjectsUrl", true) if(isBlank(serviceInstanceId)){ execution.setVariable("GENGS_obtainServiceInstanceUrlByName", true) } @@ -170,49 +196,64 @@ class GenericGetService extends AbstractServiceTaskProcessor{ execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlById Process*** ", isDebugEnabled) try { - String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") - utils.log("DEBUG", " Querying Node for Service-Instance URL by using Service-Instance Id: " + serviceInstanceId, isDebugEnabled) - AaiUtil aaiUriUtil = new AaiUtil(this) String aai_uri = aaiUriUtil.getSearchNodesQueryEndpoint(execution) String aai_endpoint = execution.getVariable("URN_aai_endpoint") - - utils.logAudit("GenericGetService AAI Endpoint: " + aai_endpoint) - String path = "${aai_uri}?search-node-type=service-instance&filter=service-instance-id:EQUALS:${serviceInstanceId}" + + String type = execution.getVariable("GENGS_type") + String path = "" + if(type.equalsIgnoreCase("service-instance")){ + String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") + utils.log("DEBUG", " Querying Node for Service-Instance URL by using Service-Instance Id: " + serviceInstanceId, isDebugEnabled) + path = "${aai_uri}?search-node-type=service-instance&filter=service-instance-id:EQUALS:${serviceInstanceId}" + utils.logAudit("Service Instance Node Query Url is: " + path) + utils.log("DEBUG", "Service Instance Node Query Url is: " + path, isDebugEnabled) + }else if(type.equalsIgnoreCase("allotted-resource")){ + String allottedResourceId = execution.getVariable("GENGS_allottedResourceId") + utils.log("DEBUG", " Querying Node for Service-Instance URL by using Allotted Resource Id: " + allottedResourceId, isDebugEnabled) + path = "${aai_uri}?search-node-type=allotted-resource&filter=id:EQUALS:${allottedResourceId}" + utils.logAudit("Allotted Resource Node Query Url is: " + path) + utils.log("DEBUG", "Allotted Resource Node Query Url is: " + path, isDebugEnabled) + } //String url = "${aai_endpoint}${path}" host name needs to be removed from property String url = "${path}" - execution.setVariable("GENGS_obtainSIUrlPath", url) + execution.setVariable("GENGS_genericQueryPath", url) APIResponse response = aaiUriUtil.executeAAIGetCall(execution, url) int responseCode = response.getStatusCode() - execution.setVariable("GENGS_obtainSIUrlResponseCode", responseCode) + execution.setVariable("GENGS_genericQueryResponseCode", responseCode) utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled) utils.logAudit("GenericGetService AAI GET Response Code: " + responseCode) String aaiResponse = response.getResponseBodyAsString() + execution.setVariable("GENGS_obtainSIUrlResponseBeforeUnescaping", aaiResponse) + utils.log("DEBUG", "GenericGetService AAI Response before unescaping: " + aaiResponse, isDebugEnabled) aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) - execution.setVariable("GENGS_obtainSIUrlResponse", aaiResponse) + execution.setVariable("GENGS_genericQueryResponse", aaiResponse) utils.logAudit("GenericGetService AAI Response: " + aaiResponse) + utils.log("DEBUG", "GenericGetService AAI Response: " + aaiResponse, isDebugEnabled) + //Process Response if(responseCode == 200){ - utils.log("DEBUG", " Query for Service Instance Url Received a Good Response Code", isDebugEnabled) + utils.log("DEBUG", "Generic Query Received a Good Response Code", isDebugEnabled) execution.setVariable("GENGS_SuccessIndicator", true) if(utils.nodeExists(aaiResponse, "result-data")){ - utils.log("DEBUG", "Query for Service Instance Url Response Does Contain Data" , isDebugEnabled) + utils.log("DEBUG", "Generic Query Response Does Contain Data" , isDebugEnabled) execution.setVariable("GENGS_FoundIndicator", true) String resourceLink = utils.getNodeText1(aaiResponse, "resource-link") + execution.setVariable("GENGS_resourceLink", resourceLink) execution.setVariable("GENGS_siResourceLink", resourceLink) }else{ - utils.log("DEBUG", "Query for Service Instance Url Response Does NOT Contains Data" , isDebugEnabled) + utils.log("DEBUG", "Generic Query Response Does NOT Contains Data" , isDebugEnabled) execution.setVariable("WorkflowResponse", " ") //for junits } }else if(responseCode == 404){ - utils.log("DEBUG", " Query for Service Instance Received a Not Found (404) Response", isDebugEnabled) + utils.log("DEBUG", "Generic Query Received a Not Found (404) Response", isDebugEnabled) execution.setVariable("GENGS_SuccessIndicator", true) execution.setVariable("WorkflowResponse", " ") //for junits }else{ - utils.log("DEBUG", "Query for Service Instance Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) + utils.log("DEBUG", "Generic Query Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) throw new BpmnError("MSOWorkflowException") } @@ -255,11 +296,11 @@ class GenericGetService extends AbstractServiceTaskProcessor{ execution.setVariable("GENGS_obtainSIUrlResponseCode", responseCode) utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled) utils.logAudit("GenericGetService AAI Response Code: " + responseCode) - + String aaiResponse = response.getResponseBodyAsString() aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) execution.setVariable("GENGS_obtainSIUrlResponse", aaiResponse) - utils.logAudit("GenericGetService AAI Response: " + aaiResponse) + utils.logAudit("GenericGetService AAI Response: " + aaiResponse) //Process Response if(responseCode == 200){ utils.log("DEBUG", " Query for Service Instance Url Received a Good Response Code", isDebugEnabled) @@ -268,6 +309,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{ utils.log("DEBUG", "Query for Service Instance Url Response Does Contain Data" , isDebugEnabled) execution.setVariable("GENGS_FoundIndicator", true) String resourceLink = utils.getNodeText1(aaiResponse, "resource-link") + execution.setVariable("GENGS_resourceLink", resourceLink) execution.setVariable("GENGS_siResourceLink", resourceLink) }else{ utils.log("DEBUG", "Query for Service Instance Url Response Does NOT Contains Data" , isDebugEnabled) @@ -308,10 +350,10 @@ class GenericGetService extends AbstractServiceTaskProcessor{ AaiUtil aaiUriUtil = new AaiUtil(this) String aai_endpoint = execution.getVariable("URN_aai_endpoint") String serviceEndpoint = "" - + utils.logAudit("GenericGetService getServiceObject AAI Endpoint: " + aai_endpoint) if(type.equalsIgnoreCase("service-instance")){ - String siResourceLink = execution.getVariable("GENGS_siResourceLink") + String siResourceLink = execution.getVariable("GENGS_resourceLink") if(isBlank(siResourceLink)){ String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") utils.log("DEBUG", " Incoming GENGS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) @@ -324,7 +366,27 @@ class GenericGetService extends AbstractServiceTaskProcessor{ logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") }else{ - utils.log("DEBUG", "Incoming Service Instance Resource Link is: " + siResourceLink, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Instance Url is: " + siResourceLink, isDebugEnabled) + String[] split = siResourceLink.split("/aai/") + serviceEndpoint = "/aai/" + split[1] + } + }else if(type.equalsIgnoreCase("allotted-resource")){ + String siResourceLink = execution.getVariable("GENGS_resourceLink") + if(isBlank(siResourceLink)){ + String allottedResourceId = execution.getVariable("GENGS_allottedResourceId") + utils.log("DEBUG", " Incoming GENGS_allottedResourceId is: " + allottedResourceId, isDebugEnabled) + String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") + utils.log("DEBUG", " Incoming GENGS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) + String serviceType = execution.getVariable("GENGS_serviceType") + utils.log("DEBUG", " Incoming GENGS_serviceType is: " + serviceType, isDebugEnabled) + String globalCustomerId = execution.getVariable("GENGS_globalCustomerId") + utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled) + + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) + serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") + }else{ + utils.log("DEBUG", "Incoming Allotted-Resource Url is: " + siResourceLink, isDebugEnabled) String[] split = siResourceLink.split("/aai/") serviceEndpoint = "/aai/" + split[1] } @@ -345,12 +407,11 @@ class GenericGetService extends AbstractServiceTaskProcessor{ execution.setVariable("GENGS_getServiceResponseCode", responseCode) utils.log("DEBUG", " GET Service response code is: " + responseCode, isDebugEnabled) utils.logAudit("GenericGetService AAI Response Code: " + responseCode) - + String aaiResponse = response.getResponseBodyAsString() aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) execution.setVariable("GENGS_getServiceResponse", aaiResponse) utils.logAudit("GenericGetService AAI Response: " + aaiResponse) - //Process Response if(responseCode == 200 || responseCode == 202){ utils.log("DEBUG", "GET Service Received a Good Response Code", isDebugEnabled) @@ -382,4 +443,4 @@ class GenericGetService extends AbstractServiceTaskProcessor{ utils.log("DEBUG", " *** COMPLETED GenericGetService GetServiceObject Process*** ", isDebugEnabled) } -} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy index df9a97c78c..bc787df577 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy @@ -20,7 +20,7 @@ package org.openecomp.mso.bpmn.common.scripts -import static org.apache.commons.lang3.StringUtils.* +import static org.openecomp.mso.bpmn.common.scripts.GenericUtils.*; import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy index 9609103228..9f7d57f335 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy @@ -49,6 +49,7 @@ import org.springframework.web.util.UriUtils * * * Incoming Required Variables: + * @param - GENPS_requestId * @param - GENPS_type - Required field. This will be required field populated as service-instance or service-subscription * @param - GENPS_globalSubscriberId - Required field * @param - GENPS_serviceType - Required Field @@ -58,8 +59,7 @@ import org.springframework.web.util.UriUtils * @param - GENPS_allottedResourceId - Conditional Field. Required for allotted-resource. * @param - GENPS_tunnelXconnectId - Conditional Field. Required for tunnel-xconnect. * - * @param - GENPS_requestId to trace the request id - * @param - GENPS_serviceResourceVersion optional needs to be provided only in case of update for both service-instance and service subscription. The calling flows + * @param - GENPS_serviceResourceVersion - Conditional Field. Needs to be provided only in case of update for both service-instance and service subscription. The calling flows * should check if a service-instance or servic-subscription exists by calling the subflow GenericGetService. if it exists then resourceversion should be * obtained from aai and sent as an input parameter. * @@ -183,7 +183,7 @@ class GenericPutService extends AbstractServiceTaskProcessor{ AaiUtil aaiUriUtil = new AaiUtil(this) String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + String namespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) logDebug('AAI namespace is: ' + namespace, isDebugEnabled) String aai_endpoint = execution.getVariable("URN_aai_endpoint") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy new file mode 100644 index 0000000000..3397aa9b54 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy @@ -0,0 +1,20 @@ +package org.openecomp.mso.bpmn.common.scripts + +import org.apache.commons.lang3.StringUtils; + +class GenericUtils extends StringUtils{ + + @Override + public static boolean isBlank(final CharSequence cs) { + int strLen; + if (cs == null || (strLen = cs.length()) == 0 || cs.equals("null")) { + return true; + } + for (int i = 0; i < strLen; i++) { + if (Character.isWhitespace(cs.charAt(i)) == false) { + return false; + } + } + return true; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy index f870e30d1d..4ca0370185 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy @@ -932,7 +932,7 @@ class SDNCAdapterUtils { if (modelVersionId == null) { modelVersionId = "" } - String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationId") + String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationUuid") String modelCustomizationString = "" if (modelCustomizationUuid != null) { modelCustomizationString = "${modelCustomizationUuid}" diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index 4838a67d36..0c483388c1 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -28,7 +28,7 @@ import org.springframework.web.util.UriUtils public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { - + private XmlParser xmlParser = new XmlParser() ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -44,12 +44,13 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { execution.setVariable('UAAIGenVnf_personaModelVersion', null) execution.setVariable("UAAIGenVnf_ipv4OamAddress", null) execution.setVariable('UAAIGenVnf_managementV6Address', null) + execution.setVariable('UAAIGenVnf_orchestrationStatus', null) execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode' ,null) execution.setVariable('UAAIGenVnf_getGenericVnfResponse', '') execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', null) execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', '') } - + /** * Check for missing elements in the received request. * @@ -90,6 +91,11 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { if (managementV6Address != null && !managementV6Address.isEmpty()) { execution.setVariable('UAAIGenVnf_managementV6Address', managementV6Address) } + + def orchestrationStatus = getNodeTextForce(xml, 'orchestration-status') + if (orchestrationStatus != null && !orchestrationStatus.isEmpty()) { + execution.setVariable('UAAIGenVnf_orchestrationStatus', orchestrationStatus) + } logDebug('Exited ' + method, isDebugLogEnabled) } catch (BpmnError e) { @@ -99,7 +105,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) } } - + /** * Using the received vnfId, query AAI to get the corresponding Generic VNF. * A 200 response is expected with the VF Module in the response body. @@ -182,7 +188,11 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { if (newPersonaModelId != null || newPersonaModelVersion != null) { // Confirm "new" persona-model-id is same as "current" persona-model-id - def Node currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'persona-model-id') + def Node currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'model-invariant-id') + if (currPersonaModelIdNode == null) { + // check the old attribute name + currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'persona-model-id') + } def String currPersonaModelId = '' if (currPersonaModelIdNode != null) { currPersonaModelId = currPersonaModelIdNode.text() @@ -194,7 +204,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { } // Construct payload - personaModelVersionEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'persona-model-version') + personaModelVersionEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'model-version-id') } // Handle ipv4-oam-address @@ -212,11 +222,20 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Construct payload managementV6AddressEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'management-v6-address') } + + // Handle orchestration-status + def String orchestrationStatus = execution.getVariable('UAAIGenVnf_orchestrationStatus') + def String orchestrationStatusEntry = "" + if (orchestrationStatus != null) { + // Construct payload + orchestrationStatusEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'orchestration-status') + } def payload = """ { ${personaModelVersionEntry} ${ipv4OamAddressEntry} - ${managementV6AddressEntry} + ${managementV6AddressEntry} + ${orchestrationStatusEntry} "vnf-id": "${vnfId}" } """ diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy index 7283a3ecfc..1f9db12b6f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy @@ -133,7 +133,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { } /** - * Construct and send a PUT request to AAI to update the VF Module. + * Construct and send a PATCH request to AAI to update the VF Module. * * @param execution The flow's execution instance. */ @@ -176,7 +176,11 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { doPersonaModelVersion = false } else { // Confirm "new" persona-model-id is same as "current" persona-model-id - def String currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'persona-model-id') + def String currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'model-invariant-id') + if (currPersonaModelId == null) { + // check the old attribute name + currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'model-version-id') + } if (currPersonaModelId == null) { currPersonaModelId = '' } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy index d48ae8f84e..7a97d5cd12 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy @@ -40,7 +40,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { /** * Get the XmlParser. - * + * * @return the XmlParser. */ protected XmlParser getXmlParser() { @@ -50,7 +50,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { /** * Find the VF Module with specified ID in the specified Generic VF. If no such * VF Module is found, null is returned. - * + * * @param genericVnf The Generic VNF in which to search for the specified VF Moduel. * @param vfModuleId The ID of the VF Module for which to search. * @return a VFModule object for the found VF Module or null if no VF Module is found. @@ -77,7 +77,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { * element to a corresponding list of 'vnf-networks' specifications (typically used when * invoking the VNF Rest Adpater). Each element in '*-params' whose name attribute ends * with '_network' is used to create an 'vnf-networks' element. - * + * * @param paramsNode A Node representing a '*-params' element. * @return a String of 'vnf-networks' elements, one for each 'param' element whose name * attribute ends with '_network'. @@ -189,7 +189,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { /** * 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. @@ -233,7 +233,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { */ - protected String buildVfModuleParams(String vnfParams, String sdncGetResponse, String vnfId, String vnfName, + protected String buildVfModuleParams(Map vnfParamsMap, String sdncGetResponse, String vnfId, String vnfName, String vfModuleId, String vfModuleName, String vfModuleIndex) { //Get SDNC Response Data @@ -251,36 +251,19 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { oldVnfId = utils.removeXmlNamespaces(oldVnfId) serviceData = serviceData.replace(oldVnfId, "") def vnfId1 = utils.getNodeText1(serviceData, "vnf-id") - String vfModuleIndexParam = "" + + Map paramsMap = new HashMap() if (vfModuleIndex != null) { - vfModuleIndexParam = """ - vf_module_index - ${vfModuleIndex} - """ + paramsMap.put("vf_module_index", "${vfModuleIndex}") } // Add-on data - String vnfInfo = - """ - vnf_id - ${vnfId} - - - vnf_name - ${vnfName} - - - vf_module_id - ${vfModuleId} - - - vf_module_name - ${vfModuleName} - - ${vfModuleIndexParam}""" - - utils.logAudit("vnfInfo: " + vnfInfo) + paramsMap.put("vnf_id", "${vnfId}") + paramsMap.put("vnf_name", "${vnfName}") + paramsMap.put("vf_module_id", "${vfModuleId}") + paramsMap.put("vf_module_name", "${vfModuleName}") + InputSource source = new InputSource(new StringReader(data)); DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); docFactory.setNamespaceAware(true) @@ -289,8 +272,6 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { // Availability Zones Data - String aZones = "" - StringBuilder sbAZone = new StringBuilder() NodeList aZonesList = responseXml.getElementsByTagNameNS("*", "availability-zones") String aZonePosition = "0" @@ -300,28 +281,14 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { Element eElement = (Element) node String aZoneValue = utils.getElementText(eElement, "availability-zone") aZonePosition = z.toString() - String aZoneXml = - """ - availability_zone_${aZonePosition} - ${aZoneValue} - """ - aZones = sbAZone.append(aZoneXml) + paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}") } } // VNF Networks Data - String vnfNetworkNetId = "" - String vnfNetworkNetName = "" - String vnfNetworkSubNetId = "" - String vnfNetworkV6SubNetId = "" - String vnfNetworkNetFqdn = "" - String vnfNetworksSriovVlanFilters = "" + StringBuilder sbNet = new StringBuilder() - StringBuilder sbNet2 = new StringBuilder() - StringBuilder sbNet3 = new StringBuilder() - StringBuilder sbNet4 = new StringBuilder() - StringBuilder sbNet5 = new StringBuilder() - StringBuilder sbNet6 = new StringBuilder() + NodeList vnfNetworkList = responseXml.getElementsByTagNameNS("*", "vnf-networks") for (int x = 0; x < vnfNetworkList.getLength(); x++) { Node node = vnfNetworkList.item(x) @@ -333,36 +300,11 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") - String vnfNetworkNetIdXml = - """ - ${vnfNetworkKey}_net_id - ${vnfNetworkNeutronIdValue} - """ - vnfNetworkNetId = sbNet.append(vnfNetworkNetIdXml) - String vnfNetworkNetNameXml = - """ - ${vnfNetworkKey}_net_name - ${vnfNetworkNetNameValue} - """ - vnfNetworkNetName = sbNet2.append(vnfNetworkNetNameXml) - String vnfNetworkSubNetIdXml = - """ - ${vnfNetworkKey}_subnet_id - ${vnfNetworkSubNetIdValue} - """ - vnfNetworkSubNetId = sbNet3.append(vnfNetworkSubNetIdXml) - String vnfNetworkV6SubNetIdXml = - """ - ${vnfNetworkKey}_v6_subnet_id - ${vnfNetworkV6SubNetIdValue} - """ - vnfNetworkV6SubNetId = sbNet5.append(vnfNetworkV6SubNetIdXml) - String vnfNetworkNetFqdnXml = - """ - ${vnfNetworkKey}_net_fqdn - ${vnfNetworkNetFqdnValue} - """ - vnfNetworkNetFqdn = sbNet4.append(vnfNetworkNetFqdnXml) + paramsMap.put("${vnfNetworkKey}_net_id", "${vnfNetworkNeutronIdValue}") + paramsMap.put("${vnfNetworkKey}_net_name", "${vnfNetworkNetNameValue}") + paramsMap.put("${vnfNetworkKey}_subnet_id", "${vnfNetworkSubNetIdValue}") + paramsMap.put("${vnfNetworkKey}_v6_subnet_id", "${vnfNetworkV6SubNetIdValue}") + paramsMap.put("${vnfNetworkKey}_net_fqdn", "${vnfNetworkNetFqdnValue}") NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") StringBuffer sriovFilterBuf = new StringBuffer() @@ -381,23 +323,13 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { } } if (!values.isEmpty()) { - String vnfNetworkSriovVlanFilterXml = - """ - ${vnfNetworkKey}_ATT_VF_VLAN_FILTER - ${values} - """ - vnfNetworksSriovVlanFilters = sbNet6.append(vnfNetworkSriovVlanFilterXml) + paramsMap.put("${vnfNetworkKey}_ATT_VF_VLAN_FILTER", "${values}") } } } // VNF-VMS Data - String vnfVMS = "" - String vnfVMSPositions = "" - String vmNetworks = "" - String vmNetworksPositions = "" - String vmNetworksPositionsV6 = "" - String interfaceRoutePrefixes = "" + def key def value def networkKey @@ -407,11 +339,6 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { def floatingIPV6Key def floatingIPV6KeyValue StringBuilder sb = new StringBuilder() - StringBuilder sbPositions = new StringBuilder() - StringBuilder sbVmNetworks = new StringBuilder() - StringBuilder sbNetworksPositions = new StringBuilder() - StringBuilder sbInterfaceRoutePrefixes = new StringBuilder() - StringBuilder sbNetworksPositionsV6 = new StringBuilder() NodeList vmsList = responseXml.getElementsByTagNameNS("*","vnf-vms") for (int x = 0; x < vmsList.getLength(); x++) { @@ -436,12 +363,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { values = sb1.append(value); } position = i.toString() - String vnfPositionXml = - """ - ${key}_name_${position} - ${value} - """ - vnfVMSPositions = sbPositions.append(vnfPositionXml) + paramsMap.put("${key}_name_${position}", "${value}") } } for(int n = 0; n < vmNetworksList.getLength(); n++){ @@ -459,19 +381,13 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { networkKey = utils.getElementText(eElementNetworkKey, "network-role") floatingIPKey = key + '_' + networkKey + '_floating_ip' floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") - if(!floatingIPKeyValue.isEmpty()){ - floatingIpKeyValueStr = """ - $floatingIPKey - $floatingIPKeyValue - """ + if(!floatingIPKeyValue.isEmpty()){ + paramsMap.put("$floatingIPKey", "$floatingIPKeyValue") } floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") - if(!floatingIPV6KeyValue.isEmpty()){ - floatingIpV6KeyValueStr = """ - $floatingIPV6Key - $floatingIPV6KeyValue - """ + if(!floatingIPV6KeyValue.isEmpty()){ + paramsMap.put("$floatingIPV6Key", "$floatingIPV6KeyValue") } NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") for(int a = 0; a < networkIpsList.getLength(); a++){ @@ -486,50 +402,34 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { ipAddressValues = sb2.append(ipAddressValue); } networkPosition = a.toString() - String vmNetworksPositionsXml = - """ - ${key}_${networkKey}_ip_${networkPosition} - ${ipAddressValue} - """ - vmNetworksPositions = sbNetworksPositions.append(vmNetworksPositionsXml) + paramsMap.put("${key}_${networkKey}_ip_${networkPosition}", "${ipAddressValue}") } } - vmNetworksPositions = sbNetworksPositions.append(floatingIpKeyValueStr).append(floatingIpV6KeyValueStr) - - String vmNetworksXml = - """ - ${key}_${networkKey}_ips - ${ipAddressValues} - """ - vmNetworks = sbVmNetworks.append(vmNetworksXml) + + paramsMap.put("${key}_${networkKey}_ips", "${ipAddressValues}") NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") String interfaceRoutePrefixValues = sb3.append("[") - for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ - Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) + for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ + Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") } - if (a != interfaceRoutePrefixesList.getLength() - 1) { + if (a != interfaceRoutePrefixesList.getLength() - 1) { interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") } else { interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") - } + } } } interfaceRoutePrefixValues = sb3.append("]") if (interfaceRoutePrefixesList.getLength() > 0) { - String interfaceRoutePrefixesXml = - """ - ${key}_${networkKey}_route_prefixes - ${interfaceRoutePrefixValues} - """ - interfaceRoutePrefixes = sbInterfaceRoutePrefixes.append(interfaceRoutePrefixesXml) + paramsMap.put("${key}_${networkKey}_route_prefixes", "${interfaceRoutePrefixValues}") } NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") @@ -545,28 +445,13 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { ipV6AddressValues = sb4.append(ipV6AddressValue); } networkPosition = a.toString() - String vmNetworksPositionsV6Xml = - """ - ${key}_${networkKey}_v6_ip_${networkPosition} - ${ipV6AddressValue} - """ - vmNetworksPositionsV6 = sbNetworksPositionsV6.append(vmNetworksPositionsV6Xml) + paramsMap.put("${key}_${networkKey}_v6_ip_${networkPosition}", "${ipV6AddressValue}") } } - String vmNetworksV6Xml = - """ - ${key}_${networkKey}_v6_ips - ${ipV6AddressValues} - """ - vmNetworks = sbVmNetworks.append(vmNetworksV6Xml) + paramsMap.put("${key}_${networkKey}_v6_ips", "${ipV6AddressValues}") } } - String vnfXml = - """ - ${key}_names - ${values} - """ - vnfVMS = sb.append(vnfXml) + paramsMap.put("${key}_names", "${values}") } } //SDNC Response Params @@ -575,7 +460,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { String vnfParamsChildNodes = utils.getChildNodes(data, "vnf-parameters") if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ // No SDNC params - }else{ + }else{ NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters") for (int z = 0; z < paramsList.getLength(); z++) { Node node = paramsList.item(z) @@ -583,34 +468,35 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name") if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") - String paraEntry = - """ - ${vnfParameterName} - ${vnfParameterValue} - """ - sdncResponseParams = sb.append(paraEntry) + paramsMap.put("${vnfParameterName}", "${vnfParameterValue}") } } } + + // Parameters received from the request should overwrite any parameters received from SDNC + if (vnfParamsMap != null) { + for (Map.Entry entry : vnfParamsMap.entrySet()) { + String vnfKey = entry.getKey() + String vnfValue = entry.getValue() + paramsMap.put("$vnfKey", "$vnfValue") + } + } + + StringBuilder sbParams = new StringBuilder() + def vfModuleParams = "" + for (Map.Entry entry : paramsMap.entrySet()) { + String paramsXml + String paramName = entry.getKey() + String paramValue = entry.getValue() + paramsXml = + """ + ${paramName} + ${paramValue} + + """ - - def vfModuleParams = """ - ${vnfInfo} - ${aZones} - ${vnfNetworkNetId} - ${vnfNetworkNetName} - ${vnfNetworkSubNetId} - ${vnfNetworkV6SubNetId} - ${vnfNetworkNetFqdn} - ${vnfNetworksSriovVlanFilters} - ${vnfVMS} - ${vnfVMSPositions} - ${vmNetworks} - ${vmNetworksPositions} - ${vmNetworksPositionsV6} - ${interfaceRoutePrefixes} - ${vnfParams} - ${sdncResponseParams}""" + vfModuleParams = sbParams.append(paramsXml) + } return vfModuleParams @@ -618,7 +504,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { /* - * VBNG specific method that parses VNF parameters passed in on the + * VBNG specific method that parses VNF parameters passed in on the * incoming requests and SDNC parameters returned from SDNC get response * and puts them into the format expected by VNF adapter. * @param vnfParamsMap - map of VNF parameters passed in the request body diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java new file mode 100644 index 0000000000..214ae28b70 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java @@ -0,0 +1,352 @@ +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.BpmPlatform; +import org.camunda.bpm.engine.MismatchingMessageCorrelationException; +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.runtime.MessageCorrelationResult; +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Abstract base class for callback services. + */ +public abstract class AbstractCallbackService { + public static final long DEFAULT_TIMEOUT_SECONDS = 60; + public static final long FAST_POLL_DUR_SECONDS = 5; + public static final long FAST_POLL_INT_MS = 100; + public static final long SLOW_POLL_INT_MS = 1000; + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + protected volatile ProcessEngineServices pes4junit = null; + + /** + * Parameterized callback handler. + */ + protected CallbackResult handleCallback(String method, Object message, + String messageEventName, String messageVariable, + String correlationVariable, String correlationValue, + String logMarker) { + + return handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker, null); + } + + /** + * Parameterized callback handler. + */ + protected CallbackResult handleCallback(String method, Object message, + String messageEventName, String messageVariable, + String correlationVariable, String correlationValue, + String logMarker, Map injectedVariables) { + + long startTime = System.currentTimeMillis(); + + LOGGER.debug(logMarker + " " + method + " received message: " + + (message == null ? "" : System.lineSeparator()) + message); + + try { + Map variables = new HashMap(); + + if (injectedVariables != null) { + variables.putAll(injectedVariables); + } + + variables.put(correlationVariable, correlationValue); + variables.put(messageVariable, message == null ? null : message.toString()); + + boolean ok = correlate(messageEventName, correlationVariable, + correlationValue, variables, logMarker); + + if (!ok) { + String msg = "No process is waiting for " + messageEventName + + " with " + correlationVariable + " = '" + correlationValue + "'"; + logCallbackError(method, startTime, msg); + return new CallbackError(msg); + } + + logCallbackSuccess(method, startTime); + return new CallbackSuccess(); + } catch (Exception e) { + String msg = "Caught " + e.getClass().getSimpleName() + + " processing " + messageEventName + " with " + correlationVariable + + " = '" + correlationValue + "'"; + logCallbackError(method, startTime, msg); + return new CallbackError(msg); + } + } + + /** + * Performs message correlation. Waits a limited amount of time for + * a process to become ready for correlation. The return value indicates + * whether or not a process was found to receive the message. Due to the + * synchronous nature of message injection in Camunda, by the time this + * method returns, one of 3 things will have happened: (1) the process + * received the message and ended, (2) the process received the message + * and reached an activity that suspended, or (3) an exception occurred + * during correlation or while the process was executing. Correlation + * exceptions are handled differently from process execution exceptions. + * Correlation exceptions are thrown so the client knows something went + * wrong with the delivery of the message. Process execution exceptions + * are logged but not thrown. + * @param messageEventName the message event name + * @param correlationVariable the process variable used as the correlator + * @param correlationValue the correlation value + * @param variables variables to inject into the process + * @param logMarker a marker for debug logging + * @return true if a process could be found, false if not + * @throws Exception for correlation errors + */ + protected boolean correlate(String messageEventName, String correlationVariable, + String correlationValue, Map variables, String logMarker) + throws Exception { + + LOGGER.debug(logMarker + " Attempting to find process waiting" + + " for " + messageEventName + " with " + correlationVariable + + " = '" + correlationValue + "'"); + + RuntimeService runtimeService = + getProcessEngineServices().getRuntimeService(); + + Map properties = + PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); + + long timeout = DEFAULT_TIMEOUT_SECONDS; + + // The code is here in case we ever need to change the default. + String s = properties.get("mso.correlation.timeout"); + if (s != null) { + try { + timeout = Long.parseLong(s); + } catch (NumberFormatException e) { + // Ignore + } + } + + long now = System.currentTimeMillis(); + long fastPollEndTime = now + (FAST_POLL_DUR_SECONDS * 1000); + long endTime = now + (timeout * 1000); + long sleep = FAST_POLL_INT_MS; + + List waitingProcesses = null; + Exception queryException = null; + int queryCount = 0; + int queryFailCount = 0; + + while (true) { + try { + ++queryCount; + waitingProcesses = runtimeService.createExecutionQuery() + .messageEventSubscriptionName(messageEventName) + .processVariableValueEquals(correlationVariable, correlationValue) + .list(); + } catch (Exception e) { + ++queryFailCount; + queryException = e; + } + + if (waitingProcesses != null && waitingProcesses.size() > 0) { + break; + } + + if (now > endTime - sleep) { + break; + } + + Thread.sleep(sleep); + now = System.currentTimeMillis(); + + if (now > fastPollEndTime) { + sleep = SLOW_POLL_INT_MS; + } + } + + if (waitingProcesses == null) { + waitingProcesses = new ArrayList(0); + } + + int count = waitingProcesses.size(); + + List execInfoList = new ArrayList(count); + for (Execution execution : waitingProcesses) { + execInfoList.add(new ExecInfo(execution)); + } + + LOGGER.debug(logMarker + " Found " + count + " process(es) waiting" + + " for " + messageEventName + " with " + correlationVariable + + " = '" + correlationValue + "': " + execInfoList); + + if (count == 0) { + if (queryFailCount > 0) { + String msg = queryFailCount + "/" + queryCount + + " execution queries failed attempting to correlate " + + messageEventName + " with " + correlationVariable + + " = '" + correlationValue + "'; last exception was:" + + queryException; + LOGGER.debug(msg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, msg, queryException); + } + + return false; + } + + if (count > 1) { + // Only one process should be waiting. Throw an exception back to the client. + throw new MismatchingMessageCorrelationException(messageEventName, + "more than 1 process is waiting with " + correlationVariable + + " = '" + correlationValue + "'"); + } + + // We prototyped an asynchronous solution, i.e. resuming the process + // flow in a separate thread, but this affected too many existing tests, + // and we went back to the synchronous solution. The synchronous solution + // has some troublesome characteristics though. For example, the + // resumed flow may send request #2 to a remote system before MSO has + // acknowledged the notification associated with request #1. + + try { + LOGGER.debug(logMarker + " Running " + execInfoList.get(0) + " to receive " + + messageEventName + " with " + correlationVariable + " = '" + + correlationValue + "'"); + + @SuppressWarnings("unused") + MessageCorrelationResult result = runtimeService + .createMessageCorrelation(messageEventName) + .setVariables(variables) + .processInstanceVariableEquals(correlationVariable, correlationValue) + .correlateWithResult(); + + } catch (MismatchingMessageCorrelationException e) { + // A correlation exception occurred even after we identified + // one waiting process. Throw it back to the client. + throw e; + } catch (Exception e) { + // This must be an exception from the flow itself. Log it, but don't + // report it back to the client. + String msg = "Caught " + e.getClass().getSimpleName() + " running " + + execInfoList.get(0) + " after receiving " + messageEventName + + " with " + correlationVariable + " = '" + correlationValue + + "': " + e; + LOGGER.debug(msg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, msg, e); + } + + return true; + } + + /** + * Records audit and metric events in the log for a callback success. + * @param method the method name + * @param startTime the request start time + */ + protected void logCallbackSuccess(String method, long startTime) { + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Completed " + method); + + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Completed " + method, + "BPMN", MsoLogger.getServiceName(), null); + } + + /** + * Records error, audit and metric events in the log for a callback + * internal error. + * @param method the method name + * @param startTime the request start time + * @param msg the error message + */ + protected void logCallbackError(String method, long startTime, String msg) { + logCallbackError(method, startTime, msg, null); + } + + /** + * Records error, audit and metric events in the log for a callback + * internal error. + * @param method the method name + * @param startTime the request start time + * @param msg the error message + * @param e the exception + */ + protected void logCallbackError(String method, long startTime, String msg, Exception e) { + if (e == null) { + LOGGER.error(MessageEnum.BPMN_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, msg); + } else { + LOGGER.error(MessageEnum.BPMN_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, msg, e); + } + + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.InternalError, "Completed " + method); + + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.InternalError, "Completed " + method, + "BPMN", MsoLogger.getServiceName(), null); + } + + /** + * Abstract callback result object. + */ + protected abstract class CallbackResult { + } + + /** + * Indicates that callback handling was successful. + */ + protected class CallbackSuccess extends CallbackResult { + } + + /** + * Indicates that callback handling failed. + */ + protected class CallbackError extends CallbackResult { + private final String errorMessage; + + public CallbackError(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * Gets the error message. + */ + public String getErrorMessage() { + return errorMessage; + } + } + + private static class ExecInfo { + private final Execution execution; + + public ExecInfo(Execution execution) { + this.execution = execution; + } + + @Override + public String toString() { + return "Process[" + execution.getProcessInstanceId() + + ":" + execution.getId() + "]"; + } + } + + protected ProcessEngineServices getProcessEngineServices() { + if (pes4junit == null) { + return BpmPlatform.getDefaultProcessEngine(); + } else { + return pes4junit; + } + } + + public void setProcessEngineServices4junit(ProcessEngineServices pes) { + pes4junit = pes; + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java index 4585d620ac..16fa51515e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java @@ -41,240 +41,53 @@ import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType; import org.openecomp.mso.bpmn.core.PropertyConfiguration; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; + /** - * @version 1.0 - * + * Implementation of SDNCAdapterCallbackService. */ @WebService(serviceName="SDNCAdapterCallbackService", targetNamespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") -public class SDNCAdapterCallbackServiceImpl implements SDNCCallbackAdapterPortType { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - private final int DEFAULT_RETRY_ATTEMPTS = 60; - private final int DEFAULT_SLEEP_TIME = 500; +public class SDNCAdapterCallbackServiceImpl extends AbstractCallbackService implements SDNCCallbackAdapterPortType { private final String logMarker = "[SDNC-CALLBACK]"; @Context WebServiceContext wsContext; - private volatile ProcessEngineServices pes4junit = null; - @WebMethod(operationName = "SDNCAdapterCallback") @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse") public SDNCAdapterResponse sdncAdapterCallback( @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest") SDNCAdapterCallbackRequest sdncAdapterCallbackRequest) { - //Callback URL to use http://localhost:28080/mso/SDNCAdapterCallbackService - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - String receivedRequestId = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId(); - MsoLogger.setServiceName("MSO." + "sdncAdapter"); - MsoLogger.setLogContext(receivedRequestId, "N/A"); - msoLogger.debug(logMarker + "Received callback response:" + sdncAdapterCallbackRequest.toString()); - SDNCAdapterResponse sdncAdapterResponse; - long startTime = System.currentTimeMillis(); - - /*Correlating the response with the running instance*/ - - // NOTE: the following loop is a workaround for problems we've had - // with reliability of the runtime service. It seems that queries - // sometimes return results, and sometimes they don't. This might - // be a problem in mysql only. We aren't sure if it affects camunda - // on oracle or mariadb. The workaround is to repeat the request - // a number of times until it succeeds. If it doesn't succeed after - // 60 tries, then we give up. - - int maxAttempts = DEFAULT_RETRY_ATTEMPTS; - int attempt = 1; - int sleepTime = DEFAULT_SLEEP_TIME; + String method = "sdncAdapterCallback"; + Object message = sdncAdapterCallbackRequest; + String messageEventName = "sdncAdapterCallbackRequest"; + String messageVariable = "sdncAdapterCallbackRequest"; + String correlationVariable = "SDNCA_requestId"; + String correlationValue = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId(); - Map bpmnProperties = getMSOBPMNURNProperties(); - if (bpmnProperties != null) { - try { - maxAttempts = Integer.parseInt(bpmnProperties.get("mso.callbackRetryAttempts")); - msoLogger.debug(logMarker + "mso.callbackRetryAttempts=" + maxAttempts); - sleepTime = Integer.parseInt(bpmnProperties.get("mso.callbackRetrySleepTime")); - msoLogger.debug(logMarker + "mso.callbackRetrySleepTime:" + sleepTime); - } catch (Exception ex) { - - msoLogger.debug (logMarker - + "Error parsing mso.callbackRetrySleepTime/mso.callbackRetryAttempts:" - + sleepTime + ":" - + maxAttempts); - - } - } - - /* Check to make sure the process instance is reay for correlation*/ - try{ - isReadyforCorrelation(runtimeService, receivedRequestId, maxAttempts, sleepTime ); - }catch(Exception e){ - String msg = - "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '" - + receivedRequestId - + "' but that RequestId doesn't exist or has timed out waiting for the callback"; - sdncAdapterResponse = new SDNCAdapterExceptionResponse(e); - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService." ); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlationValue, "N/A"); - msoLogger.debug(logMarker + "*** Received MSO sdncAdapterCallbackService ******"); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO sdncAdapterCallbackService"); - - msoLogger.debug(logMarker + "Callback response string:\n" + sdncAdapterCallbackRequest.toString()); + CallbackResult result = handleCallback(method, message, messageEventName, + messageVariable, correlationVariable, correlationValue, logMarker); - String reqId = receivedRequestId; - Map variables = new HashMap(); - variables.put("SDNCA_requestId", reqId ); - variables.put("sdncAdapterCallbackRequest", sdncAdapterCallbackRequest.toString()); - while (true) { - try { - // sdncAdapterCallbackRequest is the message event name (defined in the bpmn process) - runtimeService.createMessageCorrelation("sdncAdapterCallbackRequest") - .setVariables(variables) - .processInstanceVariableEquals("SDNCA_requestId", reqId).correlate(); - sdncAdapterResponse = new SDNCAdapterResponse(); - msoLogger.debug(logMarker + "***** Completed processing of MSO sdncAdapterCallbackService ******"); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch (attempt " + attempt + "/" + maxAttempts + ")"); - if (attempt == maxAttempts) { - // Couldn't correlate requestId to any active flow - //MsoLogger logger = MsoLogger.getMsoLogger("SDNCAdapterCallbackService"); - String msg = - "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '" - + receivedRequestId - + "' but that RequestId could not be correlated to any active process - ignoring the Request"; - sdncAdapterResponse = new SDNCAdapterExceptionResponse(e); - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService." ); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } - - try { - Thread.sleep(sleepTime); - } catch (InterruptedException e2) { - String msg = - "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '" - + receivedRequestId - + "' but correlation was interrupted"; - sdncAdapterResponse = new SDNCAdapterExceptionResponse(e); - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } - } - - attempt++; - } - } - - - private Map getMSOBPMNURNProperties() { - PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); - Map props = propertyConfiguration.getProperties("mso.bpmn.urn.properties"); - return props; - } - - private void isReadyforCorrelation(RuntimeService runtimeService, - String receivedRequestId, int retries, int sleepTime){ - ExecutionQuery waitingInstances = null; - long waitingInstancesCount = 0; - - //Workaround for performance testing, explicit wait for a second for the transactions to be committed - //Also check to make sure the process didn't timeout before trying to correlate - - do{ - waitingInstances = runtimeService.createExecutionQuery() // - .messageEventSubscriptionName("sdncAdapterCallbackRequest") - .processVariableValueEquals("SDNCA_requestId", receivedRequestId); - waitingInstancesCount = waitingInstances.count(); - retries--; - msoLogger.debug(logMarker + "waitingInstancesCount: " + waitingInstancesCount); - try { - Thread.sleep(sleepTime); - } catch (InterruptedException e) { - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker, e); - - } - }while (waitingInstancesCount==0 && retries > 0); - if(waitingInstancesCount > 0){ - msoLogger.debug(logMarker + "waitingInstancesCount before timeout check: " + waitingInstancesCount); - waitingInstancesCount = waitingInstances.processVariableValueEquals("asynchronousResponseTimeout", false).count(); - msoLogger.debug(logMarker + "waitingInstancesCount after timeout check: " + waitingInstancesCount); - if(waitingInstancesCount<=0){ - msoLogger.debug(logMarker + "detected timeout on flow to correlate"); - throw new IllegalStateException("process timed out"); - } - }else{ - //flow may have already ended, so can't check timeout variable. Throw exception? - msoLogger.debug(logMarker + "no flow to correlate to"); - throw new IllegalStateException("no flow to correlate to"); - } - } - - private ProcessEngineServices getProcessEngineServices() { - if (pes4junit == null) { - return BpmPlatform.getDefaultProcessEngine(); + if (result instanceof CallbackError) { + return new SDNCAdapterErrorResponse(((CallbackError)result).getErrorMessage()); } else { - return pes4junit; + return new SDNCAdapterResponse(); } } - @WebMethod(exclude=true) - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = pes; - } - - public class SDNCAdapterExceptionResponse extends SDNCAdapterResponse { - private Exception ex; + // This subclass allows unit tests to extract the error + public class SDNCAdapterErrorResponse extends SDNCAdapterResponse { + private String error; - public SDNCAdapterExceptionResponse(Exception ex) { - super(); - this.ex = ex; + public SDNCAdapterErrorResponse(String error) { + this.error = error; } - public Exception getException() { - return ex; + public String getError() { + return error; } } -} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java index 457717243a..0faf5feafc 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java @@ -1,536 +1,249 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.workflow.service; - -import java.util.HashMap; -import java.util.Map; - -import javax.jws.Oneway; -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebService; -import javax.ws.rs.core.Context; -import javax.xml.ws.Action; -import javax.xml.ws.RequestWrapper; -import javax.xml.ws.WebServiceContext; - -import org.camunda.bpm.BpmPlatform; -import org.camunda.bpm.engine.MismatchingMessageCorrelationException; -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.RuntimeService; -import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification; -import org.openecomp.mso.bpmn.common.adapter.vnf.DeleteVnfNotification; -import org.openecomp.mso.bpmn.common.adapter.vnf.MsoExceptionCategory; -import org.openecomp.mso.bpmn.common.adapter.vnf.QueryVnfNotification; -import org.openecomp.mso.bpmn.common.adapter.vnf.RollbackVnfNotification; -import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification; -import org.openecomp.mso.bpmn.common.adapter.vnf.VnfAdapterNotify; -import org.openecomp.mso.bpmn.common.adapter.vnf.VnfRollback; -import org.openecomp.mso.bpmn.common.adapter.vnf.VnfStatus; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -/** - * This is the service class for VnfAdapterNotify - * TODO: Add addition VnfAdapterNotify Methods for remaining VnfAdapterNotify operations. - */ - -@WebService(serviceName = "vnfAdapterNotify", targetNamespace = "http://org.openecomp.mso/vnfNotify") -public class VnfAdapterNotifyServiceImpl implements VnfAdapterNotify{ - +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.workflow.service; + +import javax.jws.Oneway; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.ws.rs.core.Context; +import javax.xml.ws.Action; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.WebServiceContext; + +import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.DeleteVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.MsoExceptionCategory; +import org.openecomp.mso.bpmn.common.adapter.vnf.QueryVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.RollbackVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.VnfAdapterNotify; +import org.openecomp.mso.bpmn.common.adapter.vnf.VnfRollback; +import org.openecomp.mso.bpmn.common.adapter.vnf.VnfStatus; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Implementation of the VnfAdapterNotify service. + */ +@WebService(serviceName = "vnfAdapterNotify", targetNamespace = "http://org.openecomp.mso/vnfNotify") +public class VnfAdapterNotifyServiceImpl extends AbstractCallbackService implements VnfAdapterNotify{ + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - private final String logMarker = "[VNF-NOTIFY]"; - - @Context WebServiceContext wsContext; - - private volatile ProcessEngineServices pes4junit = null; - - /** - * - * @param errorMessage - * @param exception - * @param messageId - * @param completed - */ - @WebMethod(operationName = "rollbackVnfNotification") - @Oneway - @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.RollbackVnfNotification") + private final String logMarker = "[VNF-NOTIFY]"; + + @Context WebServiceContext wsContext; + + @WebMethod(operationName = "rollbackVnfNotification") + @Oneway + @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.RollbackVnfNotification") @Action(input = "http://org.openecomp.mso/notify/adapterNotify/rollbackVnfNotificationRequest") - public void rollbackVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage) { - - - - RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification(); - - rollbackVnfNotification.setMessageId(messageId); - rollbackVnfNotification.setCompleted(completed); - rollbackVnfNotification.setException(exception); - rollbackVnfNotification.setErrorMessage(errorMessage); - - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - - MsoLogger.setServiceName("MSO." + "vnfAdapterRollback"); - MsoLogger.setLogContext(messageId, "N/A"); - msoLogger.debug(logMarker + "Received RollbackVnfNotification" + rollbackVnfNotification.toString()); - - long startTime = System.currentTimeMillis(); - try { - - /* Check to make sure the process instance is ready for correlation*/ - isReadyforCorrelation(runtimeService, messageId, "rollbackVnfNotificationCallback", "VNFRB_messageId"); - - msoLogger.debug(logMarker + "*** Received MSO rollbackVnfNotification Callback ******"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); - msoLogger.debug(logMarker + "Rollback VNF Notification string:\n" + rollbackVnfNotification.toString()); - - System.out.println("testing ROllbackVnfNotification : " + rollbackVnfNotification.toString()); - - Map variables = new HashMap(); - variables.put("VNFRB_messageId", messageId ); - variables.put("rollbackVnfNotificationCallback", rollbackVnfNotification.toString()); - - /*Correlating the response with the running instance*/ - - runtimeService.createMessageCorrelation("rollbackVnfNotificationCallback").setVariables(variables) - .processInstanceVariableEquals("VNFRB_messageId", messageId).correlate(); - - msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); - String msg = - "VNF Adapter Notify Service received a Create VNF Notification request with RequestId '" - + messageId - + "' but that RequestId could not be correlated to any active process - ignoring the request"; - - msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg); - - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Rollback VNF Notification."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Rollback VNF Notification.", "BPMN", - MsoLogger.getServiceName(), "rollbackVnfNotification"); - - return; - } - - - - /** - * - * @param errorMessage - * @param vnfExists - * @param status - * @param exception - * @param outputs - * @param messageId - * @param vnfId - * @param completed - */ - @WebMethod(operationName = "queryVnfNotification") - @Oneway + public void rollbackVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage) { + + RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification(); + + rollbackVnfNotification.setMessageId(messageId); + rollbackVnfNotification.setCompleted(completed); + rollbackVnfNotification.setException(exception); + rollbackVnfNotification.setErrorMessage(errorMessage); + + String method = "rollbackVnfNotification"; + Object message = rollbackVnfNotification; + String messageEventName = "rollbackVnfNotificationCallback"; + String messageVariable = "rollbackVnfNotificationCallback"; + String correlationVariable = "VNFRB_messageId"; + String correlationValue = messageId; + + handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); + } + + @WebMethod(operationName = "queryVnfNotification") + @Oneway @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification") @Action(input = "http://org.openecomp.mso/notify/adapterNotify/queryVnfNotificationRequest") - public void queryVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "vnfExists", targetNamespace = "") - Boolean vnfExists, - @WebParam(name = "vnfId", targetNamespace = "") - String vnfId, - @WebParam(name = "status", targetNamespace = "") - VnfStatus status, - @WebParam(name = "outputs", targetNamespace = "") - org.openecomp.mso.bpmn.common.adapter.vnf.QueryVnfNotification.Outputs outputs){ - - QueryVnfNotification queryVnfNotification = new QueryVnfNotification(); - - queryVnfNotification.setMessageId(messageId); - queryVnfNotification.setCompleted(completed); - queryVnfNotification.setException(exception); - queryVnfNotification.setErrorMessage(errorMessage); - queryVnfNotification.setVnfExists(vnfExists); - queryVnfNotification.setVnfId(vnfId); - queryVnfNotification.setStatus(status); - queryVnfNotification.setOutputs(outputs); - - - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - - MsoLogger.setServiceName("MSO." + "vnf Adapter Query"); - MsoLogger.setLogContext(messageId, "N/A"); - msoLogger.debug(logMarker + "Received QueryVnfNotification" + queryVnfNotification.toString()); - - System.out.println("Received QueryVnfNotification : " + queryVnfNotification.toString()); - - long startTime = System.currentTimeMillis(); - try { - - /* Check to make sure the process instance is ready for correlation*/ - isReadyforCorrelation(runtimeService, messageId, "queryVnfNotificationCallback", "VNFQ_messageId"); - - msoLogger.debug(logMarker + "*** Received MSO queryVnfNotification Callback ******"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); - msoLogger.debug(logMarker + "Query VNF Notification string:\n" + queryVnfNotification.toString()); - - Map variables = new HashMap(); - variables.put("VNFQ_messageId", messageId ); - variables.put("queryVnfNotificationCallback", queryVnfNotification.toString()); - - /*Correlating the response with the running instance*/ - - runtimeService.createMessageCorrelation("queryVnfNotificationCallback").setVariables(variables) - .processInstanceVariableEquals("VNFQ_messageId", messageId).correlate(); - - msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); - String msg = - "VNF Adapter Notify Service received a Query VNF Notification request with RequestId '" - + messageId - + "' but that RequestId could not be correlated to any active process - ignoring the request"; - - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - } - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Query VNF Notification."); - - return; - } - - - - - /** - * - * @param errorMessage - * @param exception - * @param rollback - * @param outputs - * @param messageId - * @param vnfId - * @param completed - */ - @WebMethod(operationName = "createVnfNotification") - @Oneway + public void queryVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "vnfExists", targetNamespace = "") + Boolean vnfExists, + @WebParam(name = "vnfId", targetNamespace = "") + String vnfId, + @WebParam(name = "status", targetNamespace = "") + VnfStatus status, + @WebParam(name = "outputs", targetNamespace = "") + QueryVnfNotification.Outputs outputs){ + + String method = "queryVnfNotification"; + String messageEventName = "queryVnfNotificationCallback"; + String messageVariable = "queryVnfNotificationCallback"; + String correlationVariable = "VNFQ_messageId"; + String correlationValue = messageId; + + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlationValue, "N/A"); + + QueryVnfNotification message = new QueryVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + message.setVnfExists(vnfExists); + message.setVnfId(vnfId); + message.setStatus(status); + message.setOutputs(outputs); + + handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); + } + + @WebMethod(operationName = "createVnfNotification") + @Oneway @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification") @Action(input = "http://org.openecomp.mso/notify/adapterNotify/createVnfNotificationRequest") - public void createVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "vnfId", targetNamespace = "") - String vnfId, - @WebParam(name = "outputs", targetNamespace = "") - org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs outputs, - @WebParam(name = "rollback", targetNamespace = "") - VnfRollback rollback){ - - CreateVnfNotification createVnfNotification = new CreateVnfNotification(); - - createVnfNotification.setMessageId(messageId); - createVnfNotification.setCompleted(completed); - createVnfNotification.setException(exception); - createVnfNotification.setErrorMessage(errorMessage); - createVnfNotification.setVnfId(vnfId); - createVnfNotification.setOutputs(outputs); - createVnfNotification.setRollback(rollback); - - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - - MsoLogger.setServiceName("MSO." + "vnf Adapter Create"); - MsoLogger.setLogContext(messageId, "N/A"); - msoLogger.debug(logMarker + "Received CreateVnfNotification - " + createVnfNotification.toString()); - - long startTime = System.currentTimeMillis(); - try { - - /* Check to make sure the process instance is ready for correlation*/ - isReadyforCorrelation(runtimeService, messageId, "createVnfNotificationCallback", "VNFC_messageId"); - - msoLogger.debug(logMarker + "*** Received MSO createVnfNotification Callback ******"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); - - msoLogger.debug(logMarker + "Create VNF Notification string:\n" + createVnfNotification.toString()); - - Map variables = new HashMap(); - variables.put("VNFC_messageId", messageId ); - variables.put("createVnfNotificationCallback", createVnfNotification.toString()); - - /*Correlating the response with the running instance*/ - - runtimeService.createMessageCorrelation("createVnfNotificationCallback").setVariables(variables) - .processInstanceVariableEquals("VNFC_messageId", messageId).correlate(); - - msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); - String msg = - "VNF Adapter Notify Service received a Create VNF Notification request with RequestId '" - + messageId - + "' but that RequestId could not be correlated to any active process - ignoring the request"; - - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Query VNF Notification."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Query VNF Notification.", "BPMN", - MsoLogger.getServiceName(), "createVnfNotification"); - - return; - } - - /** - * - * @param errorMessage - * @param exception - * @param rollback - * @param outputs - * @param messageId - * @param completed - */ - @WebMethod(operationName = "updateVnfNotification") - @Oneway + public void createVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "vnfId", targetNamespace = "") + String vnfId, + @WebParam(name = "outputs", targetNamespace = "") + CreateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") + VnfRollback rollback){ + + String method = "createVnfNotification"; + String messageEventName = "createVnfNotificationCallback"; + String messageVariable = "createVnfNotificationCallback"; + String correlationVariable = "VNFC_messageId"; + String correlationValue = messageId; + + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlationValue, "N/A"); + + CreateVnfNotification message = new CreateVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + message.setVnfId(vnfId); + message.setOutputs(outputs); + message.setRollback(rollback); + + handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); + } + + @WebMethod(operationName = "updateVnfNotification") + @Oneway @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification") @Action(input = "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest") - public void updateVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "outputs", targetNamespace = "") - org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs outputs, - @WebParam(name = "rollback", targetNamespace = "") - VnfRollback rollback){ - - UpdateVnfNotification updateVnfNotification = new UpdateVnfNotification(); - - updateVnfNotification.setMessageId(messageId); - updateVnfNotification.setCompleted(completed); - updateVnfNotification.setException(exception); - updateVnfNotification.setErrorMessage(errorMessage); - updateVnfNotification.setOutputs(outputs); - updateVnfNotification.setRollback(rollback); - - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - - MsoLogger.setServiceName("MSO." + "vnf Adapter Update"); - MsoLogger.setLogContext(messageId, "N/A"); - msoLogger.debug(logMarker + "Received UpdateVnfNotification - " + updateVnfNotification.toString()); - - long startTime = System.currentTimeMillis(); - try { - - // Check to make sure the process instance is ready for correlation - isReadyforCorrelation(runtimeService, messageId, "updateVnfNotificationCallback", "VNFU_messageId"); - - msoLogger.debug(logMarker + "*** Received MSO updateVnfNotification Callback ******"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); - - msoLogger.debug(logMarker + "Update VNF Notification string:\n" + updateVnfNotification.toString()); - - Map variables = new HashMap(); - variables.put("VNFU_messageId", messageId ); - variables.put("updateVnfNotificationCallback", updateVnfNotification.toString()); - - //Correlating the response with the running instance - runtimeService.createMessageCorrelation("updateVnfNotificationCallback").setVariables(variables) - .processInstanceVariableEquals("VNFU_messageId", messageId).correlate(); - - msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); - - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); - String msg = - "VNF Adapter Notify Service received a Update VNF Notification request with RequestId '" - + messageId - + "' but that RequestId could not be correlated to any active process - ignoring the request"; - - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Update VNF Notification."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Update VNF Notification.", "BPMN", - MsoLogger.getServiceName(), "updateVnfNotification"); - - return; - } - - /** - * - * @param errorMessage - * @param exception - * @param messageId - * @param completed - */ - - //@WebService(serviceName="VNFAdapterDeleteCallbackV1", targetNamespace="http://org.openecomp.mso/vnfNotify") - @WebMethod(operationName = "deleteVnfNotification") - @Oneway + public void updateVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "outputs", targetNamespace = "") + UpdateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") + VnfRollback rollback){ + + String method = "updateVnfNotification"; + String messageEventName = "updateVnfNotificationCallback"; + String messageVariable = "updateVnfNotificationCallback"; + String correlationVariable = "VNFU_messageId"; + String correlationValue = messageId; + + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlationValue, "N/A"); + + UpdateVnfNotification message = new UpdateVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + message.setOutputs(outputs); + message.setRollback(rollback); + + handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); + } + + @WebMethod(operationName = "deleteVnfNotification") + @Oneway @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.DeleteVnfNotification") @Action(input = "http://org.openecomp.mso/notify/adapterNotify/deleteVnfNotificationRequest") - public void deleteVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage) { - - //Callback URL to use http://localhost:28080/mso/services/VNFAdapterDeleteCallbackV1 - - //DeleteVnfNotification Class - DeleteVnfNotification deleteVnfNotification = new DeleteVnfNotification(); - deleteVnfNotification.setMessageId(messageId); - deleteVnfNotification.setCompleted(completed); - deleteVnfNotification.setException(exception); - deleteVnfNotification.setErrorMessage(errorMessage); - - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - - MsoLogger.setServiceName("MSO." + "vnfAdapterDelete"); - MsoLogger.setLogContext(messageId, "N/A"); - msoLogger.debug(logMarker + "Received DeleteVnfNotification callback: " + deleteVnfNotification.toString()); - - long startTime = System.currentTimeMillis(); - try { - - /* Check to make sure the process instance is ready for correlation*/ - //isReadyforCorrelation(runtimeService, messageId, "deleteVnfACallback", "VNFDEL_uuid"); - - msoLogger.debug(logMarker + " *** Received MSO deleteVnfACallback ******"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO deleteVnfACallback "); - msoLogger.debug(logMarker + " Callback response string:\n" + deleteVnfNotification.toString()); - - Map variables = new HashMap(); - variables.put("VNFDEL_uuid", messageId); - variables.put("deleteVnfACallback", deleteVnfNotification.toString()); - - /*Correlating the response with the running instance*/ - - runtimeService.createMessageCorrelation("deleteVnfACallback") - .setVariables(variables) - .processInstanceVariableEquals("VNFDEL_uuid", messageId).correlate(); - - msoLogger.debug(logMarker + "***** Completed processing of MSO deleteVnfACallback ******"); - - } catch(MismatchingMessageCorrelationException e) { - - msoLogger.debug(logMarker + " [CORM]correlation id mismatch"); - // Couldn't correlate requestId to any active flow - //MsoLogger logger = MsoLogger.getMsoLogger("SDNCAdapterCallbackService"); - - String msg = - "Vnf Adapter Callback Service received a Vnf Adapter Callback with messageId '" - + messageId - + "' but that messageId could not be correlated to any active process - ignoring the Request"; - - msoLogger.error(MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO VNFAdapterDeleteCallbackV1."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO VNFAdapterDeleteCallbackV1.", "BPMN", - MsoLogger.getServiceName(), "deleteVnfNotification"); - - return; - } - - private void isReadyforCorrelation(RuntimeService runtimeService, String requestId, String responseName, String correlationValue) { - - long waitingInstances = runtimeService.createExecutionQuery().messageEventSubscriptionName(responseName).processVariableValueEquals(correlationValue, requestId).count(); - int retries = 50; - while (waitingInstances==0 && retries > 0) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - // should I add new exception Message to MessageEnum??? - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logMarker, e); - - } // you can still play with the numbers - waitingInstances = runtimeService.createExecutionQuery() // - .messageEventSubscriptionName(responseName) - .processVariableValueEquals(correlationValue, requestId).count(); - retries--; - } - } - - - private ProcessEngineServices getProcessEngineServices() { - if (pes4junit == null) { - return BpmPlatform.getDefaultProcessEngine(); - } else { - return pes4junit; - } - } - - @WebMethod(exclude=true) - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = pes; - } -} + public void deleteVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage) { + + String method = "deleteVnfNotification"; + String messageEventName = "deleteVnfACallback"; + String messageVariable = "deleteVnfACallback"; + String correlationVariable = "VNFDEL_uuid"; + String correlationValue = messageId; + + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlationValue, "N/A"); + + DeleteVnfNotification message = new DeleteVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + + handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java index 5afbded982..698ec13c00 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.Map; import javax.ws.rs.Consumes; +import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -11,10 +12,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.camunda.bpm.BpmPlatform; -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.RuntimeService; - import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; @@ -27,25 +24,29 @@ import org.openecomp.mso.logger.MsoLogger; * */ @Path("/") -public class WorkflowMessageResource { +public class WorkflowMessageResource extends AbstractCallbackService { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); private static final String LOGMARKER = "[WORKFLOW-MESSAGE]"; - - private ProcessEngineServices pes4junit = null; @POST @Path("/WorkflowMessage/{messageType}/{correlator}") @Consumes("*/*") @Produces(MediaType.TEXT_PLAIN) - public Response deliver(@PathParam("messageType") String messageType, - @PathParam("correlator") String correlator, String message) { + public Response deliver( + @HeaderParam("Content-Type") String contentType, + @PathParam("messageType") String messageType, + @PathParam("correlator") String correlator, + String message) { + + String method = "receiveWorkflowMessage"; + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlator, "N/A"); LOGGER.debug(LOGMARKER + " Received workflow message" + " type='" + messageType + "'" + " correlator='" + correlator + "'" - + System.lineSeparator() + message); - - MsoLogger.setServiceName("MSO." + "WorkflowMessage"); + + (contentType == null ? "" : " contentType='" + contentType + "'") + + " message=" + System.lineSeparator() + message); if (messageType == null || messageType.isEmpty()) { String msg = "Missing message type"; @@ -63,79 +64,25 @@ public class WorkflowMessageResource { return Response.status(400).entity(msg).build(); } - String correlatorVariable = messageType + "_CORRELATOR"; + String messageEventName = "WorkflowMessage"; String messageVariable = messageType + "_MESSAGE"; + String correlationVariable = messageType + "_CORRELATOR"; + String correlationValue = correlator; + String contentTypeVariable = messageType + "_CONTENT_TYPE"; - long startTime = System.currentTimeMillis(); - - try { - RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); - - if (!isReadyforCorrelation(runtimeService, correlatorVariable, correlator)) { - String msg = "No process is waiting to receive '" + messageType + "' WorkflowMessage with correlator '" + correlator + "'"; - LOGGER.debug(LOGMARKER + " " + msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, LOGMARKER + ":" + msg); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BusinessProcesssError, msg, "BPMN", MsoLogger.getServiceName(), messageType); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BusinessProcesssError, msg); - return Response.status(500).entity(msg).build(); - } + Map variables = new HashMap(); - Map variables = new HashMap(); - variables.put(correlatorVariable, correlator); - variables.put(messageVariable, message); - - runtimeService.createMessageCorrelation("WorkflowMessage").setVariables(variables) - .processInstanceVariableEquals(correlatorVariable, correlator).correlate(); - - String msg = "Completed delivery of '" + messageType + "' WorkflowMessage with correlator '" + correlator + "'"; - LOGGER.debug(LOGMARKER + msg); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg, "BPMN", MsoLogger.getServiceName(), messageType); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg); - return Response.status(204).build(); - } catch (Exception e) { - // For example: MismatchingMessageCorrelationException - String msg = "Caught " + e.getClass().getSimpleName() + " processing '" + messageType + "' WorkflowMessage with " + correlatorVariable + "='" + correlator + "'"; - LOGGER.debug(LOGMARKER + " " + msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, LOGMARKER + ":" + msg, e); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, msg, "BPMN", MsoLogger.getServiceName(), messageType); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, msg); - return Response.status(500).entity(msg).build(); + if (contentType != null) { + variables.put(contentTypeVariable, contentType); } - } - - private boolean isReadyforCorrelation(RuntimeService runtimeService, - String correlationVariable, String correlationValue) - throws InterruptedException { - - long waitingInstances = runtimeService.createExecutionQuery() - .messageEventSubscriptionName("WorkflowMessage") - .processVariableValueEquals(correlationVariable, correlationValue) - .count(); - - int retries = 50; - while (waitingInstances == 0 && retries > 0) { - Thread.sleep(100); - waitingInstances = runtimeService.createExecutionQuery() - .messageEventSubscriptionName("WorkflowMessage") - .processVariableValueEquals(correlationVariable, correlationValue) - .count(); - - retries--; - } + CallbackResult result = handleCallback(method, message, messageEventName, + messageVariable, correlationVariable, correlationValue, LOGMARKER, variables); - return waitingInstances != 0; - } - - private ProcessEngineServices getProcessEngineServices() { - if (pes4junit == null) { - return BpmPlatform.getDefaultProcessEngine(); + if (result instanceof CallbackError) { + return Response.status(500).entity(((CallbackError)result).getErrorMessage()).build(); } else { - return pes4junit; + return Response.status(204).build(); } } - - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = pes; - } } \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn index af615e379d..6f012bcb88 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -9,16 +9,16 @@ GenericGetService getService = new GenericGetService() getService.preProcessRequest(execution) ]]> - - + + SequenceFlow_2 getUrlYes getUrlNo - + - + SequenceFlow_7 @@ -28,12 +28,12 @@ getService.preProcessRequest(execution) ExceptionUtil ex = new ExceptionUtil() ex.processSubflowsBPMNException(execution)]]> - + SequenceFlow_7 - + - + SequenceFlow_8 @@ -46,43 +46,43 @@ GenericGetService getService = new GenericGetService() getService.setSuccessIndicator(execution, true) ]]> - - + + SequenceFlow_5 SequenceFlow_3 - + getUrlNo foundYes SequenceFlow_5 - - + + obtainById SequenceFlow_4 - - + + obtainByName SequenceFlow_13 - - + + getUrlYes obtainById obtainByName - + @@ -94,226 +94,226 @@ getService.obtainServiceInstanceUrlByName(execution)]]> - + notFound - + SequenceFlow_4 SequenceFlow_13 SequenceFlow_14 - + SequenceFlow_6 - + SequenceFlow_1 - + - + - + - + - - + + - + - + - + - - + + - + - + - + - + - + - - - + + + - + - - - + + + - + - - + + - + - - - - + + + + - + - + - - + + - + - + - + - - + + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - - - + + + - + - - - + + + - + - - - + + + - + - + - + - - + + - + - - + + - + - - + + - + - + - + diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy index 8a5f9e96cd..19d21275be 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy @@ -1,305 +1,385 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common.scripts; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.* - -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.mockito.internal.debugging.MockitoDebuggerImpl -import org.junit.Before -import org.openecomp.mso.bpmn.common.scripts.AaiUtil; -import org.junit.Rule; -import org.junit.Test -import org.junit.Ignore -import org.junit.runner.RunWith -import org.junit.Before; -import org.junit.Test; -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 - -@RunWith(MockitoJUnitRunner.class) -class AaiUtilTest extends MsoGroovyTest { - - @Test - public void testGetVersionDefault() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - assertEquals('8', version) - } - - @Test - public void testGetVersionResourceSpecific() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - assertEquals('7', version) - } - - @Test - public void testGetVersionFlowSpecific() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_custom_CreateAAIVfModule_aai_version")).thenReturn('6') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - assertEquals('6', version) - } - - @Test(expected=java.lang.Exception.class) - public void testGetVersionNotDefined() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - } - - @Test - public void testGetUriDefaultVersion() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getUri(mockExecution, 'l3-network') - assertEquals('/aai/v8/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetUriFlowAndResourceSpecific() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_CreateAAIVfModule_aai_l3_network_uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getUri(mockExecution, 'l3-network') - assertEquals('/aai/v6/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetNetworkGenericVnfEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') - when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def endpoint = aaiUtil.getNetworkGenericVnfEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf', endpoint) - } - - @Test - public void testGetNetworkGenericVnfUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkGenericVnfUri(mockExecution) - assertEquals('/aai/v8/network/generic-vnfs/generic-vnf', uri) - } - - @Test - public void testGetNetworkVpnBindingUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn('/aai/v8/network/vpn-bindings/vpn-binding') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkVpnBindingUri(mockExecution) - assertEquals('/aai/v8/network/vpn-bindings/vpn-binding', uri) - } - - @Test - public void testGetNetworkPolicyUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn('/aai/v8/network/network-policies/network-policy') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkPolicyUri(mockExecution) - assertEquals('/aai/v8/network/network-policies/network-policy', uri) - } - - @Test - public void testGetNetworkTableReferencesUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_route_table_reference_uri")).thenReturn('/aai/v8/network/route-table-references/route-table-reference') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkTableReferencesUri(mockExecution) - assertEquals('/aai/v8/network/route-table-references/route-table-reference', uri) - } - - @Test - public void testGetNetworkVceUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vce_uri")).thenReturn('/aai/v8/network/vces/vce') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkVceUri(mockExecution) - assertEquals('/aai/v8/network/vces/vce', uri) - } - - @Test - public void testGetNetworkL3NetworkUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) - assertEquals('/aai/v8/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetBusinessCustomerUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_customer_uri")).thenReturn('/aai/v8/business/customers/customer') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getBusinessCustomerUri(mockExecution) - assertEquals('/aai/v8/business/customers/customer', uri) - } - - @Test - public void testGetCloudInfrastructureCloudRegionEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') - when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) - } - - @Test - public void testGetCloudInfrastructureCloudRegionUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureCloudRegionUri(mockExecution) - assertEquals('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) - } - - @Test - public void testGetCloudInfrastructureTenantUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_tenant_uri")).thenReturn('/aai/v8/cloud-infrastructure/tenants/tenant') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureTenantUri(mockExecution) - assertEquals('/aai/v8/cloud-infrastructure/tenants/tenant', uri) - } - - @Test - public void testGetSearchNodesQueryUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchNodesQueryUri(mockExecution) - assertEquals('/aai/v8/search/nodes-query', uri) - } - - @Test - public void testGetSearchNodesQueryEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query') - when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchNodesQueryEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/search/nodes-query', uri) - } - - @Test - public void testGetSearchGenericQueryUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_query_uri")).thenReturn('/aai/v8/search/generic-query') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchGenericQueryUri(mockExecution) - assertEquals('/aai/v8/search/generic-query', uri) - } - - @Test - public void testGetNamespaceFromUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def ns = aaiUtil.getNamespaceFromUri('/aai/v6/search/generic-query') - assertEquals('http://org.openecomp.aai.inventory/v6', ns) - } - -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common.scripts; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.* + +import org.openecomp.mso.rest.HttpHeader +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.junit.Before +import org.openecomp.mso.bpmn.common.scripts.AaiUtil; +import org.junit.Rule; +import org.junit.Test +import org.junit.Ignore +import org.junit.runner.RunWith +import org.junit.Before; +import org.junit.Test; +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 + +@RunWith(MockitoJUnitRunner.class) +class AaiUtilTest extends MsoGroovyTest { + + @Test + public void testGetVersionDefault() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + assertEquals('8', version) + } + + @Test + public void testGetVersionResourceSpecific() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + assertEquals('7', version) + } + + @Test + public void testGetVersionFlowSpecific() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_custom_CreateAAIVfModule_aai_version")).thenReturn('6') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + assertEquals('6', version) + } + + @Test(expected=java.lang.Exception.class) + public void testGetVersionNotDefined() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + } + + @Test + public void testGetUriDefaultVersion() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getUri(mockExecution, 'l3-network') + assertEquals('/aai/v8/network/l3-networks/l3-network', uri) + } + + @Test + public void testGetUriFlowAndResourceSpecific() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_CreateAAIVfModule_aai_l3_network_uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getUri(mockExecution, 'l3-network') + assertEquals('/aai/v6/network/l3-networks/l3-network', uri) + } + + @Test + public void testGetNetworkGenericVnfEndpoint() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def endpoint = aaiUtil.getNetworkGenericVnfEndpoint(mockExecution) + assertEquals('http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf', endpoint) + } + + @Test + public void testGetNetworkGenericVnfUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkGenericVnfUri(mockExecution) + assertEquals('/aai/v8/network/generic-vnfs/generic-vnf', uri) + } + + @Test + public void testGetNetworkVpnBindingUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn('/aai/v8/network/vpn-bindings/vpn-binding') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkVpnBindingUri(mockExecution) + assertEquals('/aai/v8/network/vpn-bindings/vpn-binding', uri) + } + + @Test + public void testGetNetworkPolicyUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn('/aai/v8/network/network-policies/network-policy') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkPolicyUri(mockExecution) + assertEquals('/aai/v8/network/network-policies/network-policy', uri) + } + + @Test + public void testGetNetworkTableReferencesUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_route_table_reference_uri")).thenReturn('/aai/v8/network/route-table-references/route-table-reference') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkTableReferencesUri(mockExecution) + assertEquals('/aai/v8/network/route-table-references/route-table-reference', uri) + } + + @Test + public void testGetNetworkVceUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vce_uri")).thenReturn('/aai/v8/network/vces/vce') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkVceUri(mockExecution) + assertEquals('/aai/v8/network/vces/vce', uri) + } + + @Test + public void testGetNetworkL3NetworkUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) + assertEquals('/aai/v8/network/l3-networks/l3-network', uri) + } + + @Test + public void testGetBusinessCustomerUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_customer_uri")).thenReturn('/aai/v8/business/customers/customer') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getBusinessCustomerUri(mockExecution) + assertEquals('/aai/v8/business/customers/customer', uri) + } + + @Test + public void testGetCloudInfrastructureCloudRegionEndpoint() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(mockExecution) + assertEquals('http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) + } + + @Test + public void testGetCloudInfrastructureCloudRegionUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getCloudInfrastructureCloudRegionUri(mockExecution) + assertEquals('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) + } + + @Test + public void testGetCloudInfrastructureTenantUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_tenant_uri")).thenReturn('/aai/v8/cloud-infrastructure/tenants/tenant') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getCloudInfrastructureTenantUri(mockExecution) + assertEquals('/aai/v8/cloud-infrastructure/tenants/tenant', uri) + } + + @Test + public void testGetSearchNodesQueryUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getSearchNodesQueryUri(mockExecution) + assertEquals('/aai/v8/search/nodes-query', uri) + } + + @Test + public void testGetSearchNodesQueryEndpoint() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getSearchNodesQueryEndpoint(mockExecution) + assertEquals('http://localhost:28090/aai/v8/search/nodes-query', uri) + } + + @Test + public void testGetSearchGenericQueryUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_query_uri")).thenReturn('/aai/v8/search/generic-query') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getSearchGenericQueryUri(mockExecution) + assertEquals('/aai/v8/search/generic-query', uri) + } + + @Test + public void testGetNamespaceFromUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('6') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v6_l3_network_uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class + def ns = aaiUtil.getNamespaceFromUri('/aai/v6/search/generic-query') + assertEquals('http://org.openecomp.aai.inventory/v6', ns) + } + + @Test + public void testGetNamespaceFromUri2() { + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('10') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v10_l3_network_uri")).thenReturn('/aai/v10/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class + def ns = aaiUtil.getNamespaceFromUri('/aai/v10/search/generic-query') + assertEquals('http://org.openecomp.aai.inventory/v10', ns) + } + + @Test + public void testGetNamespaceFromUri3() { + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('100') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v100_l3_network_uri")).thenReturn('/aai/v100/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class + def ns = aaiUtil.getNamespaceFromUri('/aai/v100/search/generic-query') + assertEquals('http://org.openecomp.aai.inventory/v100', ns) + } + + @Test + public void testGetNamespaceFromUri_twoArguments() { // (execution, uri) + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('10') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v10_l3_network_uri")).thenReturn('/aai/v10/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def ns = aaiUtil.getNamespaceFromUri(mockExecution,'/aai/v10/search/generic-query') + assertEquals('http://org.openecomp.aai.inventory/v10', ns) + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java index f1a2d7b4e2..e2942c9db5 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java @@ -1,136 +1,136 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common; - -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Assert; -import org.junit.Test; -import org.openecomp.mso.bpmn.mock.FileUtil; - -/** - * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn. - */ -public class CreateAAIVfModuleVolumeGroupTest extends WorkflowTest { - - /** - * Test the happy path through the flow. - */ - @Test - @Deployment(resources = { - "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" - }) - public void happyPath() throws IOException { - - logStart(); - - String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); - MockGetGenericVnfByIdWithPriority("skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2); - MockPutVfModuleIdNoResponse("skask", "PCRF", "lukewarm"); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap(); - variables.put("mso-request-id", "999-99-9999"); - variables.put("isDebugLogEnabled","true"); - variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); - invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); - - Assert.assertTrue(isProcessEnded(businessKey)); - String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); - Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); - System.out.println("Subflow response code: " + responseCode); - System.out.println("Subflow response: " + response); - Assert.assertEquals(200, responseCode.intValue()); - - logEnd(); - } - - /** - * Test the case where the GET to AAI returns a 404. - */ - @Test - @Deployment(resources = { - "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" - }) - public void badGet() throws IOException { - - logStart(); - - String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); - MockGetVfModuleId("skask", ".*", "VfModularity/VfModule-supercool.xml", 404); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap(); - variables.put("mso-request-id", "999-99-9999"); - variables.put("isDebugLogEnabled","true"); - variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); - invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); - - Assert.assertTrue(isProcessEnded(businessKey)); - String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse"); - Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode"); - System.out.println("Subflow response code: " + responseCode); - System.out.println("Subflow response: " + response); - Assert.assertEquals(404, responseCode.intValue()); - - logEnd(); - } - - /** - * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404. - */ - @Test - @Deployment(resources = { - "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" - }) - public void badPut() throws IOException { - - logStart(); - - String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); - MockGetVfModuleId("skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap(); - variables.put("mso-request-id", "999-99-9999"); - variables.put("isDebugLogEnabled","true"); - variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); - invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); - - Assert.assertTrue(isProcessEnded(businessKey)); - String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); - Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); - System.out.println("Subflow response code: " + responseCode); - System.out.println("Subflow response: " + response); - Assert.assertEquals(404, responseCode.intValue()); - - logEnd(); - } -} - +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn. + */ +public class CreateAAIVfModuleVolumeGroupTest extends WorkflowTest { + + /** + * Test the happy path through the flow. + */ + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" + }) + public void happyPath() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); + MockGetGenericVnfByIdWithPriority("skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2); + MockPutVfModuleIdNoResponse("skask", "PCRF", "lukewarm"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); + invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(200, responseCode.intValue()); + + logEnd(); + } + + /** + * Test the case where the GET to AAI returns a 404. + */ + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" + }) + public void badGet() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); + MockGetVfModuleId("skask", ".*", "VfModularity/VfModule-supercool.xml", 404); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); + invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + + logEnd(); + } + + /** + * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404. + */ + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" + }) + public void badPatch() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); + MockGetVfModuleId("skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); + invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + + logEnd(); + } +} + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java index 2af42db574..b73ad7ab1c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java @@ -1,505 +1,505 @@ -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceSubscription; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_500; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_500; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; - - -/** - * Unit Test for the GenericGetService Sub Flow - */ -public class GenericGetServiceTest extends WorkflowTest { - - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstance() throws Exception{ - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals(null, workflowException); - } - - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceSubscription() throws Exception{ - - MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml"); - - Map variables = new HashMap(); - setVariablesSubscription(variables, "", null , "1604-MVM-26", "SDN-ETHERNET-INTERNET"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstance_byName() throws Exception{ - - MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByName.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - - Map variables = new HashMap(); - setVariablesInstance(variables, null, "1604-MVM-26", null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertNotNull(response); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstance_byId() throws Exception{ - - MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstance_404Response() throws Exception{ - - MockGetServiceInstance_404("SDN-ETHERNET-INTERNET", "123456789", "MIS%2F1604%2F0026%2FSW_INTERNET"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceSubscription404() throws Exception{ - MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", 404); - - Map variables = new HashMap(); - setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", "1604-MVM-26"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstanceByName404() throws Exception{ - - MockNodeQueryServiceInstanceByName_404("1604-MVM-26"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "", "1604-MVM-26", null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertEquals("404", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstanceById404() throws Exception{ - - MockNodeQueryServiceInstanceById_404("MIS%2F1604%2F0026%2FSW_INTERNET"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertEquals("404", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstanceEmptyResponse() throws Exception{ - - MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", " "); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstanceByNameEmpty() throws Exception{ - MockNodeQueryServiceInstanceByName("1604-MVM-26", ""); - - Map variables = new HashMap(); - setVariablesInstance(variables, "", "1604-MVM-26", null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstanceByIdEmpty() throws Exception{ - - MockNodeQueryServiceInstanceById("MIS[%]2F1604[%]2F0026[%]2FSW_INTERNET", ""); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_error_serviceInstanceInvalidVariables() throws Exception{ - - Map variables = new HashMap(); - setVariablesInstance(variables, null, null, "SDN-ETHERNET-INTERNET", null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceSubscriptionInvalidVariables() throws Exception{ - - Map variables = new HashMap(); - setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.]"; - - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_error_serviceInstance_getSIBadResponse() throws Exception{ - - MockGetServiceInstance_500("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "123456789"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_error_serviceInstance_getUrlByIdBadResponse() throws Exception{ - - MockNodeQueryServiceInstanceById_500("MIS%2F1604%2F0026%2FSW_INTERNET"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertEquals("500", siUrlResponseCode); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_error_serviceInstance_getUrlByNameBadResponse() throws Exception{ - - MockNodeQueryServiceInstanceByName_500("1604-MVM-26"); - - Map variables = new HashMap(); - setVariablesInstance(variables, null, "1604-MVM-26", null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertEquals("500", siUrlResponseCode); - assertEquals(expectedWorkflowException, workflowException); - } - - - private void setVariablesInstance(Map variables, String siId, String siName, String globalCustId, String serviceType) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENGS_serviceInstanceId", siId); - variables.put("GENGS_serviceInstanceName", siName); - variables.put("GENGS_globalCustomerId",globalCustId); - variables.put("GENGS_serviceType", serviceType); - variables.put("GENGS_type", "service-instance"); - } - - private void setVariablesSubscription(Map variables, String siId, String siName, String globalCustId, String serviceType) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENGS_serviceInstanceId", siId); - variables.put("GENGS_serviceInstanceName", siName); - variables.put("GENGS_globalCustomerId",globalCustId); - variables.put("GENGS_serviceType", serviceType); - variables.put("GENGS_type", "service-subscription"); - } - - -} +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceSubscription; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_500; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_500; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + + +/** + * Unit Test for the GenericGetService Sub Flow + */ +public class GenericGetServiceTest extends WorkflowTest { + + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstance() throws Exception{ + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals(null, workflowException); + } + + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceSubscription() throws Exception{ + + MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml"); + + Map variables = new HashMap(); + setVariablesSubscription(variables, "", null , "1604-MVM-26", "SDN-ETHERNET-INTERNET"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstance_byName() throws Exception{ + + MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByName.xml"); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + + Map variables = new HashMap(); + setVariablesInstance(variables, null, "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertNotNull(response); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstance_byId() throws Exception{ + + MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstance_404Response() throws Exception{ + + MockGetServiceInstance_404("SDN-ETHERNET-INTERNET", "123456789", "MIS%2F1604%2F0026%2FSW_INTERNET"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceSubscription404() throws Exception{ + MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", 404); + + Map variables = new HashMap(); + setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", "1604-MVM-26"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceByName404() throws Exception{ + + MockNodeQueryServiceInstanceByName_404("1604-MVM-26"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "", "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertEquals("404", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceById404() throws Exception{ + + MockNodeQueryServiceInstanceById_404("MIS%2F1604%2F0026%2FSW_INTERNET"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertEquals("404", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceEmptyResponse() throws Exception{ + + MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", " "); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceByNameEmpty() throws Exception{ + MockNodeQueryServiceInstanceByName("1604-MVM-26", ""); + + Map variables = new HashMap(); + setVariablesInstance(variables, "", "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceByIdEmpty() throws Exception{ + + MockNodeQueryServiceInstanceById("MIS[%]2F1604[%]2F0026[%]2FSW_INTERNET", ""); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstanceInvalidVariables() throws Exception{ + + Map variables = new HashMap(); + setVariablesInstance(variables, null, null, "SDN-ETHERNET-INTERNET", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceSubscriptionInvalidVariables() throws Exception{ + + Map variables = new HashMap(); + setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.]"; + + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstance_getSIBadResponse() throws Exception{ + + MockGetServiceInstance_500("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "123456789"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstance_getUrlByIdBadResponse() throws Exception{ + + MockNodeQueryServiceInstanceById_500("MIS%2F1604%2F0026%2FSW_INTERNET"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertEquals("500", siUrlResponseCode); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstance_getUrlByNameBadResponse() throws Exception{ + + MockNodeQueryServiceInstanceByName_500("1604-MVM-26"); + + Map variables = new HashMap(); + setVariablesInstance(variables, null, "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertEquals("500", siUrlResponseCode); + assertEquals(expectedWorkflowException, workflowException); + } + + + private void setVariablesInstance(Map variables, String siId, String siName, String globalCustId, String serviceType) { + variables.put("isDebugLogEnabled", "true"); + variables.put("GENGS_serviceInstanceId", siId); + variables.put("GENGS_serviceInstanceName", siName); + variables.put("GENGS_globalCustomerId",globalCustId); + variables.put("GENGS_serviceType", serviceType); + variables.put("GENGS_type", "service-instance"); + } + + private void setVariablesSubscription(Map variables, String siId, String siName, String globalCustId, String serviceType) { + variables.put("isDebugLogEnabled", "true"); + variables.put("GENGS_serviceInstanceId", siId); + variables.put("GENGS_serviceInstanceName", siName); + variables.put("GENGS_globalCustomerId",globalCustId); + variables.put("GENGS_serviceType", serviceType); + variables.put("GENGS_type", "service-subscription"); + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java index 6fe6df6e11..e2babb7919 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java @@ -20,10 +20,11 @@ package org.openecomp.mso.bpmn.common; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import java.io.IOException; import java.util.HashMap; @@ -179,14 +180,15 @@ public class PrepareUpdateAAIVfModuleTest extends WorkflowTest { @Deployment(resources = { "subprocess/PrepareUpdateAAIVfModule.bpmn" }) - public void badPut() throws IOException { + public void badPatch() throws IOException { logStart(); String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml"); MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); - + MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404); + String businessKey = UUID.randomUUID().toString(); Map variables = new HashMap(); variables.put("mso-request-id", "999-99-9999"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java index 846a14f45f..3eb7acd91a 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java @@ -33,7 +33,6 @@ import java.util.Map; import javax.ws.rs.core.Response; -import org.camunda.bpm.engine.MismatchingMessageCorrelationException; import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.camunda.bpm.engine.runtime.Job; import org.camunda.bpm.engine.test.Deployment; @@ -44,9 +43,10 @@ import org.openecomp.mso.bpmn.common.adapter.sdnc.CallbackHeader; import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest; import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterResponse; import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl; -import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl.SDNCAdapterExceptionResponse; +import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl.SDNCAdapterErrorResponse; import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource; import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.core.PropertyConfigurationSetup; import org.openecomp.mso.bpmn.mock.FileUtil; /** @@ -129,7 +129,7 @@ public class SDNCAdapterV1Test extends WorkflowTest { SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); //System.out.println("Back from executing process again"); - assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse); assertProcessInstanceFinished(pid); //System.out.println("SDNCAdapter sunny day flow Completed!"); @@ -167,7 +167,7 @@ public class SDNCAdapterV1Test extends WorkflowTest { SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); //System.out.println("Back from executing process again"); - assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse); assertProcessInstanceNotFinished(pid); checkForTimeout(pid); @@ -212,7 +212,7 @@ public class SDNCAdapterV1Test extends WorkflowTest { SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); //System.out.println("Back from executing process again"); - assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse); assertProcessInstanceNotFinished(pid); assertEquals(true, (Boolean) (getVariable(pid, "continueListening"))); @@ -221,7 +221,7 @@ public class SDNCAdapterV1Test extends WorkflowTest { sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); //System.out.println("Back from executing process again"); - assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse); assertProcessInstanceFinished(pid); assertEquals(false, (Boolean) (getVariable(pid, "continueListening"))); @@ -241,10 +241,14 @@ public class SDNCAdapterV1Test extends WorkflowTest { @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn", "subprocess/GenericNotificationService.bpmn" }) - public void badCorrelationIdTest() throws InterruptedException { + public void badCorrelationIdTest() throws InterruptedException, IOException { mockSDNCAdapter(200); + Map urnProperties = PropertyConfigurationSetup.createBpmnUrnProperties(); + urnProperties.put("mso.correlation.timeout", "5"); + PropertyConfigurationSetup.addProperties(urnProperties, 10000); + //System.out.println("SDNCAdapter bad RequestId test Started!"); ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest); @@ -267,8 +271,8 @@ public class SDNCAdapterV1Test extends WorkflowTest { SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); //System.out.println("Back from executing process again"); - assertTrue(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); - assertTrue(((SDNCAdapterExceptionResponse) sdncAdapterResponse).getException() instanceof IllegalStateException); + assertTrue(sdncAdapterResponse instanceof SDNCAdapterErrorResponse); + assertTrue(((SDNCAdapterErrorResponse) sdncAdapterResponse).getError().contains("No process is waiting for sdncAdapterCallbackRequest")); assertProcessInstanceNotFinished(pid); //System.out.println("SDNCAdapter bad RequestId test Completed!"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java index 18fb5acbce..1573c8f757 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java @@ -20,11 +20,12 @@ package org.openecomp.mso.bpmn.common; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf_Bad; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; import java.io.IOException; import java.util.HashMap; @@ -144,7 +145,7 @@ public class UpdateAAIGenericVnfTest extends WorkflowTest { @Deployment(resources = { "subprocess/UpdateAAIGenericVnf.bpmn" }) - public void badPut() throws IOException { + public void badPatch() throws IOException { logStart(); @@ -152,6 +153,7 @@ public class UpdateAAIGenericVnfTest extends WorkflowTest { MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); MockPutGenericVnf_Bad("skask", 404); + MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask", 404); String businessKey = UUID.randomUUID().toString(); Map variables = new HashMap(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java index 035f097be2..d081fcc7f6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java @@ -20,11 +20,12 @@ package org.openecomp.mso.bpmn.common; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import java.io.IOException; import java.util.HashMap; @@ -111,13 +112,14 @@ public class UpdateAAIVfModuleTest extends WorkflowTest { @Deployment(resources = { "subprocess/UpdateAAIVfModule.bpmn" }) - public void badPut() throws IOException { + public void badPatch() throws IOException { logStart(); String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml"); MockGetGenericVnfById_404("/skask/vf-modules/vf-module/supercool"); MockGetGenericVnfById("/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200); + MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404); String businessKey = UUID.randomUUID().toString(); Map variables = new HashMap(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java index 46bbb72e56..49ad6d6e34 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java @@ -109,6 +109,16 @@ public class WorkflowTest { @Rule public final WireMockRule wireMockRule; + /** + * Content-Type for XML. + */ + protected static final String XML = "application/xml"; + + /** + * Content-Type for JSON. + */ + protected static final String JSON = "application/json; charset=UTF-8"; + /** * Constructor. */ @@ -197,15 +207,15 @@ public class WorkflowTest { * @param businessKey a unique key that will identify the process instance * @param injectedVariables variables to inject into the process */ - protected void invokeSubProcess(String processKey, String businessKey, - Map injectedVariables) { + protected void invokeSubProcess(String processKey, String businessKey, Map injectedVariables) { RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); List arguments = runtimeMxBean.getInputArguments(); System.out.println("JVM args = " + arguments); msoRequestId = (String) injectedVariables.get("mso-request-id"); + String requestId = (String) injectedVariables.get("msoRequestId"); - if (msoRequestId == null) { + if (msoRequestId == null && requestId == null) { String msg = "mso-request-id variable was not provided"; System.out.println(msg); fail(msg); @@ -242,7 +252,7 @@ public class WorkflowTest { * @param injectedVariables optional variables to inject into the process * @return a TestAsyncResponse object associated with the test */ - public TestAsyncResponse invokeAsyncProcess(String processKey, + protected TestAsyncResponse invokeAsyncProcess(String processKey, String schemaVersion, String businessKey, String request, Map injectedVariables) { @@ -438,7 +448,7 @@ public class WorkflowTest { * @param timeout the timeout in milliseconds * @return the WorkflowResponse */ - public WorkflowResponse receiveResponse(String businessKey, + protected WorkflowResponse receiveResponse(String businessKey, TestAsyncResponse asyncResponse, long timeout) { System.out.println("Waiting " + timeout + "ms for process with business key " + businessKey + " to send a response"); @@ -512,24 +522,34 @@ public class WorkflowTest { } String content = null; + String contentType = null; if ("STD".equals(modifier)) { - content = callbacks.get(action); + CallbackData callbackData = callbacks.get(action); - if (content == null) { + if (callbackData == null) { String msg = "No callback defined for '" + action + "' SDNC request"; System.out.println(msg); fail(msg); } + + content = callbackData.getContent(); + contentType = callbackData.getContentType(); } else if ("ERR".equals(modifier)) { content = "{\"SDNCServiceError\":{\"sdncRequestId\":\"((REQUEST-ID))\",\"responseCode\":\"500\",\"responseMessage\":\"SIMULATED ERROR FROM SDNC ADAPTER\",\"ackFinalIndicator\":\"Y\"}}"; + contentType = JSON; } else { String msg = "Invalid SDNC program modifier: '" + modifier + "'"; System.out.println(msg); fail(msg); } - if (!injectSDNCRestCallback(content, 10000)) { + if (contentType == null) { + // Default for backward compatibility with existing tests. + contentType = JSON; + } + + if (!injectSDNCRestCallback(contentType, content, 10000)) { fail("Failed to inject SDNC '" + action + "' callback"); } @@ -548,67 +568,14 @@ public class WorkflowTest { *
 	 *     event1, event2
 	 * 
+ * NOTE: Each callback must have a message type associated with it, e.g. + * "SDNCAEvent". * Errors are handled with junit assertions and will cause the test to fail. - * Defaults the Event Type to "SDNCAEvent" for backward compatibility. * @param callbacks an object containing event data for the program * @param program the program to execute */ protected void injectSDNCEvents(CallbackSet callbacks, String program) { - injectSDNCEvents(callbacks, program, "SDNCAEvent"); - } - - /** - * Runs a program to inject SDNC events into the test environment. - * A program is essentially just a list of keys that identify event data - * to be injected, in sequence. An example program: - *
-	 *     event1, event2
-	 * 
- * Errors are handled with junit assertions and will cause the test to fail. - * @param callbacks an object containing event data for the program - * @param program the program to execute - * @param eventType (i.e. "SDNCAEvent", "SNIROResponse", etc.) - */ - protected void injectSDNCEvents(CallbackSet callbacks, String program, String eventType) { - - String[] cmds = program.replaceAll("\\s+", "").split(","); - - for (String cmd : cmds) { - String action = cmd; - String modifier = "STD"; - - if (cmd.contains(":")) { - String[] parts = cmd.split(":"); - action = parts[0]; - modifier = parts[1]; - } - - String content = null; - - if ("STD".equals(modifier)) { - content = callbacks.get(action); - - if (content == null) { - String msg = "No SDNC event callback defined for '" + action + "'"; - System.out.println(msg); - fail(msg); - } - } else { - String msg = "Invalid SDNC program modifier: '" + modifier + "'"; - System.out.println(msg); - fail(msg); - } - - if (!injectWorkflowMessage(eventType, content, 10000)) { - fail("Failed to inject SDNC '" + action + "' event"); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - fail("Interrupted after injection of SDNC '" + action + "' event"); - } - } + injectWorkflowMessages(callbacks, program); } /** @@ -622,7 +589,7 @@ public class WorkflowTest { * @param callbacks an object containing callback data for the program * @param program the program to execute */ - public void injectSDNCCallbacks(CallbackSet callbacks, String program) { + protected void injectSDNCCallbacks(CallbackSet callbacks, String program) { String[] cmds = program.replaceAll("\\s+", "").split(","); @@ -641,14 +608,15 @@ public class WorkflowTest { String respMsg = "OK"; if ("STD".equals(modifier)) { - content = callbacks.get(action); + CallbackData callbackData = callbacks.get(action); - if (content == null) { + if (callbackData == null) { String msg = "No callback defined for '" + action + "' SDNC request"; System.out.println(msg); fail(msg); } + content = callbackData.getContent(); respCode = 200; respMsg = "OK"; } else if ("ERR".equals(modifier)) { @@ -684,7 +652,7 @@ public class WorkflowTest { * @param callbacks an object containing callback data for the program * @param program the program to execute */ - public void injectVNFRestCallbacks(CallbackSet callbacks, String program) { + protected void injectVNFRestCallbacks(CallbackSet callbacks, String program) { String[] cmds = program.replaceAll("\\s+", "").split(","); @@ -699,24 +667,34 @@ public class WorkflowTest { } String content = null; + String contentType = null; if ("STD".equals(modifier)) { - content = callbacks.get(action); + CallbackData callbackData = callbacks.get(action); - if (content == null) { + if (callbackData == null) { String msg = "No callback defined for '" + action + "' VNF REST request"; System.out.println(msg); fail(msg); } + + content = callbackData.getContent(); + contentType = callbackData.getContentType(); } else if ("ERR".equals(modifier)) { content = "SIMULATED ERROR FROM VNF ADAPTER"; + contentType = "text/plain"; } else { String msg = "Invalid VNF REST program modifier: '" + modifier + "'"; System.out.println(msg); fail(msg); } - if (!injectVnfAdapterRestCallback(content, 10000)) { + if (contentType == null) { + // Default for backward compatibility with existing tests. + contentType = XML; + } + + if (!injectVnfAdapterRestCallback(contentType, content, 10000)) { fail("Failed to inject VNF REST '" + action + "' callback"); } @@ -756,14 +734,15 @@ public class WorkflowTest { String content = null; if ("STD".equals(modifier)) { - content = callbacks.get(action); + CallbackData callbackData = callbacks.get(action); - if (content == null) { + if (callbackData == null) { String msg = "No callback defined for '" + action + "' VNF request"; System.out.println(msg); fail(msg); } + content = callbackData.getContent(); } else if ("ERR".equals(modifier)) { String msg = "Currently unsupported VNF program modifier: '" + modifier + "'"; System.out.println(msg); @@ -805,7 +784,7 @@ public class WorkflowTest { * @param count the desired count * @param timeout the timeout in milliseconds */ - public void waitForRunningProcessCount(String processKey, int count, long timeout) { + protected void waitForRunningProcessCount(String processKey, int count, long timeout) { System.out.println("Waiting " + timeout + "ms for there to be " + count + " " + processKey + " instances"); @@ -916,11 +895,12 @@ public class WorkflowTest { * may contain the placeholder string ((REQUEST-ID)) which is replaced with * the actual SDNC request ID. Note: this is not the requestId in the original * MSO request. + * @param contentType the HTTP content type for the callback * @param content the content of the callback * @param timeout the timeout in milliseconds * @return true if the callback could be injected, false otherwise */ - protected boolean injectSDNCRestCallback(String content, long timeout) { + protected boolean injectSDNCRestCallback(String contentType, String content, long timeout) { String sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV1", "SDNCAResponse_CORRELATOR", timeout); @@ -935,7 +915,7 @@ public class WorkflowTest { System.out.println("Injecting SDNC adapter callback"); WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource(); workflowMessageResource.setProcessEngineServices4junit(processEngineRule); - Response response = workflowMessageResource.deliver("SDNCAResponse", sdncRequestId, content); + Response response = workflowMessageResource.deliver(contentType, "SDNCAResponse", sdncRequestId, content); System.out.println("Workflow response to SDNC adapter callback: " + response); return true; } @@ -986,11 +966,12 @@ public class WorkflowTest { * may contain the placeholder string ((MESSAGE-ID)) which is replaced with * the actual message ID. Note: this is not the requestId in the original * MSO request. + * @param contentType the HTTP content type for the callback * @param content the content of the callback * @param timeout the timeout in milliseconds * @return true if the callback could be injected, false otherwise */ - protected boolean injectVnfAdapterRestCallback(String content, long timeout) { + protected boolean injectVnfAdapterRestCallback(String contentType, String content, long timeout) { String messageId = (String) getProcessVariable("vnfAdapterRestV1", "VNFAResponse_CORRELATOR", timeout); @@ -1005,7 +986,7 @@ public class WorkflowTest { System.out.println("Injecting VNF adapter callback"); WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource(); workflowMessageResource.setProcessEngineServices4junit(processEngineRule); - Response response = workflowMessageResource.deliver("VNFAResponse", messageId, content); + Response response = workflowMessageResource.deliver(contentType, "VNFAResponse", messageId, content); System.out.println("Workflow response to VNF adapter callback: " + response); return true; } @@ -1307,16 +1288,84 @@ public class WorkflowTest { return true; } + /** + * Runs a program to inject workflow messages into the test environment. + * A program is essentially just a list of keys that identify event data + * to be injected, in sequence. An example program: + *
+	 *     event1, event2
+	 * 
+ * Errors are handled with junit assertions and will cause the test to fail. + * NOTE: Each callback must have a workflow message type associated with it. + * @param callbacks an object containing event data for the program + * @param program the program to execute + */ + protected void injectWorkflowMessages(CallbackSet callbacks, String program) { + + String[] cmds = program.replaceAll("\\s+", "").split(","); + + for (String cmd : cmds) { + String action = cmd; + String modifier = "STD"; + + if (cmd.contains(":")) { + String[] parts = cmd.split(":"); + action = parts[0]; + modifier = parts[1]; + } + + String messageType = null; + String content = null; + String contentType = null; + + if ("STD".equals(modifier)) { + CallbackData callbackData = callbacks.get(action); + + if (callbackData == null) { + String msg = "No '" + action + "' workflow message callback is defined"; + System.out.println(msg); + fail(msg); + } + + messageType = callbackData.getMessageType(); + + if (messageType == null || messageType.trim().equals("")) { + String msg = "No workflow message type is defined in the '" + action + "' callback"; + System.out.println(msg); + fail(msg); + } + + content = callbackData.getContent(); + contentType = callbackData.getContentType(); + } else { + String msg = "Invalid workflow message program modifier: '" + modifier + "'"; + System.out.println(msg); + fail(msg); + } + + if (!injectWorkflowMessage(contentType, messageType, content, 10000)) { + fail("Failed to inject '" + action + "' workflow message"); + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + fail("Interrupted after injection of '" + action + "' workflow message"); + } + } + } + /** * Injects a workflow message. The specified callback data may contain the * placeholder string ((CORRELATOR)) which is replaced with the actual * correlator value. - * @param content the message type - * @param content the message content + * @param contentType the HTTP contentType for the message (possibly null) + * @param messageType the message type + * @param content the message content (possibly null) * @param timeout the timeout in milliseconds - * @return true if the event could be injected, false otherwise + * @return true if the message could be injected, false otherwise */ - protected boolean injectWorkflowMessage(String messageType, String content, long timeout) { + protected boolean injectWorkflowMessage(String contentType, String messageType, String content, long timeout) { String correlator = (String) getProcessVariable("ReceiveWorkflowMessage", messageType + "_CORRELATOR", timeout); @@ -1324,12 +1373,14 @@ public class WorkflowTest { return false; } - content = content.replace("((CORRELATOR))", correlator); + if (content != null) { + content = content.replace("((CORRELATOR))", correlator); + } System.out.println("Injecting " + messageType + " message"); WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource(); workflowMessageResource.setProcessEngineServices4junit(processEngineRule); - Response response = workflowMessageResource.deliver(messageType, correlator, content); + Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content); System.out.println("Workflow response to " + messageType + " message: " + response); return true; } @@ -1339,7 +1390,7 @@ public class WorkflowTest { * @param businessKey the process business key * @param timeout the amount of time to wait, in milliseconds */ - public void waitForProcessEnd(String businessKey, long timeout) { + protected void waitForProcessEnd(String businessKey, long timeout) { System.out.println("Waiting " + timeout + "ms for process with business key " + businessKey + " to end"); @@ -1377,7 +1428,7 @@ public class WorkflowTest { * @param variable the variable name * @param value the expected variable value */ - public void checkVariable(String businessKey, String variable, Object value) { + protected void checkVariable(String businessKey, String variable, Object value) { if (!isProcessEnded(businessKey)) { fail("Cannot get historic variable " + variable + " because process with business key " + businessKey + " has not ended"); @@ -1405,7 +1456,7 @@ public class WorkflowTest { * @return the variable value, or null if the variable could not be * obtained */ - public Object getVariableFromHistory(String businessKey, String variableName) { + protected Object getVariableFromHistory(String businessKey, String variableName) { try { HistoricProcessInstance processInstance = processEngineRule.getHistoryService() .createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).singleResult(); @@ -1426,6 +1477,8 @@ public class WorkflowTest { } /** + * @author cb645j + * * Gets the value of a subflow variable from the specified subflow's * historical process instance. * @@ -1440,6 +1493,10 @@ public class WorkflowTest { List processInstanceList = processEngineRule.getHistoryService() .createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list(); + if (processInstanceList == null) { + return null; + } + Collections.sort(processInstanceList, new Comparator() { public int compare(HistoricProcessInstance m1, HistoricProcessInstance m2) { return m1.getStartTime().compareTo(m2.getStartTime()); @@ -1448,10 +1505,6 @@ public class WorkflowTest { HistoricProcessInstance processInstance = processInstanceList.get(0); - if (processInstanceList == null) { - return null; - } - HistoricVariableInstance v = processEngineRule.getHistoryService() .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()) .variableName(variableName).singleResult(); @@ -1464,6 +1517,8 @@ public class WorkflowTest { } /** + * @author cb645j + * * Gets the value of a subflow variable from the subflow's * historical process x instance. * @@ -1478,6 +1533,10 @@ public class WorkflowTest { List processInstanceList = processEngineRule.getHistoryService() .createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list(); + if (processInstanceList == null) { + return null; + } + Collections.sort(processInstanceList, new Comparator() { public int compare(HistoricProcessInstance m1, HistoricProcessInstance m2) { return m1.getStartTime().compareTo(m2.getStartTime()); @@ -1486,10 +1545,6 @@ public class WorkflowTest { HistoricProcessInstance processInstance = processInstanceList.get(subflowInstanceIndex); - if (processInstanceList == null) { - return null; - } - HistoricVariableInstance v = processEngineRule.getHistoryService() .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()) .variableName(variableName).singleResult(); @@ -1594,15 +1649,36 @@ public class WorkflowTest { * An object that contains callback data for a "program". */ public class CallbackSet { - private final Map map = new HashMap(); + private final Map map = new HashMap(); /** - * Add callback data to the set. + * Add untyped callback data to the set. * @param action the action with which the data is associated * @param content the callback data */ public void put(String action, String content) { - map.put(action, content); + map.put(action, new CallbackData(null, null, content)); + } + + /** + * Add callback data to the set. + * @param action the action with which the data is associated + * @param messageType the callback message type + * @param content the callback data + */ + public void put(String action, String messageType, String content) { + map.put(action, new CallbackData(null, messageType, content)); + } + + /** + * Add callback data to the set. + * @param action the action with which the data is associated + * @param contentType the callback HTTP content type + * @param messageType the callback message type + * @param content the callback data + */ + public void put(String action, String contentType, String messageType, String content) { + map.put(action, new CallbackData(contentType, messageType, content)); } /** @@ -1610,11 +1686,53 @@ public class WorkflowTest { * @param action the action with which the data is associated * @return the callback data, or null if there is none for the specified operation */ - public String get(String action) { + public CallbackData get(String action) { return map.get(action); } } + /** + * Represents a callback data item. + */ + public class CallbackData { + private final String contentType; + private final String messageType; + private final String content; + + /** + * Constructor + * @param contentType the HTTP content type (optional) + * @param type the callback message type (optional) + * @param content the content + */ + public CallbackData(String contentType, String messageType, String content) { + this.contentType = contentType; + this.messageType = messageType; + this.content = content; + } + + /** + * Gets the callback HTTP content type, possibly null. + */ + public String getContentType() { + return contentType; + } + + /** + * Gets the callback message type, possibly null. + */ + public String getMessageType() { + return messageType; + } + + /** + * Gets the callback content. + */ + public String getContent() { + return content; + } + } + /** * A tool for evaluating XPath expressions. */ @@ -1772,7 +1890,7 @@ public class WorkflowTest { * Helper class to make it easier to create this type. */ private static class CreateVnfNotificationOutputs - extends org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs { + extends CreateVnfNotification.Outputs { public void add(String key, String value) { Entry entry = new Entry(); entry.setKey(key); @@ -1785,7 +1903,7 @@ public class WorkflowTest { * Helper class to make it easier to create this type. */ private static class UpdateVnfNotificationOutputs - extends org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs { + extends UpdateVnfNotification.Outputs { public void add(String key, String value) { Entry entry = new Entry(); entry.setKey(key); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql index 10e9930720..6ebc6e221e 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql @@ -1,76 +1,75 @@ --- Fix for https://itrack.web.att.com/browse/AJSCCMDA-90 -- -use camundabpmn; -/* -Drop a archive tables -*/ -/*-- TMP_ARCHIVING_PROCINST */ -DROP TABLE IF EXISTS TMP_ARCHIVING_PROCINST; - -/*-- TMP_ARCHIVING_BYTEARRAY */ -DROP TABLE IF EXISTS TMP_ARCHIVING_BYTEARRAY; - -/*-- TMP LOG TABLE */ -DROP TABLE IF EXISTS TMPLOGTABLE; - -/* -- Camunda Hi Tables --*/ -DROP TABLE IF EXISTS Camunda_Hi_Tables; - -/* drop own extentions columns: -alter table ARCHIVE_ACT_HI_PROCINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_ACTINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_TASKINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_VARINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_DETAIL DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_COMMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_ATTACHMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_OP_LOG DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_INCIDENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -*/ - -/*--#1 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_PROCINST; -/*--#2 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_ACTINST; -/*--#3 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_TASKINST; -/*--#4 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_VARINST; -/*--#5 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_DETAIL; -/*--#6 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_COMMENT; -/*--#7 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_ATTACHMENT; -/*--#8 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_OP_LOG; -/*--#9 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_INCIDENT; -/*--#10 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_GE_BYTEARRAY; - -/* drop PL SQL procedures: */ -DROP PROCEDURE IF EXISTS ARCHIVE_CAMUNDA_HISTORY; -DROP PROCEDURE IF EXISTS ROLLB_ARCHIVE_CAMUNDA_HISTORY; - -/*-- Sequence */ --- as sequence drop doesn't work automatically in MariaDB, use this procedure to drop sequence - DROP PROCEDURE IF EXISTS DropSequence; - - DELIMITER // - - CREATE PROCEDURE DropSequence (vname VARCHAR(30)) - BEGIN - -- Drop the sequence - DELETE FROM _sequences WHERE name = vname; - END - // - DELIMITER ; - --- use the above procedure to drop sequence -CALL DropSequence('STAT_EXECUTION_SEQ'); - -/*-- To Drop the MariaDB specific user defined procedures and functions */ -DROP FUNCTION IF EXISTS NextVal; -DROP PROCEDURE IF EXISTS CreateSequence; -DROP PROCEDURE IF EXISTS DropSequence; +use camundabpmn; +/* +Drop a archive tables +*/ +/*-- TMP_ARCHIVING_PROCINST */ +DROP TABLE IF EXISTS TMP_ARCHIVING_PROCINST; + +/*-- TMP_ARCHIVING_BYTEARRAY */ +DROP TABLE IF EXISTS TMP_ARCHIVING_BYTEARRAY; + +/*-- TMP LOG TABLE */ +DROP TABLE IF EXISTS TMPLOGTABLE; + +/* -- Camunda Hi Tables --*/ +DROP TABLE IF EXISTS Camunda_Hi_Tables; + +/* drop own extentions columns: +alter table ARCHIVE_ACT_HI_PROCINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_ACTINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_TASKINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_VARINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_DETAIL DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_COMMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_ATTACHMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_OP_LOG DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_INCIDENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +*/ + +/*--#1 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_PROCINST; +/*--#2 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_ACTINST; +/*--#3 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_TASKINST; +/*--#4 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_VARINST; +/*--#5 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_DETAIL; +/*--#6 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_COMMENT; +/*--#7 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_ATTACHMENT; +/*--#8 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_OP_LOG; +/*--#9 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_INCIDENT; +/*--#10 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_GE_BYTEARRAY; + +/* drop PL SQL procedures: */ +DROP PROCEDURE IF EXISTS ARCHIVE_CAMUNDA_HISTORY; +DROP PROCEDURE IF EXISTS ROLLB_ARCHIVE_CAMUNDA_HISTORY; + +/*-- Sequence */ +-- as sequence drop doesn't work automatically in MariaDB, use this procedure to drop sequence + DROP PROCEDURE IF EXISTS DropSequence; + + DELIMITER // + + CREATE PROCEDURE DropSequence (vname VARCHAR(30)) + BEGIN + -- Drop the sequence + DELETE FROM _sequences WHERE name = vname; + END + // + DELIMITER ; + +-- use the above procedure to drop sequence +CALL DropSequence('STAT_EXECUTION_SEQ'); + +/*-- To Drop the MariaDB specific user defined procedures and functions */ +DROP FUNCTION IF EXISTS NextVal; +DROP PROCEDURE IF EXISTS CreateSequence; +DROP PROCEDURE IF EXISTS DropSequence; DROP TABLE IF EXISTS _sequences; \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql index 8c7faa0792..c5b69c7a34 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql @@ -1,222 +1,221 @@ --- Fix for https://itrack.web.att.com/browse/AJSCCMDA-90 -- -use camundabpmn; -/* - 1. Add some Camunda Indexes to history schema part (for Archiving) -*/ -create INDEX IF NOT EXISTS IDX_ACT_HI_TASKINST_PIID ON ACT_HI_TASKINST (PROC_INST_ID_); -create INDEX IF NOT EXISTS IDX_ACT_HI_COMMENT_PIID ON ACT_HI_COMMENT (PROC_INST_ID_); -create INDEX IF NOT EXISTS IDX_ACT_HI_ATTACHMENT_PIID ON ACT_HI_ATTACHMENT (PROC_INST_ID_); -create INDEX IF NOT EXISTS IDX_ACT_HI_OP_LOG_PIID ON ACT_HI_OP_LOG (PROC_INST_ID_); -create INDEX IF NOT EXISTS IDX_ACT_HI_INCIDENT_PIID ON ACT_HI_INCIDENT (PROC_INST_ID_); -create INDEX IF NOT EXISTS IDX_ACT_HI_ACTINST_PIID ON ACT_HI_ACTINST(PROC_INST_ID_); - - -/* - 2. Create Archiving Tables in current schema -*/ - -/*-- TMP_ARCHIVING_PROCINST */ -CREATE TABLE TMP_ARCHIVING_PROCINST -( PROC_INST_ID_ varchar(64) not null, - END_TIME_ datetime(3) -); -CREATE INDEX AI_TMP_ARCH_PROCINST_PI_ID ON TMP_ARCHIVING_PROCINST(PROC_INST_ID_); - -/*-- TMP_ARCHIVING_BYTEARRAY */ -CREATE TABLE TMP_ARCHIVING_BYTEARRAY -( BYTEARRAY_ID_ varchar(64) not null, - PROC_INST_ID_ varchar(64) -); -CREATE INDEX AI_TMP_ARCH_BYTEARRAY_BAID ON TMP_ARCHIVING_BYTEARRAY(BYTEARRAY_ID_); - - -/*--#1 ARCHIVE_ACT_HI_PROCINST; */ -create TABLE ARCHIVE_ACT_HI_PROCINST -AS ( select * from ACT_HI_PROCINST where 1=0); - -create index AI_HI_PROCINST_END_TIME on ARCHIVE_ACT_HI_PROCINST(END_TIME_); -ALTER TABLE ARCHIVE_ACT_HI_PROCINST ADD CONSTRAINT ARCHIVE_ACT_HI_PROCINST_UQ UNIQUE ( PROC_INST_ID_); - -/*--#2 ARCHIVE_ACT_HI_ACTINST; */ -create TABLE ARCHIVE_ACT_HI_ACTINST -AS ( select * from ACT_HI_ACTINST where 1=0); - -create index AI_HI_ACTINST_PROC_INST_ID on ARCHIVE_ACT_HI_ACTINST(PROC_INST_ID_); -create index AI_HI_ACTINST_END_TIME on ARCHIVE_ACT_HI_ACTINST(END_TIME_); - -/*--#3 ARCHIVE_ACT_HI_TASKINST; */ -create TABLE ARCHIVE_ACT_HI_TASKINST -AS ( select * from ACT_HI_TASKINST where 1=0); - -create index AI_HI_TASKINST_PROC_INST_ID on ARCHIVE_ACT_HI_TASKINST(PROC_INST_ID_); -create index AI_HI_TASKINST_END_TIME on ARCHIVE_ACT_HI_TASKINST(END_TIME_); - -/*--#4 ARCHIVE_ACT_HI_VARINST; */ -create TABLE ARCHIVE_ACT_HI_VARINST -AS ( select * from ACT_HI_VARINST where 1=0); - -create index AI_HI_VARINST_PROC_INST_ID on ARCHIVE_ACT_HI_VARINST(PROC_INST_ID_); - -/*--#5 ARCHIVE_ACT_HI_DETAIL; */ -create TABLE ARCHIVE_ACT_HI_DETAIL -AS ( select * from ACT_HI_DETAIL where 1=0); - -create index AI_HI_DETAIL_PROC_INST_ID on ARCHIVE_ACT_HI_DETAIL(PROC_INST_ID_); -create index AI_HI_DETAIL_TIME on ARCHIVE_ACT_HI_DETAIL(TIME_); - -/*--#6 ARCHIVE_ACT_HI_COMMENT; */ -create TABLE ARCHIVE_ACT_HI_COMMENT -AS ( select * from ACT_HI_COMMENT where 1=0); - -create index AI_HI_COMMENT_PROC_INST_ID on ARCHIVE_ACT_HI_COMMENT(PROC_INST_ID_); -create index AI_HI_COMMENT_TIME on ARCHIVE_ACT_HI_COMMENT(TIME_); - -/*--#7 ARCHIVE_ACT_HI_ATTACHMENT; */ -create TABLE ARCHIVE_ACT_HI_ATTACHMENT -AS ( select * from ACT_HI_ATTACHMENT where 1=0); - -create index AI_HI_ATTACHMENT_PROC_INST_ID on ARCHIVE_ACT_HI_ATTACHMENT(PROC_INST_ID_); - -/*--#8 ARCHIVE_ACT_HI_OP_LOG; */ -create TABLE ARCHIVE_ACT_HI_OP_LOG -AS ( select * from ACT_HI_OP_LOG where 1=0); - -create index AI_HI_OP_LOG_PROC_INST_ID on ARCHIVE_ACT_HI_OP_LOG(PROC_INST_ID_); -create index AI_HI_OP_LOG_TIMESTAMP on ARCHIVE_ACT_HI_OP_LOG(TIMESTAMP_); - -/*--#9 ARCHIVE_ACT_HI_INCIDENT; */ -create TABLE ARCHIVE_ACT_HI_INCIDENT -AS ( select * from ACT_HI_INCIDENT where 1=0); - -create index AI_HI_INCIDENT_PROC_INST_ID on ARCHIVE_ACT_HI_INCIDENT(PROC_INST_ID_); - -/*--#10 ARCHIVE_ACT_GE_BYTEARRAY; */ -create TABLE ARCHIVE_ACT_GE_BYTEARRAY -AS ( select * from ACT_GE_BYTEARRAY where 1=0); - -create index AI_GE_BYTEARRAY_ID_ on ARCHIVE_ACT_GE_BYTEARRAY(ID_); - -/* ----------------------------------------------------------------------------- -Extend a ARCHIVE: Table by two attributes: STAT_EXECUTION_ID, STAT_EXECUTION_TS -*/ - -/* ---TEMPLATE: -alter table ARCHIVE_%TableName% - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_%TableName%_EXE_ID ON ARCHIVE_%TableName%(STAT_EXECUTION_ID); -*/ - - -/*--#1 ACT_HI_PROCINST */ -alter table ARCHIVE_ACT_HI_PROCINST - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_PROCINST_EXE_ID ON ARCHIVE_ACT_HI_PROCINST(STAT_EXECUTION_ID); - -/*--#2 ACT_HI_ACTINST */ -alter table ARCHIVE_ACT_HI_ACTINST - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_ACTINST_EXE_ID ON ARCHIVE_ACT_HI_ACTINST(STAT_EXECUTION_ID); - -/*--#3 ACT_HI_TASKINST */ -alter table ARCHIVE_ACT_HI_TASKINST - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_TASKINST_EXE_ID ON ARCHIVE_ACT_HI_TASKINST(STAT_EXECUTION_ID); - -/*--#4 ACT_HI_VARINST */ -alter table ARCHIVE_ACT_HI_VARINST - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_VARINST_EXE_ID ON ARCHIVE_ACT_HI_VARINST(STAT_EXECUTION_ID); - -/*--#5 ACT_HI_DETAIL */ -alter table ARCHIVE_ACT_HI_DETAIL - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_DETAIL_EXE_ID ON ARCHIVE_ACT_HI_DETAIL(STAT_EXECUTION_ID); - -/*--#6 ACT_HI_COMMENT */ -alter table ARCHIVE_ACT_HI_COMMENT - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_COMMENT_EXE_ID ON ARCHIVE_ACT_HI_COMMENT(STAT_EXECUTION_ID); - -/*--#7 ACT_HI_ATTACHMENT */ -alter table ARCHIVE_ACT_HI_ATTACHMENT - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_ATTACHMENT_EXE_ID ON ARCHIVE_ACT_HI_ATTACHMENT(STAT_EXECUTION_ID); - -/*--#8 ACT_HI_OP_LOG */ -alter table ARCHIVE_ACT_HI_OP_LOG - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_OP_LOG_EXE_ID ON ARCHIVE_ACT_HI_OP_LOG(STAT_EXECUTION_ID); - -/*--#9 ACT_HI_INCIDENT */ -alter table ARCHIVE_ACT_HI_INCIDENT - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_INCIDENT_EXE_ID ON ARCHIVE_ACT_HI_INCIDENT(STAT_EXECUTION_ID); - -/*--#10 ACT_GE_BYTEARRAY */ -alter table ARCHIVE_ACT_GE_BYTEARRAY - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_GE_BYTEARRAY_EXE_ID ON ARCHIVE_ACT_GE_BYTEARRAY(STAT_EXECUTION_ID); - - -/* -- Next Val as a user defined function needed only in MariaDB--*/ -DROP FUNCTION IF EXISTS NextVal; - DELIMITER // - CREATE FUNCTION NextVal (vname VARCHAR(30)) - RETURNS INT - BEGIN - -- Retrieve and update in single statement - UPDATE _sequences - SET next = next + 1 - WHERE name = vname; - - RETURN (SELECT next FROM _sequences LIMIT 1); - END - // - DELIMITER ; - -/* -- History tables for use in archive procedure, there is no array type in MariaDB --*/ -Create Table Camunda_Hi_Tables (id_ MEDIUMINT NOT NULL AUTO_INCREMENT, - TableName_ varchar(80) NOT NULL, - PRIMARY KEY (id_)); - -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_PROCINST'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_ACTINST'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_TASKINST'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_VARINST'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_DETAIL'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_COMMENT'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_ATTACHMENT'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_OP_LOG'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_INCIDENT'); - -/*-- log table --*/ -CREATE TABLE TMPLOGTABLE (LogMessage Varchar(700)); - - -/* -- Below user defined functions and procedures needed only in MariaDB, they are in-built in Oracle --*/ -/*-- Create a sequence SP */ -DROP PROCEDURE IF EXISTS CreateSequence; - DELIMITER // - CREATE PROCEDURE CreateSequence (name VARCHAR(30), start INT, inc INT) - BEGIN - -- Create a table to store sequences - CREATE TABLE IF NOT EXISTS _sequences - ( - name VARCHAR(70) NOT NULL UNIQUE, - next INT NOT NULL, - inc INT NOT NULL - ); - - -- Add the new sequence - INSERT INTO _sequences VALUES (name, start, inc); - END - // - DELIMITER ; - -/*-------------------------------------------------------------------------------------------------- - Add Meta to Archive - -------------------------------------------------------------------------------------------------- */ - -/* Create STAT_EXECUTION_SEQ: each Archive Entry has a same Execution ID during one Archiving Run */ -CALL CreateSequence('STAT_EXECUTION_SEQ', 1, 1); +use camundabpmn; +/* + 1. Add some Camunda Indexes to history schema part (for Archiving) +*/ +create INDEX IF NOT EXISTS IDX_ACT_HI_TASKINST_PIID ON ACT_HI_TASKINST (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_COMMENT_PIID ON ACT_HI_COMMENT (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_ATTACHMENT_PIID ON ACT_HI_ATTACHMENT (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_OP_LOG_PIID ON ACT_HI_OP_LOG (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_INCIDENT_PIID ON ACT_HI_INCIDENT (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_ACTINST_PIID ON ACT_HI_ACTINST(PROC_INST_ID_); + + +/* + 2. Create Archiving Tables in current schema +*/ + +/*-- TMP_ARCHIVING_PROCINST */ +CREATE TABLE TMP_ARCHIVING_PROCINST +( PROC_INST_ID_ varchar(64) not null, + END_TIME_ datetime(3) +); +CREATE INDEX AI_TMP_ARCH_PROCINST_PI_ID ON TMP_ARCHIVING_PROCINST(PROC_INST_ID_); + +/*-- TMP_ARCHIVING_BYTEARRAY */ +CREATE TABLE TMP_ARCHIVING_BYTEARRAY +( BYTEARRAY_ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) +); +CREATE INDEX AI_TMP_ARCH_BYTEARRAY_BAID ON TMP_ARCHIVING_BYTEARRAY(BYTEARRAY_ID_); + + +/*--#1 ARCHIVE_ACT_HI_PROCINST; */ +create TABLE ARCHIVE_ACT_HI_PROCINST +AS ( select * from ACT_HI_PROCINST where 1=0); + +create index AI_HI_PROCINST_END_TIME on ARCHIVE_ACT_HI_PROCINST(END_TIME_); +ALTER TABLE ARCHIVE_ACT_HI_PROCINST ADD CONSTRAINT ARCHIVE_ACT_HI_PROCINST_UQ UNIQUE ( PROC_INST_ID_); + +/*--#2 ARCHIVE_ACT_HI_ACTINST; */ +create TABLE ARCHIVE_ACT_HI_ACTINST +AS ( select * from ACT_HI_ACTINST where 1=0); + +create index AI_HI_ACTINST_PROC_INST_ID on ARCHIVE_ACT_HI_ACTINST(PROC_INST_ID_); +create index AI_HI_ACTINST_END_TIME on ARCHIVE_ACT_HI_ACTINST(END_TIME_); + +/*--#3 ARCHIVE_ACT_HI_TASKINST; */ +create TABLE ARCHIVE_ACT_HI_TASKINST +AS ( select * from ACT_HI_TASKINST where 1=0); + +create index AI_HI_TASKINST_PROC_INST_ID on ARCHIVE_ACT_HI_TASKINST(PROC_INST_ID_); +create index AI_HI_TASKINST_END_TIME on ARCHIVE_ACT_HI_TASKINST(END_TIME_); + +/*--#4 ARCHIVE_ACT_HI_VARINST; */ +create TABLE ARCHIVE_ACT_HI_VARINST +AS ( select * from ACT_HI_VARINST where 1=0); + +create index AI_HI_VARINST_PROC_INST_ID on ARCHIVE_ACT_HI_VARINST(PROC_INST_ID_); + +/*--#5 ARCHIVE_ACT_HI_DETAIL; */ +create TABLE ARCHIVE_ACT_HI_DETAIL +AS ( select * from ACT_HI_DETAIL where 1=0); + +create index AI_HI_DETAIL_PROC_INST_ID on ARCHIVE_ACT_HI_DETAIL(PROC_INST_ID_); +create index AI_HI_DETAIL_TIME on ARCHIVE_ACT_HI_DETAIL(TIME_); + +/*--#6 ARCHIVE_ACT_HI_COMMENT; */ +create TABLE ARCHIVE_ACT_HI_COMMENT +AS ( select * from ACT_HI_COMMENT where 1=0); + +create index AI_HI_COMMENT_PROC_INST_ID on ARCHIVE_ACT_HI_COMMENT(PROC_INST_ID_); +create index AI_HI_COMMENT_TIME on ARCHIVE_ACT_HI_COMMENT(TIME_); + +/*--#7 ARCHIVE_ACT_HI_ATTACHMENT; */ +create TABLE ARCHIVE_ACT_HI_ATTACHMENT +AS ( select * from ACT_HI_ATTACHMENT where 1=0); + +create index AI_HI_ATTACHMENT_PROC_INST_ID on ARCHIVE_ACT_HI_ATTACHMENT(PROC_INST_ID_); + +/*--#8 ARCHIVE_ACT_HI_OP_LOG; */ +create TABLE ARCHIVE_ACT_HI_OP_LOG +AS ( select * from ACT_HI_OP_LOG where 1=0); + +create index AI_HI_OP_LOG_PROC_INST_ID on ARCHIVE_ACT_HI_OP_LOG(PROC_INST_ID_); +create index AI_HI_OP_LOG_TIMESTAMP on ARCHIVE_ACT_HI_OP_LOG(TIMESTAMP_); + +/*--#9 ARCHIVE_ACT_HI_INCIDENT; */ +create TABLE ARCHIVE_ACT_HI_INCIDENT +AS ( select * from ACT_HI_INCIDENT where 1=0); + +create index AI_HI_INCIDENT_PROC_INST_ID on ARCHIVE_ACT_HI_INCIDENT(PROC_INST_ID_); + +/*--#10 ARCHIVE_ACT_GE_BYTEARRAY; */ +create TABLE ARCHIVE_ACT_GE_BYTEARRAY +AS ( select * from ACT_GE_BYTEARRAY where 1=0); + +create index AI_GE_BYTEARRAY_ID_ on ARCHIVE_ACT_GE_BYTEARRAY(ID_); + +/* ----------------------------------------------------------------------------- +Extend a ARCHIVE: Table by two attributes: STAT_EXECUTION_ID, STAT_EXECUTION_TS +*/ + +/* +--TEMPLATE: +alter table ARCHIVE_%TableName% + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_%TableName%_EXE_ID ON ARCHIVE_%TableName%(STAT_EXECUTION_ID); +*/ + + +/*--#1 ACT_HI_PROCINST */ +alter table ARCHIVE_ACT_HI_PROCINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_PROCINST_EXE_ID ON ARCHIVE_ACT_HI_PROCINST(STAT_EXECUTION_ID); + +/*--#2 ACT_HI_ACTINST */ +alter table ARCHIVE_ACT_HI_ACTINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_ACTINST_EXE_ID ON ARCHIVE_ACT_HI_ACTINST(STAT_EXECUTION_ID); + +/*--#3 ACT_HI_TASKINST */ +alter table ARCHIVE_ACT_HI_TASKINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_TASKINST_EXE_ID ON ARCHIVE_ACT_HI_TASKINST(STAT_EXECUTION_ID); + +/*--#4 ACT_HI_VARINST */ +alter table ARCHIVE_ACT_HI_VARINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_VARINST_EXE_ID ON ARCHIVE_ACT_HI_VARINST(STAT_EXECUTION_ID); + +/*--#5 ACT_HI_DETAIL */ +alter table ARCHIVE_ACT_HI_DETAIL + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_DETAIL_EXE_ID ON ARCHIVE_ACT_HI_DETAIL(STAT_EXECUTION_ID); + +/*--#6 ACT_HI_COMMENT */ +alter table ARCHIVE_ACT_HI_COMMENT + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_COMMENT_EXE_ID ON ARCHIVE_ACT_HI_COMMENT(STAT_EXECUTION_ID); + +/*--#7 ACT_HI_ATTACHMENT */ +alter table ARCHIVE_ACT_HI_ATTACHMENT + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_ATTACHMENT_EXE_ID ON ARCHIVE_ACT_HI_ATTACHMENT(STAT_EXECUTION_ID); + +/*--#8 ACT_HI_OP_LOG */ +alter table ARCHIVE_ACT_HI_OP_LOG + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_OP_LOG_EXE_ID ON ARCHIVE_ACT_HI_OP_LOG(STAT_EXECUTION_ID); + +/*--#9 ACT_HI_INCIDENT */ +alter table ARCHIVE_ACT_HI_INCIDENT + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_INCIDENT_EXE_ID ON ARCHIVE_ACT_HI_INCIDENT(STAT_EXECUTION_ID); + +/*--#10 ACT_GE_BYTEARRAY */ +alter table ARCHIVE_ACT_GE_BYTEARRAY + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_GE_BYTEARRAY_EXE_ID ON ARCHIVE_ACT_GE_BYTEARRAY(STAT_EXECUTION_ID); + + +/* -- Next Val as a user defined function needed only in MariaDB--*/ +DROP FUNCTION IF EXISTS NextVal; + DELIMITER // + CREATE FUNCTION NextVal (vname VARCHAR(30)) + RETURNS INT + BEGIN + -- Retrieve and update in single statement + UPDATE _sequences + SET next = next + 1 + WHERE name = vname; + + RETURN (SELECT next FROM _sequences LIMIT 1); + END + // + DELIMITER ; + +/* -- History tables for use in archive procedure, there is no array type in MariaDB --*/ +Create Table Camunda_Hi_Tables (id_ MEDIUMINT NOT NULL AUTO_INCREMENT, + TableName_ varchar(80) NOT NULL, + PRIMARY KEY (id_)); + +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_PROCINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_ACTINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_TASKINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_VARINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_DETAIL'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_COMMENT'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_ATTACHMENT'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_OP_LOG'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_INCIDENT'); + +/*-- log table --*/ +CREATE TABLE TMPLOGTABLE (LogMessage Varchar(700)); + + +/* -- Below user defined functions and procedures needed only in MariaDB, they are in-built in Oracle --*/ +/*-- Create a sequence SP */ +DROP PROCEDURE IF EXISTS CreateSequence; + DELIMITER // + CREATE PROCEDURE CreateSequence (name VARCHAR(30), start INT, inc INT) + BEGIN + -- Create a table to store sequences + CREATE TABLE IF NOT EXISTS _sequences + ( + name VARCHAR(70) NOT NULL UNIQUE, + next INT NOT NULL, + inc INT NOT NULL + ); + + -- Add the new sequence + INSERT INTO _sequences VALUES (name, start, inc); + END + // + DELIMITER ; + +/*-------------------------------------------------------------------------------------------------- + Add Meta to Archive + -------------------------------------------------------------------------------------------------- */ + +/* Create STAT_EXECUTION_SEQ: each Archive Entry has a same Execution ID during one Archiving Run */ +CALL CreateSequence('STAT_EXECUTION_SEQ', 1, 1); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml index 8a690403c4..7b72812f1a 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml @@ -1,10 +1,10 @@ - - skask - supercool - slowburn - complete - 78987 - introvert - 3.14 - myhost.appl.com + + skask + supercool + slowburn + complete + 78987 + introvert + 3.14 + myhost.appl.com \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml index 3370e33ce2..ee09c9bc4a 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml @@ -5,8 +5,8 @@ pending-create false 330-89 - introvert - 2.0 + introvert + 2.0 volume-group diff --git a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties index 133f58593c..1ac75e9456 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties +++ b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties @@ -57,7 +57,7 @@ aai.endpoint=http://localhost:28090 # Example to override default version for a resource: #mso.workflow.default.aai.vce.version=6 #mso.workflow.default.aai.v6.vce.uri=/aai/v6/network/vces/vce - +mso.workflow.global.default.aai.namespace=http://org.openecomp.aai.inventory/ mso.workflow.global.default.aai.version=8 mso.workflow.default.aai.cloud-region.version=9 mso.workflow.default.aai.generic-vnf.version=9 @@ -83,4 +83,11 @@ log.debug.FalloutHandler=true log.debug.GenericGetService=true log.debug.sdncAdapter=true log.debug.UpdateNetworkInstanceInfra=true -log.debug.VnfAdapterRestV1=true \ No newline at end of file +log.debug.VnfAdapterRestV1=true +log.debug.GenericGetNetwork=true +log.debug.GenericGetVnf=true +log.debug.GenericDeleteService=true +log.debug.GenericDeleteNetwork=true +log.debug.GenericDeleteVnf=true +log.debug.vnfAdapterCreateV1=true +log.debug.vnfAdapterRestV1=true diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/AllottedResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/AllottedResource.java new file mode 100644 index 0000000000..c7d2ed9583 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/AllottedResource.java @@ -0,0 +1,38 @@ +package org.openecomp.mso.bpmn.core.decomposition; + +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("allottedResource") +public class AllottedResource extends ResourceDecomposition { + + private static final long serialVersionUID = 1L; + + /* + * set resourceType for this object + */ + public AllottedResource(){ + resourceType = "allottedResource"; + } + + /* + * fields specific to VNF resource type + */ + private String allottedResourceType; + private String allottedResourceRole; + + /* + * GET and SET + */ + public String getAllottedResourceType() { + return allottedResourceType; + } + public void setAllottedResourceType(String allottedResourceType) { + this.allottedResourceType = allottedResourceType; + } + public String getAllottedResourceRole() { + return allottedResourceRole; + } + public void setAllottedResourceRole(String allottedResourceRole) { + this.allottedResourceRole = allottedResourceRole; + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/HomingSolution.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/HomingSolution.java new file mode 100644 index 0000000000..f6c1ad917f --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/HomingSolution.java @@ -0,0 +1,49 @@ +package org.openecomp.mso.bpmn.core.decomposition; + +import java.io.Serializable; +import java.util.List; + +public class HomingSolution extends JsonWrapper implements Serializable { + + private static final long serialVersionUID = 1L; + + private String infraServiceInstanceId; + private String aicCloudRegionId; + private String ucpeId; + private List entitlementPool; + private List entitlementKeyGroup; + + /* + * GET && SET + */ + public String getInfraServiceInstanceId() { + return infraServiceInstanceId; + } + public void setInfraServiceInstanceId(String infraServiceInstanceId) { + this.infraServiceInstanceId = infraServiceInstanceId; + } + public String getAicCloudRegionId() { + return aicCloudRegionId; + } + public void setAicCloudRegionId(String aicCloudRegionId) { + this.aicCloudRegionId = aicCloudRegionId; + } + public String getUcpeId() { + return ucpeId; + } + public void setUcpeId(String ucpeId) { + this.ucpeId = ucpeId; + } + public List getEntitlementPool() { + return entitlementPool; + } + public void setEntitlementPool(List entitlementPool) { + this.entitlementPool = entitlementPool; + } + public List getEntitlementKeyGroup() { + return entitlementKeyGroup; + } + public void setEntitlementKeyGroup(List entitlementKeyGroup) { + this.entitlementKeyGroup = entitlementKeyGroup; + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/InstanceData.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/InstanceData.java new file mode 100644 index 0000000000..13e9f9ac00 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/InstanceData.java @@ -0,0 +1,37 @@ +package org.openecomp.mso.bpmn.core.decomposition; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties +public class InstanceData extends JsonWrapper implements Serializable { + + private static final long serialVersionUID = 1L; + + private String instanceId; + private String instanceName; + private HomingSolution homingSolution; + + /* + * GET && SET + */ + public String getInstanceId() { + return instanceId; + } + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + public String getInstanceName() { + return instanceName; + } + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + public HomingSolution getHomingSolution() { + return homingSolution; + } + public void setHomingSolution(HomingSolution homingSolution) { + this.homingSolution = homingSolution; + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/JsonWrapper.java new file mode 100644 index 0000000000..dcc6852c4e --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/JsonWrapper.java @@ -0,0 +1,140 @@ +package org.openecomp.mso.bpmn.core.decomposition; + +import java.io.IOException; +import java.util.List; + +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.ObjectWriter; +import org.json.JSONException; +import org.json.JSONObject; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.DeserializationFeature; + + +//import org.codehaus.jackson.map.SerializationConfig.Feature; +import org.codehaus.jackson.map.DeserializationConfig.Feature; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +/** + * Wrapper encapsulates needed JSON functionality + * to be extended by MSO service decomposition objects + * providing ways to convert to and from JSON + * + * @author + * + */ +@JsonInclude(Include.NON_NULL) +public abstract class JsonWrapper { + + @JsonInclude(Include.NON_NULL) + public String toJsonString(){ + + + + String jsonString = ""; + //convert with Jackson + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE); + + mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); + + ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter(); + try { + jsonString = ow.writeValueAsString(this); + } catch (JsonGenerationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (JsonMappingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return jsonString; + } + + @JsonInclude(Include.NON_NULL) + public JSONObject toJsonObject(){ + + ObjectMapper mapper = new ObjectMapper(); + // mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true); + //mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); + + mapper.enable(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE); + // mapper.enable(org.codehaus.jackson.map.DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); + JSONObject json = new JSONObject(); + try { + json = new JSONObject(mapper.writeValueAsString(this)); + } catch (JsonGenerationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (JsonMappingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return json; + } + + public String listToJson(List list) { + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE); + + String jsonString = ""; + try { + jsonString = mapper.writeValueAsString(list); + } catch (JsonGenerationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (JsonMappingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return jsonString; + } + + /** + * Method to construct Service Decomposition object converting + * JSON structure + * + * @param jsonString - input in JSON format confirming ServiceDecomposition + * @return - ServiceDecomposition object + */ + public ServiceDecomposition JsonToServiceDecomposition(String jsonString) { + + ServiceDecomposition serviceDecomposition = new ServiceDecomposition(); + ObjectMapper om = new ObjectMapper(); + om.configure(Feature.UNWRAP_ROOT_VALUE, true); + + try { + serviceDecomposition = om.readValue(jsonString, ServiceDecomposition.class); + } catch (JsonParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (JsonMappingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return serviceDecomposition; + } + +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ModelInfo.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ModelInfo.java new file mode 100644 index 0000000000..ecbb076d80 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ModelInfo.java @@ -0,0 +1,101 @@ +package org.openecomp.mso.bpmn.core.decomposition; + +import java.io.Serializable; + +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("modelInfo") +public class ModelInfo extends JsonWrapper implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private String modelName = ""; + private String modelUuid = ""; + private String modelInvariantId = ""; + private String modelVersion = ""; + //additionally on resource level + private String modelCustomizationUuid = ""; + private String modelInstanceName = ""; + + //TODO - those were present in original "modelInfo" object structure. Confirm. + private String modelCustomizationName = ""; + private String modelVersionId = ""; + private String modelType = ""; + + public String getModelName() { + return modelName; + } + public void setModelName(String modelName) { + this.modelName = modelName; + } + public String getModelUuid() { + return modelUuid; + } + public void setModelUuid(String modelUuid) { + this.modelUuid = modelUuid; + } + public String getModelInvariantId() { + return modelInvariantId; + } + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + public String getModelVersion() { + return modelVersion; + } + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + public String getModelCustomizationUuid() { + return modelCustomizationUuid; + } + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public String getModelInstanceName() { + return modelInstanceName; + } + public void setModelInstanceName(String modelInstanceName) { + this.modelInstanceName = modelInstanceName; + } + public String getModelCustomizationName() { + return modelCustomizationName; + } + public void setModelCustomizationName(String modelCustomizationName) { + this.modelCustomizationName = modelCustomizationName; + } + public String getModelVersionId() { + return modelVersionId; + } + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + public String getModelType() { + return modelType; + } + public void setModelType(String modelType) { + this.modelType = modelType; + } + + //TODO add convenience methods + + + //TODO - complete this manual + public String toString(){ + + String jsonString = ""; + + //can try building manually + jsonString = "{" + + "\"modelName\":\"" + getModelName() + "\"," + + "\"modelUuid\":\"" + getModelUuid() + "\"" + + "\"modelInvariantId\":\"" + getModelInvariantId() + "\"" + + "}"; + + + return jsonString; + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ModuleResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ModuleResource.java new file mode 100644 index 0000000000..1c91f4e600 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ModuleResource.java @@ -0,0 +1,60 @@ +package org.openecomp.mso.bpmn.core.decomposition; + +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("vfModule") +public class ModuleResource extends ResourceDecomposition { + + private static final long serialVersionUID = 1L; + + /* + * set resourceType for this object + */ + public ModuleResource(){ + resourceType = "module"; + } + + /* + * fields specific to VF Module resource type + */ + private String vfModuleType; + private boolean hasVolumeGroup; + private boolean isBase; + private String vfModuleLabel; + private int initialCount; + + /* + * GET && SET + */ + public boolean getIsBase() { + return isBase; + } + public void setIsBase(boolean isBase) { + this.isBase = isBase; + } + public String getVfModuleLabel() { + return vfModuleLabel; + } + public void setVfModuleLabel(String vfModuleLabel) { + this.vfModuleLabel = vfModuleLabel; + } + public int getInitialCount() { + return initialCount; + } + public void setInitialCount(int initialCount) { + this.initialCount = initialCount; + } + public String getVfModuleType() { + return vfModuleType; + } + public void setVfModuleType(String vfModuleType) { + this.vfModuleType = vfModuleType; + } + public boolean isHasVolumeGroup() { + return hasVolumeGroup; + } + public void setHasVolumeGroup(boolean hasVolumeGroup) { + this.hasVolumeGroup = hasVolumeGroup; + } + +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/NetworkResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/NetworkResource.java new file mode 100644 index 0000000000..16d1010633 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/NetworkResource.java @@ -0,0 +1,42 @@ +package org.openecomp.mso.bpmn.core.decomposition; + +import org.codehaus.jackson.map.annotate.JsonRootName; + + +/** + * Encapsulates Network resource data set + * @author + * + */ +@JsonRootName("networkResource") +public class NetworkResource extends ResourceDecomposition { + + private static final long serialVersionUID = 1L; + /* + * set resourceType for this object + */ + public NetworkResource(){ + resourceType = "networkResource"; + } + /* + * fields specific to VNF resource type + */ + private String networkType; + private String networkRole; + + /* + * GET and SET + */ + public String getNetworkType() { + return networkType; + } + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + public String getNetworkRole() { + return networkRole; + } + public void setNetworkRole(String networkRole) { + this.networkRole = networkRole; + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ResourceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ResourceDecomposition.java new file mode 100644 index 0000000000..ba01c8fc44 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ResourceDecomposition.java @@ -0,0 +1,70 @@ +package org.openecomp.mso.bpmn.core.decomposition; + +import java.io.Serializable; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * Abstract superclass for all individual decomposition resources + * + * @author + * + */ +//@JsonIgnoreProperties +public abstract class ResourceDecomposition extends JsonWrapper implements Serializable { + + private static final long serialVersionUID = 1L; + + protected String resourceType; // Enum of vnf or network or allotted resource + private ModelInfo modelInfo; + + //private List modules; + private InstanceData instanceData = new InstanceData(); + + // GET and SET + public ModelInfo getModelInfo() { + return modelInfo; + } + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + public InstanceData getInstanceData() { + return instanceData; + } + public void setInstanceData(InstanceData instanceData) { + this.instanceData = instanceData; + } + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + //Utility methods + @JsonIgnore + public ModelInfo getResourceModel() { + return modelInfo; + } + @JsonIgnore + public String getResourceInstanceId() { + return this.getInstanceData().getInstanceId(); + } + @JsonIgnore + public String getResourceInstanceName() { + return this.getInstanceData().getInstanceName(); + } +// @JsonIgnore +// public String getResourceHomingSolution() { +// } + + public void setResourceInstanceId(String newInstanceId){ + this.getInstanceData().setInstanceId(newInstanceId); + } + public void setResourceInstanceName(String newInstanceName){ + this.getInstanceData().setInstanceName(newInstanceName); + } +// @JsonIgnore +// public String setResourceHomingSolution() { +// } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ServiceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ServiceDecomposition.java new file mode 100644 index 0000000000..00ba091677 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ServiceDecomposition.java @@ -0,0 +1,159 @@ +package org.openecomp.mso.bpmn.core.decomposition; + + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.json.JSONObject; + + + +/** + * Service Decomposition Structure + * This Java object contains service information: + * - Service model info + * - list of VNF resource's decompositon + * - list of network resource's decompositon + * - list of allotted resource's decompositon + */ +@JsonRootName(value = "serviceResources") +//@JsonTypeInfo(include=As.WRAPPER_OBJECT, use=Id.NAME) +public class ServiceDecomposition extends JsonWrapper implements Serializable { + + private static final long serialVersionUID = 1L; + + @JsonProperty("modelInfo") + private ModelInfo modelInfo; + private ServiceInstanceData serviceInstanceData; + @JsonProperty("vnfResource") + private List vnfResources; + @JsonProperty("networkResource") + private List networkResources; + @JsonProperty("allottedResource") + private List allottedResources; + + public ServiceDecomposition () { + super(); + } + + public ServiceDecomposition (ModelInfo modelInfo, ServiceInstanceData serviceInstanceData, List vnfResources, List networkResources, List allottedResources ) { + //TODO provide constructor implementation +// this.modelInfo = modelInfo; +// this.serviceInstanceData = serviceInstanceData; +// this.vnfResources = vnfResources; +// this.networkResources = networkResources; +// this.allottedResources = allottedResources; + + } + + public ServiceDecomposition (String catalogRestOutput, String serviceInstanceId) { + //TODO provide constructor implementation + + this.modelInfo = this.JsonToServiceDecomposition(catalogRestOutput).getModelInfo(); + this.vnfResources = this.JsonToServiceDecomposition(catalogRestOutput).getServiceVnfs(); + this.allottedResources = this.JsonToServiceDecomposition(catalogRestOutput).getServiceAllottedResources(); + this.networkResources = this.JsonToServiceDecomposition(catalogRestOutput).getServiceNetworks(); + this.serviceInstanceData = new ServiceInstanceData(); + this.serviceInstanceData.setInstanceId(serviceInstanceId); + } + public ServiceDecomposition (JSONObject catalogRestOutput, String serviceInstanceId) { + //TODO provide constructor implementation + } + //GET and SET + public ModelInfo getModelInfo() { + return modelInfo; + } + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + public ServiceInstanceData getServiceInstanceData() { + return serviceInstanceData; + } + public void setServiceInstanceData(ServiceInstanceData serviceInstanceData) { + this.serviceInstanceData = serviceInstanceData; + } + public List getServiceVnfs() { + return vnfResources; + } + public void setServiceVnfs(List vnfResources) { + this.vnfResources = vnfResources; + } + public List getServiceNetworks() { + return networkResources; + } + public void setServiceNetworks(List networkResources) { + this.networkResources = networkResources; + } + public List getServiceAllottedResources() { + return allottedResources; + } + public void setServiceAllottedResources(List allottedResources) { + this.allottedResources = allottedResources; + } + + // methods to add to the list + public void addVnfResource(VnfResource vnfResource) { + if (vnfResources == null){ + vnfResources = new ArrayList(); + } + this.vnfResources.add(vnfResource); + } + public void addNetworkResource(NetworkResource networkResource) { + if (networkResources == null){ + networkResources = new ArrayList(); + } + this.networkResources.add(networkResource); + } + public void addAllottedResource(AllottedResource allottedResource) { + if (allottedResources == null){ + allottedResources = new ArrayList(); + } + this.allottedResources.add(allottedResource); + } + +// //TODO - IF NEEDED, update below methods to return one resource decomposition by (?) ID, not index - used temporarily +// public VnfResource getnfResource(int index) { +// +//// Iterator iter = vnfResources.iterator(); +//// while (iter.hasNext()) { +//// VnfResource vnfResource = iter.next(); +//// vnfResource.getModelInfo().getModelInvariantId(); +//// } +// return this.vnfResources.get(index); +// } +// public NetworkResource getNetworkResource( int index) { +// return this.networkResources.get(index); +// } +// public AllottedResource getAllottedResource(int index) { +// return this.allottedResources.get(index); +// } + + @JsonIgnore + public List getServiceResources(){ + ArrayList serviceResources = new ArrayList(); + serviceResources.addAll(this.getServiceNetworks()); + serviceResources.addAll(this.getServiceVnfs()); + serviceResources.addAll(this.getServiceAllottedResources()); + return serviceResources; + } + + @JsonIgnore + public String getServiceResourcesJsonString(){ + StringBuffer serviceResourcesJsonStringBuffer = new StringBuffer(); + serviceResourcesJsonStringBuffer.append(listToJson((this.getServiceNetworks()))); + serviceResourcesJsonStringBuffer.append(listToJson((this.getServiceVnfs()))); + serviceResourcesJsonStringBuffer.append(listToJson((this.getServiceAllottedResources()))); + return serviceResourcesJsonStringBuffer.toString(); + } + + //return String representation of JSON + @Override + public String toString(){ + return "string representation"; + } + +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ServiceInstanceData.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ServiceInstanceData.java new file mode 100644 index 0000000000..9b7393d742 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/ServiceInstanceData.java @@ -0,0 +1,23 @@ +package org.openecomp.mso.bpmn.core.decomposition; + +import java.io.Serializable; + +public class ServiceInstanceData extends JsonWrapper implements Serializable { + + private static final long serialVersionUID = 1L; + private String instanceId; + private String instanceName; + + public String getInstanceId() { + return instanceId; + } + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + public String getInstanceName() { + return instanceName; + } + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/VnfResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/VnfResource.java new file mode 100644 index 0000000000..267a20ebe6 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/decomposition/VnfResource.java @@ -0,0 +1,91 @@ +package org.openecomp.mso.bpmn.core.decomposition; + +import java.util.ArrayList; +import java.util.List; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.map.annotate.JsonRootName; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Encapsulates VNF resource data set + * @author + * + */ +@JsonRootName("vnfResource") +public class VnfResource extends ResourceDecomposition { + + private static final long serialVersionUID = 1L; + + /* + * set resourceType for this object + */ + public VnfResource(){ + resourceType = "vnfResource"; + } + + /* + * fields specific to VNF resource type + */ + @JsonProperty("vfModules") + private List vfModules; + private String vnfType; + + /* + * GET and SET + */ + public List getVfModules() { + return vfModules; + } + public void setModules(List moduleResources) { + this.vfModules = moduleResources; + } + public String getVnfType() { + return vnfType; + } + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + /* + * GET accessors per design requirements + */ + + /** + * Returns a list of all VfModule objects. + * Base module is first entry in the list + * @return ordered list of ModuleResources objects + */ + @JsonIgnore + public List getAllVfModuleObjects(){ + + for (int i = 0; i < vfModules.size(); i++) { + ModuleResource moduleResource = vfModules.get(i); + if (moduleResource.getIsBase()){ + vfModules.remove(moduleResource); + vfModules.add(0,moduleResource); + } + } + return vfModules; + } + + /** + * + * @return Returns JSON list of all VfModule structures. + */ + @JsonIgnore + public String getAllVfModulesJson(){ + + return listToJson(vfModules); + } + + // methods to add to the list + public void addVfModule(ModuleResource moduleResource) { + if (vfModules == null){ + vfModules = new ArrayList(); + } + this.vfModules.add(moduleResource); + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy new file mode 100644 index 0000000000..ec414a4ee2 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy @@ -0,0 +1,262 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; +import groovy.xml.XmlUtil +import groovy.json.* +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.rest.APIResponse + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils + +/** + * This groovy class supports the CreateServiceInstance.bpmn process. + * AlaCarte flow for 1702 ServiceInstance Create + * + */ +public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskProcessor { + String Prefix="CRESI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + + public void preProcessRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + String msg = "" + utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled) + + try { + + String siRequest = execution.getVariable("bpmnRequest") + utils.logAudit(siRequest) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if (isBlank(serviceInstanceId)) { + serviceInstanceId = UUID.randomUUID().toString() + } + utils.log("DEBUG", "Generated new Service Instance:" + serviceInstanceId, isDebugEnabled) + 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" + utils.log("DEBUG", msg, isDebugEnabled) + //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" + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceModelInfo", serviceModelInfo) + } + + utils.log("DEBUG", "modelInfo" + serviceModelInfo, isDebugEnabled) + + //requestParameters + String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + //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() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) + } + + public void sendSyncResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) + + 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() + utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + createServiceRestRequest, isDebugEnabled) + sendWorkflowResponse(execution, 202, createServiceRestRequest) + 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) + } + + + public void sendSyncError (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** sendSyncError *** ", isDebugEnabled) + + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${errorMessage} + 7000 + """ + + utils.logAudit(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) + } + + } + + public void prepareCompletionRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled) + + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String source = execution.getVariable("source") + + String msoCompletionRequest = + """ + + ${requestId} + CREATE + ${source} + + Service Instance was created successfully. + ${serviceInstanceId} + CreateGenericALaCarteServiceInstance + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable("completionRequest", xmlMsoCompletionRequest) + utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) + + } catch (Exception ex) { + String msg = " Exception in prepareCompletion:" + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled) + } + + public void prepareFalloutRequest(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** prepareFalloutRequest *** ", isDebugEnabled) + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + utils.log("DEBUG", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled) + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String requestInfo = + """ + ${requestId} + CREATE + ${source} + """ + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + execution.setVariable("falloutRequest", falloutRequest) + } catch (Exception ex) { + utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled) + String errorException = " Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() + String requestId = execution.getVariable("msoRequestId") + String falloutRequest = + """ + + ${requestId} + CREATE + VID + + + ${errorException} + 7000 + + """ + + execution.setVariable("falloutRequest", falloutRequest) + } + utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled) + } +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy index 88e2396078..79508cb8cb 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy @@ -1,752 +1,804 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.json.JSONObject; -import org.json.JSONArray; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; - -/** - * This groovy class supports the CreateGenericMacroServiceNetworkVnf.bpmn process. - * - */ -public class CreateGenericMacroServiceNetworkVnf extends AbstractServiceTaskProcessor { - - String Prefix="CREVAS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - CatalogDbUtils catalogDbUtils = new CatalogDbUtils() - - /** - * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. - * @param execution - */ - public InitializeProcessVariables(Execution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable("createGenericMacroServiceNetworkVnfRequest", "") - execution.setVariable("globalSubscriberId", "") - execution.setVariable("serviceInstanceName", "") - execution.setVariable("msoRequestId", "") - execution.setVariable("CREVAS_NetworksCreatedCount", 0) - execution.setVariable("CREVAS_VnfsCreatedCount", 0) - execution.setVariable("productFamilyId", "") - - - //TODO - execution.setVariable("sdncVersion", "1702") - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. - * @param execution - */ - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest CreateGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // check for incoming json message/input - String createGenericMacroServiceNetworkVnfRequest = execution.getVariable("bpmnRequest") - utils.logAudit(createGenericMacroServiceNetworkVnfRequest) - execution.setVariable("createGenericMacroServiceNetworkVnfRequest", createGenericMacroServiceNetworkVnfRequest); - println 'createGenericMacroServiceNetworkVnfRequest - ' + createGenericMacroServiceNetworkVnfRequest - - // extract requestId - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) { - serviceInstanceId = UUID.randomUUID().toString() - utils.log("DEBUG", " Generated new Service Instance: " + serviceInstanceId , isDebugEnabled) - } else { - utils.log("DEBUG", "Using provided Service Instance ID: " + serviceInstanceId , isDebugEnabled) - } - - serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8") - execution.setVariable("serviceInstanceId", serviceInstanceId) - - String requestAction = execution.getVariable("requestAction") - execution.setVariable("requestAction", requestAction) - - String source = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.source") - if ((source == null) || (source.isEmpty())) { - execution.setVariable("source", "VID") - } else { - execution.setVariable("source", source) - } - - // extract globalSubscriberId - String globalSubscriberId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "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(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestParameters.subscriptionServiceType") - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) - - String suppressRollback = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.suppressRollback") - execution.setVariable("disableRollback", suppressRollback) - utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) - - String productFamilyId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.infrastructure.scripts; + +import groovy.xml.XmlUtil +import groovy.json.* + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.decomposition.ModelInfo +import org.openecomp.mso.bpmn.core.decomposition.NetworkResource +import org.openecomp.mso.bpmn.core.decomposition.ServiceDecomposition +import org.openecomp.mso.bpmn.core.decomposition.VnfResource +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.json.JSONObject; +import org.json.JSONArray; +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils; + +/** + * This groovy class supports the CreateGenericMacroServiceNetworkVnf.bpmn process. + * + */ +public class CreateGenericMacroServiceNetworkVnf extends AbstractServiceTaskProcessor { + + String Prefix="CGMSNV_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + CatalogDbUtils catalogDbUtils = new CatalogDbUtils() + + /** + * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. + * @param execution + */ + public InitializeProcessVariables(Execution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable("createViprServiceRequest", "") + execution.setVariable("globalSubscriberId", "") + execution.setVariable("serviceInstanceName", "") + execution.setVariable("msoRequestId", "") + execution.setVariable("CGMSNV_NetworksCreatedCount", 0) + execution.setVariable("CGMSNV_VnfsCreatedCount", 0) + execution.setVariable("productFamilyId", "") + + //TODO + execution.setVariable("sdncVersion", "1707") + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. + * @param execution + */ + public void preProcessRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " ***** Inside preProcessRequest CreateGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // check for incoming json message/input + String createViprServiceRequest = execution.getVariable("bpmnRequest") + utils.logAudit(createViprServiceRequest) + execution.setVariable("createViprServiceRequest", createViprServiceRequest); + println 'createViprServiceRequest - ' + createViprServiceRequest + + // extract requestId + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) { + serviceInstanceId = UUID.randomUUID().toString() + utils.log("DEBUG", " Generated new Service Instance: " + serviceInstanceId , isDebugEnabled) + } else { + utils.log("DEBUG", "Using provided Service Instance ID: " + serviceInstanceId , isDebugEnabled) + } + + serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8") + execution.setVariable("serviceInstanceId", serviceInstanceId) + + String requestAction = execution.getVariable("requestAction") + execution.setVariable("requestAction", requestAction) + + String source = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.source") + if ((source == null) || (source.isEmpty())) { + execution.setVariable("source", "VID") + } else { + execution.setVariable("source", source) + } + + // extract globalSubscriberId + String globalSubscriberId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId") + + // verify element global-customer-id is sent from JSON input, throw exception if missing + if ((globalSubscriberId == null) || (globalSubscriberId.isEmpty())) { + String dataErrorMessage = " Element 'globalSubscriberId' is missing. " + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + execution.setVariable("globalCustomerId", globalSubscriberId) + } + + // extract subscriptionServiceType + String subscriptionServiceType = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestParameters.subscriptionServiceType") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) + + String suppressRollback = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.suppressRollback") + execution.setVariable("disableRollback", suppressRollback) + utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) + + String productFamilyId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) + + //For Completion Handler & Fallout Handler + String requestInfo = """ - ${requestId} - CREATE - ${source} - """ - - execution.setVariable("CREVAS_requestInfo", requestInfo) - - utils.log("DEBUG", " ***** Completed preProcessRequest CreateGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex){ - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected from method preProcessRequest() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String requestId = execution.getVariable("mso-request-id") - - // RESTResponse (for API Handler (APIH) Reply Task) - String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) - sendWorkflowResponse(execution, 202, syncResponse) - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // - // ******************************* - public void prepareCreateServiceInstance(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - String createGenericMacroServiceNetworkVnfRequest = execution.getVariable("createGenericMacroServiceNetworkVnfRequest") - String serviceModelInfo = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.modelInfo") - execution.setVariable("serviceModelInfo", serviceModelInfo) - - String serviceInputParams = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestParameters") - execution.setVariable("serviceInputParams", serviceInputParams) - - String serviceInstanceName = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.instanceName") - execution.setVariable("serviceInstanceName", serviceInstanceName) - - utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareCreateService() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - - public void postProcessServiceInstanceCreate (Execution execution){ - def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +'execution=' + execution.getId() +')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - String source = execution.getVariable("source") - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String serviceInstanceName = execution.getVariable("serviceInstanceName") - - try { - - String payload = """ + ${requestId} + CREATE + ${source} + """ + + execution.setVariable("CGMSNV_requestInfo", requestInfo) + + utils.log("DEBUG", " ***** Completed preProcessRequest CreateGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex){ + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected from method preProcessRequest() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void sendSyncResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String requestId = execution.getVariable("mso-request-id") + + // RESTResponse (for API Handler (APIH) Reply Task) + String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() + + utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) + sendWorkflowResponse(execution, 202, syncResponse) + + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // + // ******************************* + public void prepareDecomposeService(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareDecomposeService of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + String createViprServiceRequest = execution.getVariable("createViprServiceRequest") + String serviceModelInfo = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.modelInfo") + execution.setVariable("serviceModelInfo", serviceModelInfo) + + utils.log("DEBUG", " ***** Completed prepareDecomposeService of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // + // ******************************* + public void prepareCreateServiceInstance(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + /* + * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject + * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + * ModelInfo modelInfo = serviceDecomposition.getModelInfo() + * + */ + String createViprServiceRequest = execution.getVariable("createViprServiceRequest") + String serviceInputParams = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestParameters") + execution.setVariable("serviceInputParams", serviceInputParams) + + String serviceInstanceName = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.instanceName") + execution.setVariable("serviceInstanceName", serviceInstanceName) + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonString()) + + utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void postProcessServiceInstanceCreate (Execution execution){ + def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + String source = execution.getVariable("source") + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceInstanceName = execution.getVariable("serviceInstanceName") + + try { + + String payload = """ - - - - ${requestId} - BPEL - ${serviceInstanceId} - ${serviceInstanceName} - - - - """ - execution.setVariable("CREVAS_setUpdateDbInstancePayload", payload) - utils.logAudit("CREVAS_setUpdateDbInstancePayload: " + payload) - logDebug('Exited ' + method, isDebugLogEnabled) - //println("CMSO_updateDBStatusToSuccessPayload --> " + execution.getVariable("CMSO_updateDBStatusToSuccessPayload")) - - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) - } - } - - - public void callDBCatalog (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside callDBCatalog() of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - - // get variable within incoming json - String createGenericMacroServiceNetworkVnfRequest = execution.getVariable("createGenericMacroServiceNetworkVnfRequest"); - - String catalog_db_endpoint = execution.getVariable("URN_mso_catalog_db_endpoint") - utils.log("DEBUG", "catalog_db_endpoint: "+catalog_db_endpoint, isDebugEnabled) - - String serviceModelInvariantId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.modelInfo.modelInvariantId") - String serviceModelVersion = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.modelInfo.modelVersion") - utils.log("DEBUG", "getting network list ", isDebugEnabled) - - JSONArray networkList = catalogDbUtils.getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(catalog_db_endpoint, serviceModelInvariantId, serviceModelVersion) - - //utils.log("DEBUG", "got network list: "+ networkList.toString(), isDebugEnabled) - execution.setVariable("networkList", networkList) - execution.setVariable("networkListString", networkList.toString()) - - networkList = execution.getVariable("networkList"); - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - if (networkList != null && networkList.length() > 0) { - - execution.setVariable("CREVAS_NetworksCount", networkList.length()) - utils.log("DEBUG", "networks to create: "+ networkList.length(), isDebugEnabled) - } else { - execution.setVariable("CREVAS_NetworksCount", 0) - utils.log("DEBUG", "no networks to create based upon Catalog DB response", isDebugEnabled) - } - - // VNFs - JSONArray vnfList = catalogDbUtils.getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(catalog_db_endpoint, serviceModelInvariantId, serviceModelVersion) - execution.setVariable("vnfList", vnfList) - - String vnfModelInfoString = "" - if (vnfList != null && vnfList.length() > 0) { - execution.setVariable("CREVAS_VNFsCount", vnfList.length()) - utils.log("DEBUG", "vnfs to create: "+ vnfList.length(), isDebugEnabled) - JSONObject vnfModelInfo = vnfList.getJSONObject(0).getJSONObject("modelInfo") - vnfModelInfoString = vnfModelInfo.toString() - } else { - execution.setVariable("CREVAS_VNFsCount", 0) - utils.log("DEBUG", "no vnfs to create based upon Catalog DB response", isDebugEnabled) - } - - execution.setVariable("vnfModelInfo", vnfModelInfoString) - //utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed callDBCatalog() of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. callDBCatalog() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareNetworkCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside preparenNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - -// String disableRollback = execution.getVariable("disableRollback") -// def backoutOnFailure = "" -// if(disableRollback != null){ -// if ( disableRollback == true) { -// backoutOnFailure = "false" -// } else if ( disableRollback == false) { -// backoutOnFailure = "true" -// } -// } - //failIfExists - optional - - String createGenericMacroServiceNetworkVnfRequest = execution.getVariable("createGenericMacroServiceNetworkVnfRequest") - - JSONArray networkList = execution.getVariable("networkList") - utils.log("DEBUG", "array networkList: "+ networkList, isDebugEnabled) - - if (networkList == null || networkList.length() < 1){ - networkList = new JSONArray(execution.getVariable("networkListString")) - utils.log("DEBUG", "array from string networkList: "+ networkList, isDebugEnabled) - } - - Integer networksCreatedCount = execution.getVariable("CREVAS_NetworksCreatedCount") - String networkModelInfoString = "" - - if (networkList != null) { - utils.log("DEBUG", " getting model info for network # :" + networksCreatedCount, isDebugEnabled) - JSONObject networkModelInfo = networkList.getJSONObject(networksCreatedCount.intValue()).getJSONObject("modelInfo") - networkModelInfoString = networkModelInfo.toString() - } else { - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected number of networks to create - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - execution.setVariable("networkModelInfo", networkModelInfoString) - utils.log("DEBUG", " networkModelInfoString :" + networkModelInfoString, isDebugEnabled) - -// String networkModelInfo = execution.getVariable("networkModelInfo") - // extract cloud configuration - String lcpCloudRegionId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) - utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("tenantId", tenantId) - utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) - - JSONArray vnfList = execution.getVariable("vnfList") - utils.log("DEBUG", "vnfList: "+ vnfList, isDebugEnabled) - - String vnfModelInfo = execution.getVariable("vnfModelInfo") - utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) - - networkList = execution.getVariable("networkList") - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed preparenNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareNetworkCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section -> increment count - // ******************************* - public void validateNetworkCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - Integer networksCreatedCount = execution.getVariable("CREVAS_NetworksCreatedCount") - networksCreatedCount++ - - execution.setVariable("CREVAS_NetworksCreatedCount", networksCreatedCount) - - execution.setVariable("DCRENI_rollbackData"+networksCreatedCount, execution.getVariable("DCRENI_rollbackData")) - - utils.log("DEBUG", "networksCreatedCount: "+ networksCreatedCount, isDebugEnabled) - utils.log("DEBUG", "DCRENI_rollbackData N : "+ execution.getVariable("DCRENI_rollbackData"+networksCreatedCount), isDebugEnabled) - - JSONArray vnfList = execution.getVariable("vnfList") - utils.log("DEBUG", "vnfList: "+ vnfList, isDebugEnabled) - - String vnfModelInfo = execution.getVariable("vnfModelInfo") - utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) - - JSONArray networkList = execution.getVariable("networkList") - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed validateNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** "+" network # "+networksCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareVnfAndModulesCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - // String disableRollback = execution.getVariable("disableRollback") - // def backoutOnFailure = "" - // if(disableRollback != null){ - // if ( disableRollback == true) { - // backoutOnFailure = "false" - // } else if ( disableRollback == false) { - // backoutOnFailure = "true" - // } - // } - //failIfExists - optional - - String createGenericMacroServiceNetworkVnfRequest = execution.getVariable("createGenericMacroServiceNetworkVnfRequest") - String productFamilyId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled) - - JSONArray vnfList = execution.getVariable("vnfList") - - Integer vnfsCreatedCount = execution.getVariable("CREVAS_VnfsCreatedCount") - String vnfModelInfoString = null; - - if (vnfList != null && vnfList.length() > 0 ) { - utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled) - JSONObject vnfModelInfo1 = vnfList.getJSONObject(0).getJSONObject("modelInfo") - utils.log("DEBUG", "got 0 ", isDebugEnabled) - JSONObject vnfModelInfo = vnfList.getJSONObject(vnfsCreatedCount.intValue()).getJSONObject("modelInfo") - vnfModelInfoString = vnfModelInfo.toString() - } else { - //TODO: vnfList does not contain data. Need to investigate why ... . Fro VIPR use model stored - vnfModelInfoString = execution.getVariable("vnfModelInfo") - } - - utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) - - // extract cloud configuration - String lcpCloudRegionId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) - utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("tenantId", tenantId) - utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareVnfAndModulesCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Vnf request Section -> increment count - // ******************************* - public void validateVnfCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - Integer vnfsCreatedCount = execution.getVariable("CREVAS_VnfsCreatedCount") - vnfsCreatedCount++ - - execution.setVariable("CREVAS_VnfsCreatedCount", vnfsCreatedCount) - - utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateGenericMacroServiceNetworkVnf ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section -> decrement count - // ******************************* - public void validateNetworkRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - Integer networksCreatedCount = execution.getVariable("CREVAS_NetworksCreatedCount") - networksCreatedCount-- - - execution.setVariable("CREVAS_NetworksCreatedCount", networksCreatedCount) - - execution.setVariable("DCRENI_rollbackData", execution.getVariable("DCRENI_rollbackData"+networksCreatedCount)) - - utils.log("DEBUG", " ***** Completed validateNetworkRollback of CreateGenericMacroServiceNetworkVnf ***** "+" network # "+networksCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkRollback() - " + ex.getMessage() - //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - execution.setVariable("CREVAS_NetworksCreatedCount", 0) - utils.log("ERROR", exceptionMessage, true) - } - } - // ******************************* - // Build DB request Section - // ******************************* -// public void prepareDBRequest (Execution execution) { -// def isDebugEnabled=execution.getVariable("isDebugLogEnabled") -// -// try { -// utils.log("DEBUG", " ***** Inside prepareDBRequest of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) -// -// String requestId = execution.getVariable("CREVAS_requestId") -// String statusMessage = "vIPR ATM Service Instance successfully created." -// String serviceInstanceId = execution.getVariable("CREVAS_serviceInstanceId") -// -// //TODO - verify the format for Service Instance Create, -// String dbRequest = -// """ -// -// + + + + ${requestId} + BPEL + ${serviceInstanceId} + ${serviceInstanceName} + + + + """ + execution.setVariable("CGMSNV_setUpdateDbInstancePayload", payload) + utils.logAudit("CGMSNV_setUpdateDbInstancePayload: " + payload) + logDebug('Exited ' + method, isDebugLogEnabled) + //println("CMSO_updateDBStatusToSuccessPayload --> " + execution.getVariable("CMSO_updateDBStatusToSuccessPayload")) + + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + } + + + public void getDataFromDecomposition (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside getDataFromDecomposition() of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + try { + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + List networkList = serviceDecomposition.getServiceNetworks() + + //utils.log("DEBUG", "got network list: "+ networkList.toString(), isDebugEnabled) + execution.setVariable("networkList", networkList) + execution.setVariable("networkListString", networkList.toString()) + + networkList = execution.getVariable("networkList"); + utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) + + if (networkList != null && networkList.size() > 0) { + + execution.setVariable("CGMSNV_NetworksCount", networkList.size()) + utils.log("DEBUG", "networks to create: "+ networkList.size(), isDebugEnabled) + } else { + execution.setVariable("CGMSNV_NetworksCount", 0) + utils.log("DEBUG", "no networks to create based upon serviceDecomposition content", isDebugEnabled) + } + + // VNFs + List vnfList = serviceDecomposition.getServiceVnfs() + execution.setVariable("vnfList", vnfList) + + String vnfModelInfoString = "" + if (vnfList != null && vnfList.size() > 0) { + execution.setVariable("CGMSNV_VNFsCount", vnfList.size()) + utils.log("DEBUG", "vnfs to create: "+ vnfList.size(), isDebugEnabled) + ModelInfo vnfModelInfo = vnfList[0].getModelInfo() + String vnfModelInfoWithRoot = vnfModelInfo.toString() + vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo") + } else { + execution.setVariable("CGMSNV_VNFsCount", 0) + utils.log("DEBUG", "no vnfs to create based upon Catalog DB response", isDebugEnabled) + } + + execution.setVariable("vnfModelInfo", vnfModelInfoString) + //utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) + + utils.log("DEBUG", " ***** Completed getDataFromDecomposition() of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + sendSyncError(execution) + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. getDataFromDecomposition() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Generate Network request Section + // ******************************* + public void prepareNetworkCreate (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside preparenNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + +// String disableRollback = execution.getVariable("disableRollback") +// def backoutOnFailure = "" +// if(disableRollback != null){ +// if ( disableRollback == true) { +// backoutOnFailure = "false" +// } else if ( disableRollback == false) { +// backoutOnFailure = "true" +// } +// } + //failIfExists - optional + + String createViprServiceRequest = execution.getVariable("createViprServiceRequest") + + JSONArray networkList = execution.getVariable("networkList") + utils.log("DEBUG", "array networkList: "+ networkList, isDebugEnabled) + + if (networkList == null || networkList.size() < 1){ + networkList = new JSONArray(execution.getVariable("networkListString")) + utils.log("DEBUG", "array from string networkList: "+ networkList, isDebugEnabled) + } + + Integer networksCreatedCount = execution.getVariable("CGMSNV_NetworksCreatedCount") + String networkModelInfoString = "" + + if (networkList != null) { + utils.log("DEBUG", " getting model info for network # :" + networksCreatedCount, isDebugEnabled) + ModelInfo networkModelInfo = networkList[networksCreatedCount.intValue()].getModelInfo() + networkModelInfoString = networkModelInfo.toString() + } else { + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected number of networks to create - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + execution.setVariable("networkModelInfo", networkModelInfoString) + utils.log("DEBUG", " networkModelInfoString :" + networkModelInfoString, isDebugEnabled) + +// String networkModelInfo = execution.getVariable("networkModelInfo") + // extract cloud configuration + String lcpCloudRegionId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") + execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) + utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) + String tenantId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.tenantId") + execution.setVariable("tenantId", tenantId) + utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) + + String sdncVersion = execution.getVariable("sdncVersion") + utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) + + List vnfList = execution.getVariable("vnfList") + utils.log("DEBUG", "vnfList: "+ vnfList.toString(), isDebugEnabled) + + String vnfModelInfo = execution.getVariable("vnfModelInfo") + utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) + + networkList = execution.getVariable("networkList") + utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) + + utils.log("DEBUG", " ***** Completed preparenNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareNetworkCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Network request Section -> increment count + // ******************************* + public void validateNetworkCreate (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside validateNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + Integer networksCreatedCount = execution.getVariable("CGMSNV_NetworksCreatedCount") + networksCreatedCount++ + + execution.setVariable("CGMSNV_NetworksCreatedCount", networksCreatedCount) + + execution.setVariable("DCRENI_rollbackData"+networksCreatedCount, execution.getVariable("DCRENI_rollbackData")) + + utils.log("DEBUG", "networksCreatedCount: "+ networksCreatedCount, isDebugEnabled) + utils.log("DEBUG", "DCRENI_rollbackData N : "+ execution.getVariable("DCRENI_rollbackData"+networksCreatedCount), isDebugEnabled) + + JSONArray vnfList = execution.getVariable("vnfList") + utils.log("DEBUG", "vnfList: "+ vnfList, isDebugEnabled) + + String vnfModelInfo = execution.getVariable("vnfModelInfo") + utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) + + JSONArray networkList = execution.getVariable("networkList") + utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) + + utils.log("DEBUG", " ***** Completed validateNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** "+" network # "+networksCreatedCount, isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Generate Network request Section + // ******************************* + public void prepareVnfAndModulesCreate (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + // String disableRollback = execution.getVariable("disableRollback") + // def backoutOnFailure = "" + // if(disableRollback != null){ + // if ( disableRollback == true) { + // backoutOnFailure = "false" + // } else if ( disableRollback == false) { + // backoutOnFailure = "true" + // } + // } + //failIfExists - optional + + String createViprServiceRequest = execution.getVariable("createViprServiceRequest") + String productFamilyId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled) + + List vnfList = execution.getVariable("vnfList") + + Integer vnfsCreatedCount = execution.getVariable("CGMSNV_VnfsCreatedCount") + String vnfModelInfoString = null; + + if (vnfList != null && vnfList.size() > 0 ) { + utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled) + ModelInfo vnfModelInfo1 = vnfList[0].getModelInfo() + utils.log("DEBUG", "got 0 ", isDebugEnabled) + ModelInfo vnfModelInfo = vnfList[vnfsCreatedCount.intValue()].getModelInfo() + vnfModelInfoString = vnfModelInfo.toString() + } else { + //TODO: vnfList does not contain data. Need to investigate why ... . Fro VIPR use model stored + vnfModelInfoString = execution.getVariable("vnfModelInfo") + } + + utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) + + // extract cloud configuration + String lcpCloudRegionId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") + execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) + utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) + String tenantId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.tenantId") + execution.setVariable("tenantId", tenantId) + utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) + + String sdncVersion = execution.getVariable("sdncVersion") + utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) + + utils.log("DEBUG", " ***** Completed prepareVnfAndModulesCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Vnf request Section -> increment count + // ******************************* + public void validateVnfCreate (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + Integer vnfsCreatedCount = execution.getVariable("CGMSNV_VnfsCreatedCount") + vnfsCreatedCount++ + + execution.setVariable("CGMSNV_VnfsCreatedCount", vnfsCreatedCount) + + utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateGenericMacroServiceNetworkVnf ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Network request Section -> decrement count + // ******************************* + public void validateNetworkRollback (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside validateNetworkRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + Integer networksCreatedCount = execution.getVariable("CGMSNV_NetworksCreatedCount") + networksCreatedCount-- + + execution.setVariable("CGMSNV_NetworksCreatedCount", networksCreatedCount) + + execution.setVariable("DCRENI_rollbackData", execution.getVariable("DCRENI_rollbackData"+networksCreatedCount)) + + utils.log("DEBUG", " ***** Completed validateNetworkRollback of CreateGenericMacroServiceNetworkVnf ***** "+" network # "+networksCreatedCount, isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkRollback() - " + ex.getMessage() + //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + execution.setVariable("CGMSNV_NetworksCreatedCount", 0) + utils.log("ERROR", exceptionMessage, true) + } + } + +// public void extractServiceModelInfo (Execution execution) { +// def isDebugEnabled = execution.getVariable("isDebugLogEnabled") +// String msg = "" +// utils.log("DEBUG"," ***** extractServiceModelInfo of CreateGenericMacroServiceNetworkVnf *****", isDebugEnabled) +// +// try { +// +// // check for input +// String requestId = execution.getVariable("msoRequestId") +// +// ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") +// ModelInfo modelInfo = serviceDecomposition.getModelInfo() +// +// utils.log("DEBUG", "modelInfo: "+ modelInfo.toJsonString(), isDebugEnabled) +// utils.log("DEBUG", "modelInfo: "+ modelInfo, isDebugEnabled) +// execution.setVariable("serviceDecomposition", modelInfo) +// +// utils.log("DEBUG"," ***** Exit extractServiceModelInfo of CreateGenericMacroServiceNetworkVnf *****", isDebugEnabled) +// +// } catch (BpmnError e) { +// throw e; +// } catch (Exception ex){ +// msg = "Exception in extractServiceModelInfo " + ex.getMessage() +// utils.log("DEBUG", msg, isDebugEnabled) +// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) +// } +// utils.log("DEBUG"," ***** Exit extractServiceModelInfo of DecomposeService *****", isDebugEnabled) +// } + + // ******************************* + // Build DB request Section + // ******************************* +// public void prepareDBRequest (Execution execution) { +// def isDebugEnabled=execution.getVariable("isDebugLogEnabled") +// +// try { +// utils.log("DEBUG", " ***** Inside prepareDBRequest of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) +// +// String requestId = execution.getVariable("CGMSNV_requestId") +// String statusMessage = "vIPR ATM Service Instance successfully created." +// String serviceInstanceId = execution.getVariable("CGMSNV_serviceInstanceId") +// +// //TODO - verify the format for Service Instance Create, +// String dbRequest = +// """ +// +// // -// ${requestId} -// BPMN -// ${statusMessage} -// -// COMPLETED -// 100 -// -// ${serviceInstanceId} -// -// -// """ -// -// String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) -// execution.setVariable("CREVAS_createDBRequest", buildDeleteDBRequestAsString) -// utils.logAudit(buildDeleteDBRequestAsString) -// -// utils.log("DEBUG", " ***** Completed prepareDBRequest of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) -// } catch (Exception ex) { -// // try error in method block -// String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage() -// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) -// -// } -// -// } - - - // ***************************************** - // Prepare Completion request Section - // ***************************************** - public void postProcessResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside postProcessResponse of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - String source = execution.getVariable("source") - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - String msoCompletionRequest = +// ${requestId} +// BPMN +// ${statusMessage} +// +// COMPLETED +// 100 +// +// ${serviceInstanceId} +// +// +// """ +// +// String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) +// execution.setVariable("CGMSNV_createDBRequest", buildDeleteDBRequestAsString) +// utils.logAudit(buildDeleteDBRequestAsString) +// +// utils.log("DEBUG", " ***** Completed prepareDBRequest of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) +// } catch (Exception ex) { +// // try error in method block +// String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage() +// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) +// +// } +// +// } + + + // ***************************************** + // Prepare Completion request Section + // ***************************************** + public void postProcessResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside postProcessResponse of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + try { + String source = execution.getVariable("source") + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String msoCompletionRequest = """ - ${requestId} - CREATE - ${source} - - Service Instance has been created successfully via macro orchestration - ${serviceInstanceId} - BPMN macro create - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable("CREVAS_Success", true) - execution.setVariable("CREVAS_CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void preProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - try { - - Object workflowException = execution.getVariable("WorkflowException"); - - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); - } - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) - } catch(Exception ex) { - String msg = "Exception in preProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit preProcessRollback of CreateGenericMacroServiceNetworkVnf *** ", isDebugEnabled) - } - - public void postProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - String msg = "" - try { - Object workflowException = execution.getVariable("prevWorkflowException"); - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) - execution.setVariable("WorkflowException", workflowException); - } - } catch (BpmnError b) { - utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) - throw b; - } catch(Exception ex) { - msg = "Exception in postProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit postProcessRollback of CreateGenericMacroServiceNetworkVnf *** ", isDebugEnabled) - } - - public void prepareFalloutRequest(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " *** STARTED CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestInfo = execution.getVariable("CREVAS_requestInfo") - utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) - - //TODO. hmmm. there is no way to UPDATE error message. -// String errorMessage = wfex.getErrorMessage() -// boolean successIndicator = execution.getVariable("DCRESI_rollbackSuccessful") -// if (successIndicator){ -// errorMessage = errorMessage + ". Rollback successful." -// } else { -// errorMessage = errorMessage + ". Rollback not completed." -// } - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - - execution.setVariable("CREVAS_falloutRequest", falloutRequest) - - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process") - } - utils.log("DEBUG", "*** COMPLETED CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process ***", isDebugEnabled) - } - - - public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncError() of CreateServiceInstanceInfra ***** ", isDebugEnabled) - - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = + ${requestId} + CREATE + ${source} + + Service Instance has been created successfully via macro orchestration + ${serviceInstanceId} + BPMN macro create + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + utils.logAudit(xmlMsoCompletionRequest) + execution.setVariable("CGMSNV_Success", true) + execution.setVariable("CGMSNV_CompleteMsoProcessRequest", xmlMsoCompletionRequest) + utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void preProcessRollback (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** preProcessRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + try { + + Object workflowException = execution.getVariable("WorkflowException"); + + if (workflowException instanceof WorkflowException) { + utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) + execution.setVariable("prevWorkflowException", workflowException); + //execution.setVariable("WorkflowException", null); + } + } catch (BpmnError e) { + utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) + } catch(Exception ex) { + String msg = "Exception in preProcessRollback. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + } + utils.log("DEBUG"," *** Exit preProcessRollback of CreateGenericMacroServiceNetworkVnf *** ", isDebugEnabled) + } + + public void postProcessRollback (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** postProcessRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + String msg = "" + try { + Object workflowException = execution.getVariable("prevWorkflowException"); + if (workflowException instanceof WorkflowException) { + utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) + execution.setVariable("WorkflowException", workflowException); + } + } catch (BpmnError b) { + utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) + throw b; + } catch(Exception ex) { + msg = "Exception in postProcessRollback. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + } + utils.log("DEBUG"," *** Exit postProcessRollback of CreateGenericMacroServiceNetworkVnf *** ", isDebugEnabled) + } + + public void prepareFalloutRequest(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " *** STARTED CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process *** ", isDebugEnabled) + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) + String requestInfo = execution.getVariable("CGMSNV_requestInfo") + utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) + + //TODO. hmmm. there is no way to UPDATE error message. +// String errorMessage = wfex.getErrorMessage() +// boolean successIndicator = execution.getVariable("DCRESI_rollbackSuccessful") +// if (successIndicator){ +// errorMessage = errorMessage + ". Rollback successful." +// } else { +// errorMessage = errorMessage + ". Rollback not completed." +// } + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + + execution.setVariable("CGMSNV_falloutRequest", falloutRequest) + + } catch (Exception ex) { + utils.log("DEBUG", "Error Occured in CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process") + } + utils.log("DEBUG", "*** COMPLETED CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process ***", isDebugEnabled) + } + + + public void sendSyncError (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + utils.log("DEBUG", " ***** Inside sendSyncError() of CreateServiceInstanceInfra ***** ", isDebugEnabled) + + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = """ - ${errorMessage} - 7000 - """ - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - } - - public void processJavaException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("CRESI_unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") - }catch(BpmnError b){ - utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("CRESI_unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") - } - utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) - } + ${errorMessage} + 7000 + """ + + utils.logAudit(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + } catch (Exception ex) { + utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) + } + } + + public void processJavaException(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + try{ + utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) + utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) + utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) + execution.setVariable("CRESI_unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") + }catch(BpmnError b){ + utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) + execution.setVariable("CRESI_unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") + } + utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) + } } \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateServiceInstance.groovy deleted file mode 100644 index 2205ffd696..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateServiceInstance.groovy +++ /dev/null @@ -1,262 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts; - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -/** - * This groovy class supports the CreateServiceInstance.bpmn process. - * AlaCarte flow for 1702 ServiceInstance Create - * - */ -public class CreateServiceInstance extends AbstractServiceTaskProcessor { - String Prefix="CRESI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - String msg = "" - utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled) - - try { - - String siRequest = execution.getVariable("bpmnRequest") - utils.logAudit(siRequest) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)) { - serviceInstanceId = UUID.randomUUID().toString() - } - utils.log("DEBUG", "Generated new Service Instance:" + serviceInstanceId, isDebugEnabled) - 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" - utils.log("DEBUG", msg, isDebugEnabled) - //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" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("serviceModelInfo", serviceModelInfo) - } - - utils.log("DEBUG", "modelInfo" + serviceModelInfo, isDebugEnabled) - - //requestParameters - String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - //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() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) - - 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() - utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + createServiceRestRequest, isDebugEnabled) - sendWorkflowResponse(execution, 202, createServiceRestRequest) - execution.setVariable("sentSyncResponse", true) - - } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } - - - public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncError *** ", isDebugEnabled) - - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """ - ${errorMessage} - 7000 - """ - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - - } - - public void prepareCompletionRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String source = execution.getVariable("source") - - String msoCompletionRequest = - """ - - ${requestId} - CREATE - ${source} - - Service Instance was created successfully. - ${serviceInstanceId} - CreateServiceInstance - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - execution.setVariable("completionRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String msg = " Exception in prepareCompletion:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled) - } - - public void prepareFalloutRequest(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareFalloutRequest *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String requestInfo = - """ - ${requestId} - CREATE - ${source} - """ - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - execution.setVariable("falloutRequest", falloutRequest) - } catch (Exception ex) { - utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled) - String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - String requestId = execution.getVariable("msoRequestId") - String falloutRequest = - """ - - ${requestId} - CREATE - VID - - - ${errorException} - 7000 - - """ - - execution.setVariable("falloutRequest", falloutRequest) - } - utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled) - } -} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index 573deb4155..b468a5116c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -1,42 +1,45 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts; +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.infrastructure.scripts; import groovy.json.JsonSlurper +import groovy.json.JsonOutput import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution import org.apache.commons.lang3.* -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils; -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException - -public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; +import org.openecomp.mso.bpmn.common.scripts.NetworkUtils; +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils; +import org.openecomp.mso.bpmn.common.scripts.VidUtils; +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils + +public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + /** * Validates the request message and sets up the workflow. * @param execution the execution @@ -71,73 +74,160 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { // check if request is xml or json try { def jsonSlurper = new JsonSlurper() + def jsonOutput = new JsonOutput() Map reqMap = jsonSlurper.parseText(incomingRequest) utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled) def serviceInstanceId = execution.getVariable('serviceInstanceId') def vnfId = execution.getVariable('vnfId') - - def vidUtils = new VidUtils(this) - - String requestInXmlFormat = vidUtils.createXmlVfModuleRequest(execution, reqMap, 'CREATE_VF_MODULE', serviceInstanceId) - - utils.log("DEBUG", " Request in XML format: " + requestInXmlFormat, isDebugLogEnabled) - - execution.setVariable(prefix + 'Request', requestInXmlFormat) + + execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId) execution.setVariable(prefix+'vnfId', vnfId) execution.setVariable("isVidRequest", "true") - - } - catch(groovy.json.JsonException je) { - utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled) - 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) - utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest") - } - - try { - String request = validateInfraRequest(execution) + + def vnfName = '' + def asdcServiceModelVersion = '' + def serviceModelInfo = null + def vnfModelInfo = null + + def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList + + if (relatedInstanceList != null) { + relatedInstanceList.each { + if (it.relatedInstance.modelInfo?.modelType == 'service') { + asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion + serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo) + + } + if (it.relatedInstance.modelInfo.modelType == 'vnf') { + vnfName = it.relatedInstance.instanceName ?: '' + vnfModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo) + } + } + } + + execution.setVariable(prefix + 'vnfName', vnfName) + execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion) + execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo) + execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo) + + + def vnfType = execution.getVariable('vnfType') + execution.setVariable(prefix + 'vnfType', vnfType) + def vfModuleId = execution.getVariable('vfModuleId') + execution.setVariable(prefix + 'vfModuleId', vfModuleId) + def volumeGroupId = execution.getVariable('volumeGroupId') + execution.setVariable(prefix + 'volumeGroupId', volumeGroupId) + def userParams = reqMap.requestDetails?.requestParameters?.userParams + + Map userParamsMap = [:] + if (userParams != null) { + userParams.each { userParam -> + userParamsMap.put(userParam.name, userParam.value) + } + } + + utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled) + + execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap) + + def isBaseVfModule = "false" + if (execution.getVariable('isBaseVfModule') == true) { + isBaseVfModule = "true" + } + + execution.setVariable(prefix + 'isBaseVfModule', isBaseVfModule) + + def requestId = execution.getVariable("mso-request-id") + execution.setVariable(prefix + 'requestId', requestId) + + def vfModuleModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo) + execution.setVariable(prefix + 'vfModuleModelInfo', vfModuleModelInfo) + + def suppressRollback = reqMap.requestDetails?.requestInfo?.suppressRollback + + + def backoutOnFailure = "" + if(suppressRollback != null){ + if ( suppressRollback == true) { + backoutOnFailure = "false" + } else if ( suppressRollback == false) { + backoutOnFailure = "true" + } + } + + execution.setVariable(prefix + '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("CreateVfModuleInfraSuccessIndicator", false) execution.setVariable("RollbackCompleted", false) - execution.setVariable("DoCreateVfModuleRequest", request) + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) - execution.setVariable("CVFMI_requestInfo",utils.getNodeXml(request,"request-info")) - execution.setVariable("CVFMI_requestId",utils.getNodeText1(request,"request-id")) - execution.setVariable("CVFMI_source",utils.getNodeText1(request,"source")) - execution.setVariable("CVFMI_serviceInstanceId", utils.getNodeText1(request, "service-instance-id")) - execution.setVariable("CVFMI_vnfInputs",utils.getNodeXml(request,"vnf-inputs")) + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable("CVFMI_source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${requestId} + CREATE + ${source} + """ + + execution.setVariable("CVFMI_requestInfo", requestInfo) + //backoutOnFailure - NetworkUtils networkUtils = new NetworkUtils() - execution.setVariable("CVFMI_rollbackEnabled", networkUtils.isRollbackEnabled(execution,request)) + //NetworkUtils networkUtils = new NetworkUtils() + //execution.setVariable("CVFMI_rollbackEnabled", networkUtils.isRollbackEnabled(execution,request)) execution.setVariable("CVFMI_originalWorkflowException", null) - def vnfParams = "" - if (utils.nodeExists(request, "vnf-params")) { - vnfParams = utils.getNodeXml(request,"vnf-params") - } - execution.setVariable("CVFMI_vnfParams", vnfParams) + def newVfModuleId = UUID.randomUUID().toString() execution.setVariable("newVfModuleId", newVfModuleId) + execution.setVariable(prefix + 'vfModuleId', newVfModuleId) - logDebug('RequestInfo: ' + execution.getVariable("CVFMI_requestInfo"), isDebugLogEnabled) - logDebug('VnfInputs: ' + execution.getVariable("CVFMI_vnfInputs"), isDebugLogEnabled) - logDebug('VnfParams: ' + execution.getVariable("CVFMI_vnfParams"), isDebugLogEnabled) + logDebug('RequestInfo: ' + execution.getVariable("CVFMI_requestInfo"), isDebugLogEnabled) + logDebug('rollbackEnabled: ' + execution.getVariable("CVFMI_rollbackEnabled"), isDebugLogEnabled) logDebug('Exited ' + method, isDebugLogEnabled) } catch (BpmnError bpmnError) { throw bpmnError - } catch (Exception exception) { + } + catch(groovy.json.JsonException je) { + utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled) + 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) + utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest") } + } /** @@ -168,16 +258,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { try { def requestInfo = execution.getVariable('CVFMI_requestInfo') def requestId = execution.getVariable('CVFMI_requestId') - def source = execution.getVariable('CVFMI_source') - def progress = getNodeTextForce(requestInfo, 'progress') - if (progress.isEmpty()) { - progress = '0' - } - def startTime = getNodeTextForce(requestInfo, 'start-time') - if (startTime.isEmpty()) { - startTime = System.currentTimeMillis() - } - + 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() @@ -202,9 +284,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", " ======== STARTED PostProcessResponse Process ======== ", isDebugEnabled) - try{ - def request = execution.getVariable("DoCreateVfModuleRequest") - def requestInfo = utils.getNodeXml(request, 'request-info', false) + try{ + def requestInfo = execution.getVariable("CVFMI_requestInfo") def action = utils.getNodeText1(requestInfo, "action") utils.log("DEBUG", "requestInfo is: " + requestInfo, isDebugEnabled) @@ -223,10 +304,10 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { } String payload = - """ - + """ + ${requestInfo} Vf Module has been created successfully. @@ -292,7 +373,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { /* - def requestId = execution.getVariable("mso-request-id") + def requestId = execution.getVariable("mso-request-id") if (requestId == null) { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id") @@ -300,7 +381,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { setVariable(execution, prefix + 'requestId', requestId) - def serviceInstanceId = execution.getVariable("mso-service-instance-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") @@ -325,14 +406,16 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { utils.log("DEBUG", " ======== STARTED prepareUpdateInfraRequest Process ======== ", isDebugEnabled) try{ - - String vnfInputs = execution.getVariable("CVFMI_vnfInputs") - String requestInfo = execution.getVariable("CVFMI_requestInfo") - def aicCloudRegion = utils.getNodeText1(vnfInputs, "aic-cloud-region") - def tenantId = utils.getNodeText1(vnfInputs, "tenant-id") + + + String requestInfo = execution.getVariable("CVFMI_requestInfo") + def aicCloudRegion = execution.getVariable("CVFMI_lcpCloudRegionId") + def tenantId = execution.getVariable("CVFMI_tenantId") def requestId = utils.getNodeText1(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 = execution.getVariable("URN_mso_adapters_db_endpoint") execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) @@ -352,18 +435,19 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { String payload = """ + xmlns:ns="http://org.openecomp.mso/requestsdb"> - + ${requestId} BPMN VF Module successfully created COMPLETE 100 - <vnf-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"><vnf-id>${vnfId}</vnf-id><vf-module-id>${vfModuleId}</vf-module-id></vnf-outputs> + <vnf-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"><vnf-id>${vnfId}</vnf-id><vf-module-id>${vfModuleId}</vf-module-id></vnf-outputs> ${vfModuleId} + ${vfModuleName} """ @@ -396,9 +480,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { try { - def WorkflowException workflowException = execution.getVariable("WorkflowException") - def request = execution.getVariable("DoCreateVfModuleRequest") - def requestInformation = utils.getNodeXml(request, 'request-info', false) + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def requestInformation = execution.getVariable("CVFMI_requestInfo") def errorResponseCode = workflowException.getErrorCode() def errorResponseMsg = workflowException.getErrorMessage() def encErrorResponseMsg = "" @@ -407,10 +490,10 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { } String content = """ - + ${requestInformation} ${encErrorResponseMsg} @@ -458,6 +541,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { execution.setVariable("RollbackCompleted", true) } + + } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy index 289e185522..48ca2905c1 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy @@ -1,304 +1,303 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts - -import org.openecomp.mso.bpmn.common.scripts.AaiUtil; -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse - -import groovy.json.JsonSlurper - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution; -import org.apache.commons.lang3.* - -class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { - - public static final String prefix='CVMVINFRAV1_' - - /** - * Perform initial processing, such as request validation, initialization of variables, etc. - * * @param execution - */ - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - preProcessRequest(execution, isDebugEnabled) - } - - - /** - * Perform initial processing, such as request validation, initialization of variables, etc. - * @param execution - * @param isDebugEnabled - */ - public void preProcessRequest (Execution execution, isDebugEnabled) { - - execution.setVariable("prefix",prefix) - setSuccessIndicator(execution, false) - execution.setVariable(prefix+'syncResponseSent', false) - - String createVolumeIncoming = validateRequest(execution, 'vnfId') - utils.logAudit(createVolumeIncoming) - - try { - def jsonSlurper = new JsonSlurper() - Map reqMap = jsonSlurper.parseText(createVolumeIncoming) - - def serviceInstanceId = execution.getVariable('serviceInstanceId') - def vnfId = execution.getVariable('vnfId') - - def vidUtils = new VidUtils(this) - createVolumeIncoming = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', serviceInstanceId) - - execution.setVariable(prefix+'Request', createVolumeIncoming) - execution.setVariable(prefix+'vnfId', vnfId) - execution.setVariable(prefix+'isVidRequest', true) - - utils.log("DEBUG", "XML request:\n" + createVolumeIncoming, isDebugEnabled) - - } - catch(groovy.json.JsonException je) { - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'Request is not a valid JSON document') - } - - execution.setVariable(prefix+'source', utils.getNodeText1(createVolumeIncoming, "source")) - execution.setVariable(prefix+'volumeGroupName', utils.getNodeText1(createVolumeIncoming, 'volume-group-name')) - execution.setVariable(prefix+'volumeOutputs', utils.getNodeXml(createVolumeIncoming, 'volume-outputs', false)) - - execution.setVariable(prefix+'serviceType', 'service-instance') - execution.setVariable(prefix+'serviceInstanceId', utils.getNodeText1(createVolumeIncoming, "service-instance-id")) - - // Generate volume group id - String volumeGroupId = UUID.randomUUID() - utils.log("DEBUG", "Generated volume group id: " + volumeGroupId, isDebugEnabled) - - def testGroupId = execution.getVariable('test-volume-group-id') - if (testGroupId != null && testGroupId.trim() != '') { - volumeGroupId = testGroupId - } - - execution.setVariable(prefix+'volumeGroupId', volumeGroupId) - - } - - - public void sendSyncResponse (Execution execution, isDebugEnabled) { - def volumeGroupId = execution.getVariable(prefix+'volumeGroupId') - def requestId = execution.getVariable("mso-request-id") - def serviceInstanceId = execution.getVariable("serviceInstanceId") - - String syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", "Sync Response: " + "\n" + syncResponse, isDebugEnabled) - sendWorkflowResponse(execution, 200, syncResponse) - - execution.setVariable(prefix+'syncResponseSent', true) - } - - - public void sendSyncError (Execution 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(Execution execution, int errorCode, errorMessage, isDebugEnabled) { - utils.log("DEBUG", errorMessage, isDebugEnabled) - (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage) - } - - - public void prepareDbInfraSuccessRequest(Execution execution, isDebugEnabled) { - ExceptionUtil exceptionUtil = new ExceptionUtil() - def dbVnfOutputs = execution.getVariable(prefix+'volumeOutputs') - def requestId = execution.getVariable('mso-request-id') - def statusMessage = "VolumeGroup successfully created." - def requestStatus = "COMPLETED" - def progress = "100" - - try { - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - /* - from: $gVolumeGroup/aai:volume-group-id/text() - to: vnfreq:volume-outputs/vnfreq:volume-group-id - */ - // for now assume, generated volumeGroupId is accepted - def volumeGroupId = execution.getVariable(prefix+'volumeGroupId') - - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - ${requestStatus} - ${progress} - ${dbVnfOutputs} - ${volumeGroupId} - - - """ - - String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) - execution.setVariable(prefix+"createDBRequest", buildDeleteDBRequestAsString) - - utils.logAudit(buildDeleteDBRequestAsString) - } - - - - - - public void postProcessResponse (Execution execution, isDebugEnabled) { - - def dbReturnCode = execution.getVariable(prefix+'dbReturnCode') - def createDBResponse = execution.getVariable(prefix+'createDBResponse') - - utils.logAudit('DB return code: ' + dbReturnCode) - utils.logAudit('DB response: ' + createDBResponse) - - def requestId = execution.getVariable("mso-request-id") - def source = execution.getVariable(prefix+'source') - - String msoCompletionRequest = - """ - - ${requestId} - CREATE - ${source} - - Volume Group has been created successfully. - BPMN VF Module Volume action: CREATE - """ - - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - utils.logAudit(createDBResponse) - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable(prefix+'Success', true) - execution.setVariable(prefix+'CompleteMsoProcessRequest', xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } - - public void prepareFalloutHandlerRequest(Execution 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 = - """ - - ${requestId} - CREATE - ${source} - - - ${errorMessage} - ${errorCode} - - - """ - - // Format Response - String xmlHandlerRequest = utils.formatXml(falloutHandlerRequest) - utils.logAudit(xmlHandlerRequest) - - execution.setVariable(prefix+'FalloutHandlerRequest', xmlHandlerRequest) - utils.log("ERROR", "Overall Error Response going to FalloutHandler: " + "\n" + xmlHandlerRequest, isDebugEnabled) - } - - - /** - * Query AAI service instance - * @param execution - * @param isDebugEnabled - */ - public void callRESTQueryAAIServiceInstance(Execution execution, isDebugEnabled) { - - def request = execution.getVariable(prefix+"Request") - def serviceInstanceId = utils.getNodeText1(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 - utils.logAudit("AAI query service instance request: " + queryAAIRequest) - - APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) - - String returnCode = response.getStatusCode() - String aaiResponseAsString = response.getResponseBodyAsString() - aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) - - utils.logAudit("AAI query service instance return code: " + returnCode) - utils.logAudit("AAI query service instance response: " + aaiResponseAsString) - - utils.log("DEBUG", "AAI query service instance return code: " + returnCode, isDebugEnabled) - utils.log("DEBUG", "AAI query service instance response: " + aaiResponseAsString, isDebugEnabled) - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - if (returnCode=='200') { - utils.log("DEBUG", 'Service instance ' + serviceInstanceId + ' found in AAI.', isDebugEnabled) - } else { - if (returnCode=='404') { - def message = 'Service instance ' + serviceInstanceId + ' was not found in AAI. Return code: 404.' - utils.log("DEBUG", message, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message) - } else { - WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - throw new BpmnError("MSOWorkflowException") - } - } - } -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.infrastructure.scripts + +import org.openecomp.mso.bpmn.common.scripts.AaiUtil; +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; +import org.openecomp.mso.bpmn.common.scripts.VidUtils; +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse + +import groovy.json.JsonSlurper + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution; +import org.apache.commons.lang3.* + +class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { + + public static final String prefix='CVMVINFRAV1_' + + /** + * Perform initial processing, such as request validation, initialization of variables, etc. + * * @param execution + */ + public void preProcessRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + preProcessRequest(execution, isDebugEnabled) + } + + + /** + * Perform initial processing, such as request validation, initialization of variables, etc. + * @param execution + * @param isDebugEnabled + */ + public void preProcessRequest (Execution execution, isDebugEnabled) { + + execution.setVariable("prefix",prefix) + setSuccessIndicator(execution, false) + execution.setVariable(prefix+'syncResponseSent', false) + + String createVolumeIncoming = validateRequest(execution, 'vnfId') + utils.logAudit(createVolumeIncoming) + + try { + def jsonSlurper = new JsonSlurper() + Map reqMap = jsonSlurper.parseText(createVolumeIncoming) + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def vnfId = execution.getVariable('vnfId') + + def vidUtils = new VidUtils(this) + createVolumeIncoming = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', serviceInstanceId) + + execution.setVariable(prefix+'Request', createVolumeIncoming) + execution.setVariable(prefix+'vnfId', vnfId) + execution.setVariable(prefix+'isVidRequest', true) + + utils.log("DEBUG", "XML request:\n" + createVolumeIncoming, isDebugEnabled) + + } + catch(groovy.json.JsonException je) { + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'Request is not a valid JSON document') + } + + execution.setVariable(prefix+'source', utils.getNodeText1(createVolumeIncoming, "source")) + execution.setVariable(prefix+'volumeGroupName', utils.getNodeText1(createVolumeIncoming, 'volume-group-name')) + execution.setVariable(prefix+'volumeOutputs', utils.getNodeXml(createVolumeIncoming, 'volume-outputs', false)) + + execution.setVariable(prefix+'serviceType', 'service-instance') + execution.setVariable(prefix+'serviceInstanceId', utils.getNodeText1(createVolumeIncoming, "service-instance-id")) + + // Generate volume group id + String volumeGroupId = UUID.randomUUID() + utils.log("DEBUG", "Generated volume group id: " + volumeGroupId, isDebugEnabled) + + def testGroupId = execution.getVariable('test-volume-group-id') + if (testGroupId != null && testGroupId.trim() != '') { + volumeGroupId = testGroupId + } + + execution.setVariable(prefix+'volumeGroupId', volumeGroupId) + + } + + + public void sendSyncResponse (Execution execution, isDebugEnabled) { + def volumeGroupId = execution.getVariable(prefix+'volumeGroupId') + def requestId = execution.getVariable("mso-request-id") + def serviceInstanceId = execution.getVariable("serviceInstanceId") + + String syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim() + + utils.log("DEBUG", "Sync Response: " + "\n" + syncResponse, isDebugEnabled) + sendWorkflowResponse(execution, 200, syncResponse) + + execution.setVariable(prefix+'syncResponseSent', true) + } + + + public void sendSyncError (Execution 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(Execution execution, int errorCode, errorMessage, isDebugEnabled) { + utils.log("DEBUG", errorMessage, isDebugEnabled) + (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage) + } + + + public void prepareDbInfraSuccessRequest(Execution execution, isDebugEnabled) { + def dbVnfOutputs = execution.getVariable(prefix+'volumeOutputs') + def requestId = execution.getVariable('mso-request-id') + def statusMessage = "VolumeGroup successfully created." + def requestStatus = "COMPLETED" + def progress = "100" + + try { + String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") + utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) + + def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) + execution.setVariable("BasicAuthHeaderValueDB",encodedString) + } catch (IOException ex) { + String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() + utils.log("DEBUG", dataErrorMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + /* + from: $gVolumeGroup/aai:volume-group-id/text() + to: vnfreq:volume-outputs/vnfreq:volume-group-id + */ + // for now assume, generated volumeGroupId is accepted + def volumeGroupId = execution.getVariable(prefix+'volumeGroupId') + + String dbRequest = + """ + + + + ${requestId} + BPMN + ${statusMessage} + + ${requestStatus} + ${progress} + ${dbVnfOutputs} + ${volumeGroupId} + + + """ + + String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) + execution.setVariable(prefix+"createDBRequest", buildDeleteDBRequestAsString) + + utils.logAudit(buildDeleteDBRequestAsString) + } + + + + + + public void postProcessResponse (Execution execution, isDebugEnabled) { + + def dbReturnCode = execution.getVariable(prefix+'dbReturnCode') + def createDBResponse = execution.getVariable(prefix+'createDBResponse') + + utils.logAudit('DB return code: ' + dbReturnCode) + utils.logAudit('DB response: ' + createDBResponse) + + def requestId = execution.getVariable("mso-request-id") + def source = execution.getVariable(prefix+'source') + + String msoCompletionRequest = + """ + + ${requestId} + CREATE + ${source} + + Volume Group has been created successfully. + BPMN VF Module Volume action: CREATE + """ + + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + utils.logAudit(createDBResponse) + utils.logAudit(xmlMsoCompletionRequest) + execution.setVariable(prefix+'Success', true) + execution.setVariable(prefix+'CompleteMsoProcessRequest', xmlMsoCompletionRequest) + utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) + + } + + public void prepareFalloutHandlerRequest(Execution 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 = + """ + + ${requestId} + CREATE + ${source} + + + ${errorMessage} + ${errorCode} + + + """ + + // Format Response + String xmlHandlerRequest = utils.formatXml(falloutHandlerRequest) + utils.logAudit(xmlHandlerRequest) + + execution.setVariable(prefix+'FalloutHandlerRequest', xmlHandlerRequest) + utils.log("ERROR", "Overall Error Response going to FalloutHandler: " + "\n" + xmlHandlerRequest, isDebugEnabled) + } + + + /** + * Query AAI service instance + * @param execution + * @param isDebugEnabled + */ + public void callRESTQueryAAIServiceInstance(Execution execution, isDebugEnabled) { + + def request = execution.getVariable(prefix+"Request") + def serviceInstanceId = utils.getNodeText1(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 + utils.logAudit("AAI query service instance request: " + queryAAIRequest) + + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) + + String returnCode = response.getStatusCode() + String aaiResponseAsString = response.getResponseBodyAsString() + aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) + + utils.logAudit("AAI query service instance return code: " + returnCode) + utils.logAudit("AAI query service instance response: " + aaiResponseAsString) + + utils.log("DEBUG", "AAI query service instance return code: " + returnCode, isDebugEnabled) + utils.log("DEBUG", "AAI query service instance response: " + aaiResponseAsString, isDebugEnabled) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + if (returnCode=='200') { + utils.log("DEBUG", 'Service instance ' + serviceInstanceId + ' found in AAI.', isDebugEnabled) + } else { + if (returnCode=='404') { + def message = 'Service instance ' + serviceInstanceId + ' was not found in AAI. Return code: 404.' + utils.log("DEBUG", message, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message) + } else { + WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) + throw new BpmnError("MSOWorkflowException") + } + } + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy index 6168acde44..9b7fd6835c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy @@ -205,76 +205,6 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { utils.log("DEBUG", "*** COMPLETED CreateVnfInfra SendSyncResponse Process ***", isDebugEnabled) } - public void prepareCreateGenericVnf (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED CreateVnfInfra PrepareCreateGenericVnf Process *** ", isDebugEnabled) - try { - //Get Vnf Info - String vnfId = execution.getVariable("CREVI_vnfId") - def vnfName = execution.getVariable("CREVI_vnfName") - def vnfType = execution.getVariable("CREVI_vnfType") - def serviceId = execution.getVariable("CREVI_serviceId") - def orchStatus = execution.getVariable("CREVI_orchStatus") - def modelInvariantId = execution.getVariable("CREVI_modelInvariantId") - def modelVersion = execution.getVariable("CREVI_modelVersion") - // TODO: 1702 Variable - def equipmentRole = execution.getVariable("CREVI_equipmentRole") - - //Get Service Instance Info - def serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId") - String siRelatedLink = execution.getVariable("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) - - //Get Namespace - AaiUtil aaiUtil = new AaiUtil(this) - def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) - String namespace = aaiUtil.getNamespaceFromUri(aai_uri) - - String payload = - """ - ${vnfId} - ${vnfName} - ${serviceId} - ${vnfType} - ${orchStatus} - ${modelInvariantId} - ${modelVersion} - - - service-instance - ${siRelatedLink} - - customer.global-customer-id - ${globalCustId} - - - service-subscription.service-type - ${serviceType} - - - service-instance.service-instance-id - ${serviceInstanceId} - - - - """ - - execution.setVariable("CREVI_genericVnfPayload", payload) - - }catch(Exception ex) { - utils.log("DEBUG", "Error Occured in CreateVnfInfra PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra PrepareCreateGenericVnf Process") - } - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PrepareCreateGenericVnf Process ***", isDebugEnabled) - } public void preProcessSDNCAssignRequest(Execution execution){ def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DelServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DelServiceInstance.groovy deleted file mode 100644 index aad0693948..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DelServiceInstance.groovy +++ /dev/null @@ -1,353 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.bpmn.infrastructure.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; - -import java.util.UUID; -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.json.JSONObject; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -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 static org.apache.commons.lang3.StringUtils.*; - -import org.springframework.web.util.UriUtils; - -/** - * This groovy class supports the DelServiceInstance.bpmn process. - * - */ -public class DelServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="DELSI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - String msg = "" - - utils.log("DEBUG", " *** preProcessRequest Request *** ", isDebugEnabled) - - try { - // check for incoming json message/input - String siRequest = execution.getVariable("bpmnRequest") - utils.logAudit(siRequest) - - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled) - - 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" - utils.log("DEBUG", msg, isDebugEnabled) - } else - { - execution.setVariable("serviceModelInfo", serviceModelInfo) - //utils.log("DEBUG", "modelInfo" + serviceModelInfo, isDebugEnabled) - } - - //requestInfo - String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId") - if (isBlank(productFamilyId)) - { - msg = "Input productFamilyId is null" - utils.log("DEBUG", msg, isDebugEnabled) - //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" - utils.log("DEBUG", msg, isDebugEnabled) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //requestParameters - String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - utils.log("DEBUG", msg, isDebugEnabled) - //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) - - 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() - utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) - sendWorkflowResponse(execution, 202, syncResponse) - - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse: " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } - - public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncError *** ", isDebugEnabled) - - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """ - ${errorMessage} - 7000 - """ - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - - } - - public void prepareCompletionRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String msoCompletionRequest = - """ - - ${requestId} - DELETE - ${source} - - Service Instance was deleted successfully. - DelServiceInstance - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - execution.setVariable("completionRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String msg = " Exception in prepareCompletion:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled) - } - - public void prepareFalloutRequest(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareFalloutRequest *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String requestInfo = - """ - ${requestId} - DELETE - ${source} - """ - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - execution.setVariable("falloutRequest", falloutRequest) - } catch (Exception ex) { - utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled) - String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - String requestId = execution.getVariable("msoRequestId") - String falloutRequest = - """ - - ${requestId} - DELETE - VID - - - ${errorException} - 7000 - - """ - - execution.setVariable("falloutRequest", falloutRequest) - } - utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled) - } - - - // ******************************* - // Build DB request Section - // ******************************* - public void prepareDBRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequest of DeleteServiceInstance ***** ", isDebugEnabled) - - String requestId = execution.getVariable("DELSI_requestId") - String statusMessage = "Service Instance successfully deleted." - - //TODO - verify the format for Service Instance Delete, - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - COMPLETED - 100 - - - """ - - String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) - execution.setVariable("DELSI_createDBRequest", buildDeleteDBRequestAsString) - utils.logAudit(buildDeleteDBRequestAsString) - - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - // ******************************* - // Build Error Section - // ******************************* - public void prepareDBRequestError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteServiceInstanceInfra ***** ", isDebugEnabled) - - 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 DeleteServiceInstanceInfra proccessing. " - } - - //TODO - verify the format for Service Instance Create, - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - FAILED - - - """ - - String buildDBRequestAsString = utils.formatXml(dbRequest) - execution.setVariable("DELSI_createDBInfraErrorRequest", buildDBRequestAsString) - utils.logAudit(buildDBRequestAsString) - - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceInfra flow. Unexpected Error from method prepareDBRequestError() - " + ex.getMessage() - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy new file mode 100644 index 0000000000..7555885bcb --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy @@ -0,0 +1,353 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.infrastructure.scripts; + +import groovy.xml.XmlUtil +import groovy.json.* + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; + +import java.util.UUID; +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.json.JSONObject; +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +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 static org.apache.commons.lang3.StringUtils.*; + +import org.springframework.web.util.UriUtils; + +/** + * 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() + + public void preProcessRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + String msg = "" + + utils.log("DEBUG", " *** preProcessRequest Request *** ", isDebugEnabled) + + try { + // check for incoming json message/input + String siRequest = execution.getVariable("bpmnRequest") + utils.logAudit(siRequest) + + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled) + + 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" + utils.log("DEBUG", msg, isDebugEnabled) + } else + { + execution.setVariable("serviceModelInfo", serviceModelInfo) + //utils.log("DEBUG", "modelInfo" + serviceModelInfo, isDebugEnabled) + } + + //requestInfo + String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId") + if (isBlank(productFamilyId)) + { + msg = "Input productFamilyId is null" + utils.log("DEBUG", msg, isDebugEnabled) + //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" + utils.log("DEBUG", msg, isDebugEnabled) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //requestParameters + String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + utils.log("DEBUG", msg, isDebugEnabled) + //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) + } + + public void sendSyncResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) + + 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() + utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) + sendWorkflowResponse(execution, 202, syncResponse) + + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse: " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) + } + + public void sendSyncError (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** sendSyncError *** ", isDebugEnabled) + + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${errorMessage} + 7000 + """ + + utils.logAudit(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) + } + + } + + public void prepareCompletionRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled) + + try { + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String msoCompletionRequest = + """ + + ${requestId} + DELETE + ${source} + + Service Instance was deleted successfully. + DeleteGenericALaCarteServiceInstance + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable("completionRequest", xmlMsoCompletionRequest) + utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) + + } catch (Exception ex) { + String msg = " Exception in prepareCompletion:" + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled) + } + + public void prepareFalloutRequest(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** prepareFalloutRequest *** ", isDebugEnabled) + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + utils.log("DEBUG", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled) + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String requestInfo = + """ + ${requestId} + DELETE + ${source} + """ + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + execution.setVariable("falloutRequest", falloutRequest) + } catch (Exception ex) { + utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled) + String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() + String requestId = execution.getVariable("msoRequestId") + String falloutRequest = + """ + + ${requestId} + DELETE + VID + + + ${errorException} + 7000 + + """ + + execution.setVariable("falloutRequest", falloutRequest) + } + utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled) + } + + + // ******************************* + // Build DB request Section + // ******************************* + public void prepareDBRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + try { + utils.log("DEBUG", " ***** Inside prepareDBRequest of DeleteGenericALaCarteServiceInstance ***** ", isDebugEnabled) + + String requestId = execution.getVariable("DELSI_requestId") + String statusMessage = "Service Instance successfully deleted." + + //TODO - verify the format for Service Instance Delete, + String dbRequest = + """ + + + + ${requestId} + BPMN + ${statusMessage} + + COMPLETED + 100 + + + """ + + String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) + execution.setVariable("DELSI_createDBRequest", buildDeleteDBRequestAsString) + utils.logAudit(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 (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteGenericALaCarteServiceInstance ***** ", isDebugEnabled) + + 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 = + """ + + + + ${requestId} + BPMN + ${statusMessage} + + FAILED + + + """ + + String buildDBRequestAsString = utils.formatXml(dbRequest) + execution.setVariable("DELSI_createDBInfraErrorRequest", buildDBRequestAsString) + utils.logAudit(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/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy index e49de0bc09..108f8d3751 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy @@ -1,468 +1,468 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.bpmn.infrastructure.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; - - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.json.JSONObject; -import org.json.JSONArray; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; - -/** - * This groovy class supports the DeleteViprAtmService.bpmn process. - * - */ -public class DeleteGenericMacroServiceNetworkVnf extends AbstractServiceTaskProcessor { - - String Prefix="DELVAS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - CatalogDbUtils catalogDbUtils = new CatalogDbUtils() - NetworkUtils networkUtils = new NetworkUtils() - - /** - * This method is executed during the preProcessRequest task of the DeleteViprAtmService.bpmn process. - * @param execution - */ - public InitializeProcessVariables(Execution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable("deleteViprAtmServiceRequest", "") - execution.setVariable("msoRequestId", "") - execution.setVariable("DELVAS_vnfsDeletedCount", 0) - execution.setVariable("DELVAS_vnfsCount", 0) - execution.setVariable("DELVAS_networksCount", 0) - execution.setVariable("DELVAS_networksDeletedCount", 0) - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. - * @param execution - */ - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest DeleteViprAtmService Request ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // check for incoming json message/input - String deleteViprAtmServiceRequest = execution.getVariable("bpmnRequest") - utils.logAudit(deleteViprAtmServiceRequest) - execution.setVariable("deleteViprAtmServiceRequest", deleteViprAtmServiceRequest); - println 'deleteViprAtmServiceRequest - ' + deleteViprAtmServiceRequest - - // 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(deleteViprAtmServiceRequest, "requestDetails.requestInfo.source") - if ((source == null) || (source.isEmpty())) { - execution.setVariable("source", "VID") - } else { - execution.setVariable("source", source) - } - - // extract globalSubscriberId - String globalSubscriberId = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId") - - // global-customer-id is optional on Delete - - execution.setVariable("globalSubscriberId", globalSubscriberId) - execution.setVariable("globalCustomerId", globalSubscriberId) - - String suppressRollback = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.requestInfo.suppressRollback") - execution.setVariable("disableRollback", suppressRollback) - utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) - - String productFamilyId = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) - - // extract subscriptionServiceType - String subscriptionServiceType = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.requestParameters.subscriptionServiceType") - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) - - // extract cloud configuration - String lcpCloudRegionId = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) - utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("tenantId", tenantId) - utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) - - String sdncVersion = "1702" - execution.setVariable("sdncVersion", sdncVersion) - utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = - """ - ${requestId} - DELETE - ${source} - """ - - execution.setVariable("DELVAS_requestInfo", requestInfo) - - //Setting for Generic Sub Flows - execution.setVariable("GENGS_type", "service-instance") - - utils.log("DEBUG", " ***** Completed preProcessRequest DeleteViprAtmService Request ***** ", isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. Unexpected from method preProcessRequest() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteViprAtmService ***** ", isDebugEnabled) - - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String requestId = execution.getVariable("mso-request-id") - - // RESTResponse (for API Handler (APIH) Reply Task) - String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) - sendWorkflowResponse(execution, 202, syncResponse) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void prepareServiceInstanceDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside prepareServiceInstanceDelete() of DeleteViprAtmService ***** ", isDebugEnabled) - - try { - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - // confirm if ServiceInstance was found - if ( !execution.getVariable("GENGS_FoundIndicator") ) - { - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. Service Instance was not found in AAI by id: " + serviceInstanceId - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - // get variable within incoming json - String deleteViprAtmServiceRequest = execution.getVariable("deleteViprAtmServiceRequest"); - - // get SI extracted by GenericGetService - String serviceInstanceAaiRecord = execution.getVariable("GENGS_service"); - - utils.log("DEBUG", "serviceInstanceAaiRecord: "+serviceInstanceAaiRecord, isDebugEnabled) - - String relationship = "" - try { - relationship = networkUtils.getFirstNodeXml(serviceInstanceAaiRecord, "relationship-list") - } catch (Exception ex) { - //no relationships found - } - utils.log("DEBUG", " relationship string - " + relationship, isDebugEnabled) - - int vnfsCount = 0 - int networksCount = 0 - - if (relationship != null && relationship.length() > 0){ - relationship = relationship.trim().replace("tag0:","").replace(":tag0","") - - // Check if Network TableREf is present, then build a List of network policy - List relatedVnfIdList = networkUtils.getRelatedVnfIdList(relationship) - vnfsCount = relatedVnfIdList.size() - execution.setVariable("DELVAS_vnfsCount", vnfsCount) - utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) - execution.setVariable("DELVAS_relatedVnfIdList", relatedVnfIdList) - - // Check if Network TableREf is present, then build a List of network policy - List relatedNetworkIdList = networkUtils.getRelatedNetworkIdList(relationship) - networksCount = relatedNetworkIdList.size() - execution.setVariable("DELVAS_networksCount", networksCount) - utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) - execution.setVariable("DELVAS_relatedNetworkIdList", relatedNetworkIdList) - } else { - execution.setVariable("DELVAS_vnfsCount", 0) - utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) - execution.setVariable("DELVAS_networksCount", 0) - utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) - } - - utils.log("DEBUG", " ***** Completed prepareServiceInstanceDelete() of DeleteViprAtmService ***** ", isDebugEnabled) - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. prepareServiceInstanceDelete() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - - // ******************************* - // - // ******************************* - public void prepareVnfAndModulesDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled) - - List vnfList = execution.getVariable("DELVAS_relatedVnfIdList") - Integer vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount") - String vnfModelInfoString = "" - String vnfId = "" - if (vnfList.size() > 0 ) { - vnfId = vnfList.get(vnfsDeletedCount.intValue()) - } - - execution.setVariable("vnfId", vnfId) - utils.log("DEBUG", "need to delete vnfId:" + vnfId, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceMacro flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Vnf request Section -> increment count - // ******************************* - public void validateVnfDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteViprAtmService ***** ", isDebugEnabled) - - String vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount") - vnfsDeletedCount++ - - execution.setVariable("DELVAS_vnfsDeletedCount", vnfsDeletedCount) - - utils.log("DEBUG", " ***** Completed validateVnfDelete of DeleteViprAtmService ***** "+" vnf # "+vnfsDeletedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareNetworkDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareNetworkDelete of DeleteViprAtmService ***** ", isDebugEnabled) - - List networkList = execution.getVariable("DELVAS_relatedNetworkIdList") - Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") - - String networkId = "" - if (networkList.size() > 0) { - networkId = networkList.get(networksDeletedCount.intValue()) - } - - execution.setVariable("networkId", networkId) - utils.log("DEBUG", "need to delete networkId:" + networkId, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareNetworkDelete of DeleteViprAtmService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = q"Bpmn error encountered in DeleteViprAtmService flow. Unexpected Error from method prepareNetworkDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section - // ******************************* - public void validateNetworkDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkDelete of DeleteViprAtmService ***** ", isDebugEnabled) - - Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") - networksDeletedCount++ - - execution.setVariable("DELVAS_networksDeletedCount", networksDeletedCount) - - utils.log("DEBUG", " ***** Completed validateNetworkDelete of DeleteViprAtmService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. Unexpected Error from method validateNetworkDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - - // ***************************************** - // Prepare Completion request Section - // ***************************************** - public void postProcessResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteViprAtmService ***** ", isDebugEnabled) - - try { - String source = execution.getVariable("source") - String requestId = execution.getVariable("msoRequestId") - - String msoCompletionRequest = - """ - - ${requestId} - DELETE - ${source} - - vIPR ATM Service Instance has been deleted successfully. - BPMN Service Instance macro action: DELETE - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable("DELVAS_Success", true) - execution.setVariable("DELVAS_CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void prepareFalloutRequest(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** STARTED DeleteViprAtmService prepareFalloutRequest Process *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestInfo = execution.getVariable("DELVAS_requestInfo") - utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - - execution.setVariable("DELVAS_falloutRequest", falloutRequest) - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in DeleteViprAtmService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteViprAtmService prepareFalloutRequest Process") - } - utils.log("DEBUG", "*** COMPLETED DeleteViprAtmService prepareFalloutRequest Process ***", isDebugEnabled) - } - - - public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteServiceInstanceInfra ***** ", isDebugEnabled) - - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """ - ${errorMessage} - 7000 - """ - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - } - - public void processJavaException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("DELVAS_unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") - }catch(BpmnError b){ - utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("DELVAS_unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") - } - utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) - } - - +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.infrastructure.scripts; + +import groovy.xml.XmlUtil +import groovy.json.* + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.NetworkUtils +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; + + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.json.JSONObject; +import org.json.JSONArray; +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils; + +/** + * This groovy class supports the DeleteViprAtmService.bpmn process. + * + */ +public class DeleteGenericMacroServiceNetworkVnf extends AbstractServiceTaskProcessor { + + String Prefix="DELVAS_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + CatalogDbUtils catalogDbUtils = new CatalogDbUtils() + NetworkUtils networkUtils = new NetworkUtils() + + /** + * This method is executed during the preProcessRequest task of the DeleteGenericMacroServiceNetworkVnf.bpmn process. + * @param execution + */ + public InitializeProcessVariables(Execution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable("DeleteGenericMacroServiceNetworkVnfRequest", "") + execution.setVariable("msoRequestId", "") + execution.setVariable("DELVAS_vnfsDeletedCount", 0) + execution.setVariable("DELVAS_vnfsCount", 0) + execution.setVariable("DELVAS_networksCount", 0) + execution.setVariable("DELVAS_networksDeletedCount", 0) + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. + * @param execution + */ + public void preProcessRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " ***** Inside preProcessRequest DeleteGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // check for incoming json message/input + String DeleteGenericMacroServiceNetworkVnfRequest = execution.getVariable("bpmnRequest") + utils.logAudit(DeleteGenericMacroServiceNetworkVnfRequest) + execution.setVariable("DeleteGenericMacroServiceNetworkVnfRequest", DeleteGenericMacroServiceNetworkVnfRequest); + println 'DeleteGenericMacroServiceNetworkVnfRequest - ' + DeleteGenericMacroServiceNetworkVnfRequest + + // extract requestId + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) { + String dataErrorMessage = " Element 'serviceInstanceId' is missing. " + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + String requestAction = execution.getVariable("requestAction") + execution.setVariable("requestAction", requestAction) + + String source = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.source") + if ((source == null) || (source.isEmpty())) { + execution.setVariable("source", "VID") + } else { + execution.setVariable("source", source) + } + + // extract globalSubscriberId + String globalSubscriberId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.subscriberInfo.globalSubscriberId") + + // global-customer-id is optional on Delete + + execution.setVariable("globalSubscriberId", globalSubscriberId) + execution.setVariable("globalCustomerId", globalSubscriberId) + + String suppressRollback = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.suppressRollback") + execution.setVariable("disableRollback", suppressRollback) + utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) + + String productFamilyId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) + + // extract subscriptionServiceType + String subscriptionServiceType = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestParameters.subscriptionServiceType") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) + + // extract cloud configuration + String lcpCloudRegionId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") + execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) + utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) + String tenantId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.tenantId") + execution.setVariable("tenantId", tenantId) + utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) + + String sdncVersion = "1707" + execution.setVariable("sdncVersion", sdncVersion) + utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${requestId} + DELETE + ${source} + """ + + execution.setVariable("DELVAS_requestInfo", requestInfo) + + //Setting for Generic Sub Flows + execution.setVariable("GENGS_type", "service-instance") + + utils.log("DEBUG", " ***** Completed preProcessRequest DeleteGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected from method preProcessRequest() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void sendSyncResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String requestId = execution.getVariable("mso-request-id") + + // RESTResponse (for API Handler (APIH) Reply Task) + String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() + + utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) + sendWorkflowResponse(execution, 202, syncResponse) + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void prepareServiceInstanceDelete (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** Inside prepareServiceInstanceDelete() of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + try { + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // confirm if ServiceInstance was found + if ( !execution.getVariable("GENGS_FoundIndicator") ) + { + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Service Instance was not found in AAI by id: " + serviceInstanceId + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + // get variable within incoming json + String DeleteGenericMacroServiceNetworkVnfRequest = execution.getVariable("DeleteGenericMacroServiceNetworkVnfRequest"); + + // get SI extracted by GenericGetService + String serviceInstanceAaiRecord = execution.getVariable("GENGS_service"); + + utils.log("DEBUG", "serviceInstanceAaiRecord: "+serviceInstanceAaiRecord, isDebugEnabled) + + String relationship = "" + try { + relationship = networkUtils.getFirstNodeXml(serviceInstanceAaiRecord, "relationship-list") + } catch (Exception ex) { + //no relationships found + } + utils.log("DEBUG", " relationship string - " + relationship, isDebugEnabled) + + int vnfsCount = 0 + int networksCount = 0 + + if (relationship != null && relationship.length() > 0){ + relationship = relationship.trim().replace("tag0:","").replace(":tag0","") + + // Check if Network TableREf is present, then build a List of network policy + List relatedVnfIdList = networkUtils.getRelatedVnfIdList(relationship) + vnfsCount = relatedVnfIdList.size() + execution.setVariable("DELVAS_vnfsCount", vnfsCount) + utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) + execution.setVariable("DELVAS_relatedVnfIdList", relatedVnfIdList) + + // Check if Network TableREf is present, then build a List of network policy + List relatedNetworkIdList = networkUtils.getRelatedNetworkIdList(relationship) + networksCount = relatedNetworkIdList.size() + execution.setVariable("DELVAS_networksCount", networksCount) + utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) + execution.setVariable("DELVAS_relatedNetworkIdList", relatedNetworkIdList) + } else { + execution.setVariable("DELVAS_vnfsCount", 0) + utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) + execution.setVariable("DELVAS_networksCount", 0) + utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) + } + + utils.log("DEBUG", " ***** Completed prepareServiceInstanceDelete() of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + sendSyncError(execution) + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. prepareServiceInstanceDelete() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + + // ******************************* + // + // ******************************* + public void prepareVnfAndModulesDelete (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled) + + List vnfList = execution.getVariable("DELVAS_relatedVnfIdList") + Integer vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount") + String vnfModelInfoString = "" + String vnfId = "" + if (vnfList.size() > 0 ) { + vnfId = vnfList.get(vnfsDeletedCount.intValue()) + } + + execution.setVariable("vnfId", vnfId) + utils.log("DEBUG", "need to delete vnfId:" + vnfId, isDebugEnabled) + + utils.log("DEBUG", " ***** Completed prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceMacro flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Vnf request Section -> increment count + // ******************************* + public void validateVnfDelete (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + String vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount") + vnfsDeletedCount++ + + execution.setVariable("DELVAS_vnfsDeletedCount", vnfsDeletedCount) + + utils.log("DEBUG", " ***** Completed validateVnfDelete of DeleteGenericMacroServiceNetworkVnf ***** "+" vnf # "+vnfsDeletedCount, isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Generate Network request Section + // ******************************* + public void prepareNetworkDelete (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + List networkList = execution.getVariable("DELVAS_relatedNetworkIdList") + Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") + + String networkId = "" + if (networkList.size() > 0) { + networkId = networkList.get(networksDeletedCount.intValue()) + } + + execution.setVariable("networkId", networkId) + utils.log("DEBUG", "need to delete networkId:" + networkId, isDebugEnabled) + + utils.log("DEBUG", " ***** Completed prepareNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = q"Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareNetworkDelete() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Network request Section + // ******************************* + public void validateNetworkDelete (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside validateNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") + networksDeletedCount++ + + execution.setVariable("DELVAS_networksDeletedCount", networksDeletedCount) + + utils.log("DEBUG", " ***** Completed validateNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkDelete() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + + // ***************************************** + // Prepare Completion request Section + // ***************************************** + public void postProcessResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + try { + String source = execution.getVariable("source") + String requestId = execution.getVariable("msoRequestId") + + String msoCompletionRequest = + """ + + ${requestId} + DELETE + ${source} + + vIPR ATM Service Instance has been deleted successfully. + BPMN Service Instance macro action: DELETE + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + utils.logAudit(xmlMsoCompletionRequest) + execution.setVariable("DELVAS_Success", true) + execution.setVariable("DELVAS_CompleteMsoProcessRequest", xmlMsoCompletionRequest) + utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) + } catch (BpmnError e) { + throw e; + + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void prepareFalloutRequest(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** STARTED DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process *** ", isDebugEnabled) + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) + String requestInfo = execution.getVariable("DELVAS_requestInfo") + utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + + execution.setVariable("DELVAS_falloutRequest", falloutRequest) + } catch (Exception ex) { + utils.log("DEBUG", "Error Occured in DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process") + } + utils.log("DEBUG", "*** COMPLETED DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process ***", isDebugEnabled) + } + + + public void sendSyncError (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteServiceInstanceInfra ***** ", isDebugEnabled) + + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """ + ${errorMessage} + 7000 + """ + + utils.logAudit(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + } catch (Exception ex) { + utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) + } + } + + public void processJavaException(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + try{ + utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) + utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) + utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) + execution.setVariable("DELVAS_unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") + }catch(BpmnError b){ + utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) + execution.setVariable("DELVAS_unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") + } + utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) + } + + } \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy index 9e341dafbc..e18af172de 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy @@ -1,417 +1,417 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts; - -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.rest.APIResponse -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils -import groovy.xml.XmlUtil -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() - - - public InitializeProcessVariables(Execution 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 (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest() of " + groovyClassName + " ***** ", isDebugEnabled) - - 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) - utils.log("DEBUG", "Received 'suppressRollback': " + disableRollback , isDebugEnabled) - } else { - execution.setVariable("disableRollback", false) - } - utils.log("DEBUG", " Set 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) - } else { - String dataErrorMessage = " Invalid 'bpmnRequest' request." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - } else { - // 'macro' test ONLY, sdncVersion = '1702' - utils.log("DEBUG", " 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) - } - - // get/set 'msoRequestId' and 'mso-request-id' - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } 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() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void getNetworkModelInfo (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside getNetworkModelInfo() of DeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - // "networkModelInfo" is expected to be sent - String networkModelInfo = execution.getVariable("networkModelInfo") - utils.log("DEBUG", " networkModelInfo - " + networkModelInfo, isDebugEnabled) - - - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance flow. getNetworkModelInfo() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncResponse() of DeleteNetworkInstance ***** ", isDebugEnabled) - - 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() - - utils.log("DEBUG", " sendSyncResponse to APIH - " + "\n" + deleteNetworkRestRequest, isDebugEnabled) - - sendWorkflowResponse(execution, 202, deleteNetworkRestRequest) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Exception Encountered in DeleteNetworkInstance, sendSyncResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareCompletion (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareCompletion() of CreateNetworkInstance ***** ", isDebugEnabled) - - try { - - String requestId = execution.getVariable("mso-request-id") - String source = execution.getVariable(Prefix + "source") - - String msoCompletionRequest = - """ - - ${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) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. prepareCompletion() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - public void prepareDBRequestError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteNetworkInstance ***** ", isDebugEnabled) - - WorkflowException wfe = execution.getVariable("WorkflowException") - String statusMessage = wfe.getErrorMessage() - String requestId = execution.getVariable(Prefix +"requestId") - - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - FAILED - - <network-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"/> - - - """ - - execution.setVariable(Prefix + "deleteDBRequest", dbRequest) - utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, prepareDBRequestError() - " + ex.getMessage() - logError(exceptionMessage) - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - // ************************************************** - // Post or Validate Response Section - // ************************************************** - - public void postProcessResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside postProcessResponse() of DeleteNetworkInstance ***** ", isDebugEnabled) - - try { - if (execution.getVariable("CMSO_ResponseCode") == "200") { - execution.setVariable(Prefix + "Success", true) - utils.log("DEBUG", " ***** DeleteNetworkInstance Success ***** ", isDebugEnabled) - // Place holder for additional code. - - } else { - execution.setVariable(Prefix + "Success", false) - utils.log("DEBUG", " ***** DeleteNetworkInstance Failed in CompletionMsoProces flow!. ***** ", isDebugEnabled) - - } - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DeleteNetworkInstance flow. postProcessResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - // ******************************* - // Build Error Section - // ******************************* - - // Prepare for FalloutHandler - public void buildErrorResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. *****", isDebugEnabled) - - String dbReturnCode = execution.getVariable(Prefix + "dbReturnCode") - utils.log("DEBUG", " ***** DB Update Response Code : " + dbReturnCode, isDebugEnabled) - utils.log("DEBUG", " ***** DB Update Response String: " + '\n' + execution.getVariable(Prefix + "deleteDBResponse"), isDebugEnabled) - - 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 = - """ - - ${requestId} - DELETE - ${source} - - - ${errorMessage} - ${errorCode} - - """ - - utils.logAudit(falloutHandlerRequest) - execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - utils.log("ERROR", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, buildErrorResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - falloutHandlerRequest = - """ - - ${requestId} - DELEtE - ${source} - - - ${exceptionMessage} - 9999 - - """ - execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - } - } - - - public void sendSyncError (Execution 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() - - utils.log("DEBUG", " sendSyncResponse to APIH - " + "\n" + deleteNetworkRestError, isDebugEnabled) - - sendWorkflowResponse(execution, 500, deleteNetworkRestError) - - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed - DeleteNetworkInstance, sendSyncError(): " + "\n" + ex.getMessage(), isDebugEnabled) - } - } - - public void processJavaException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("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){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - 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") - } - utils.log("DEBUG", "Completed processJavaException Method of " + Prefix, isDebugEnabled) - } - -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.infrastructure.scripts; + +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.NetworkUtils +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils; +import org.openecomp.mso.rest.APIResponse +import java.util.UUID; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils +import groovy.xml.XmlUtil +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() + + + public InitializeProcessVariables(Execution 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 (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " ***** Inside preProcessRequest() of " + groovyClassName + " ***** ", isDebugEnabled) + + 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) + utils.log("DEBUG", "Received 'suppressRollback': " + disableRollback , isDebugEnabled) + } else { + execution.setVariable("disableRollback", false) + } + utils.log("DEBUG", " Set 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) + } else { + String dataErrorMessage = " Invalid 'bpmnRequest' request." + utils.log("DEBUG", dataErrorMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + } else { + // 'macro' test ONLY, sdncVersion = '1702' + utils.log("DEBUG", " 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) + } + + // get/set 'msoRequestId' and 'mso-request-id' + String requestId = execution.getVariable("msoRequestId") + if (requestId != null) { + execution.setVariable("mso-request-id", requestId) + } 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() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void getNetworkModelInfo (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + utils.log("DEBUG", " ***** Inside getNetworkModelInfo() of DeleteNetworkInstance ***** ", isDebugEnabled) + + try { + + // "networkModelInfo" is expected to be sent + String networkModelInfo = execution.getVariable("networkModelInfo") + utils.log("DEBUG", " networkModelInfo - " + networkModelInfo, isDebugEnabled) + + + } catch (Exception ex) { + sendSyncError(execution) + String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance flow. getNetworkModelInfo() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void sendSyncResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " ***** Inside sendSyncResponse() of DeleteNetworkInstance ***** ", isDebugEnabled) + + 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() + + utils.log("DEBUG", " sendSyncResponse to APIH - " + "\n" + deleteNetworkRestRequest, isDebugEnabled) + + sendWorkflowResponse(execution, 202, deleteNetworkRestRequest) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Exception Encountered in DeleteNetworkInstance, sendSyncResponse() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + public void prepareCompletion (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " ***** Inside prepareCompletion() of CreateNetworkInstance ***** ", isDebugEnabled) + + try { + + String requestId = execution.getVariable("mso-request-id") + String source = execution.getVariable(Prefix + "source") + + String msoCompletionRequest = + """ + + ${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) + utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. prepareCompletion() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + + } + + public void prepareDBRequestError (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + try { + utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteNetworkInstance ***** ", isDebugEnabled) + + WorkflowException wfe = execution.getVariable("WorkflowException") + String statusMessage = wfe.getErrorMessage() + String requestId = execution.getVariable(Prefix +"requestId") + + String dbRequest = + """ + + + + ${requestId} + BPMN + ${statusMessage} + + FAILED + + <network-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"/> + + + """ + + execution.setVariable(Prefix + "deleteDBRequest", dbRequest) + utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, prepareDBRequestError() - " + ex.getMessage() + logError(exceptionMessage) + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + // ************************************************** + // Post or Validate Response Section + // ************************************************** + + public void postProcessResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + utils.log("DEBUG", " ***** Inside postProcessResponse() of DeleteNetworkInstance ***** ", isDebugEnabled) + + try { + if (execution.getVariable("CMSO_ResponseCode") == "200") { + execution.setVariable(Prefix + "Success", true) + utils.log("DEBUG", " ***** DeleteNetworkInstance Success ***** ", isDebugEnabled) + // Place holder for additional code. + + } else { + execution.setVariable(Prefix + "Success", false) + utils.log("DEBUG", " ***** DeleteNetworkInstance Failed in CompletionMsoProces flow!. ***** ", isDebugEnabled) + + } + + + } catch (Exception ex) { + String exceptionMessage = " Bpmn error encountered in DeleteNetworkInstance flow. postProcessResponse() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + + } + + } + + + // ******************************* + // Build Error Section + // ******************************* + + // Prepare for FalloutHandler + public void buildErrorResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + utils.log("DEBUG", " ***** Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. *****", isDebugEnabled) + + String dbReturnCode = execution.getVariable(Prefix + "dbReturnCode") + utils.log("DEBUG", " ***** DB Update Response Code : " + dbReturnCode, isDebugEnabled) + utils.log("DEBUG", " ***** DB Update Response String: " + '\n' + execution.getVariable(Prefix + "deleteDBResponse"), isDebugEnabled) + + 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 = + """ + + ${requestId} + DELETE + ${source} + + + ${errorMessage} + ${errorCode} + + """ + + utils.logAudit(falloutHandlerRequest) + execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + utils.log("ERROR", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) + + } catch (Exception ex) { + // caught exception + String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, buildErrorResponse() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + falloutHandlerRequest = + """ + + ${requestId} + DELEtE + ${source} + + + ${exceptionMessage} + 9999 + + """ + execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) + } + } + + + public void sendSyncError (Execution 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() + + utils.log("DEBUG", " sendSyncResponse to APIH - " + "\n" + deleteNetworkRestError, isDebugEnabled) + + sendWorkflowResponse(execution, 500, deleteNetworkRestError) + + } catch (Exception ex) { + utils.log("DEBUG", " Sending Sync Error Activity Failed - DeleteNetworkInstance, sendSyncError(): " + "\n" + ex.getMessage(), isDebugEnabled) + } + } + + public void processJavaException(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + try{ + utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) + utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) + utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) + execution.setVariable("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){ + utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) + 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") + } + utils.log("DEBUG", "Completed processJavaException Method of " + Prefix, isDebugEnabled) + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index 2d5ddf0d0c..d221d0622b 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -1,37 +1,37 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= */ -package org.openecomp.mso.bpmn.infrastructure.scripts; +package org.openecomp.mso.bpmn.infrastructure.scripts; import groovy.xml.XmlUtil import groovy.json.* -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.NetworkUtils +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig import java.util.HashMap; import java.util.Map; @@ -322,7 +322,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String networkInputs = execution.getVariable(Prefix + "networkInputs") String networkName = utils.getNodeText1(networkInputs, "network-name") networkName = UriUtils.encode(networkName,"UTF-8") - String messageId = execution.getVariable("messageId") // Prepare AA&I url with network-name String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -333,14 +332,8 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryNameAAIRequest", queryAAINameRequest) utils.log("DEBUG", Prefix + "queryNameAAIRequest - " + "\n" + queryAAINameRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(queryAAINameRequest); - try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAINameRequest) String returnCode = response.getStatusCode() execution.setVariable(Prefix + "aaiNameReturnCode", returnCode) utils.log("DEBUG", " ***** AAI Query Name Response Code : " + returnCode, isDebugEnabled) @@ -483,7 +476,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "networkName", networkName) networkId = UriUtils.encode(networkId,"UTF-8") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare AA&I url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -494,12 +486,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest) utils.log("DEBUG", Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(queryIdAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest) String returnCode = response.getStatusCode() execution.setVariable(Prefix + "aaiIdReturnCode", returnCode) @@ -562,7 +549,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String networkId = execution.getVariable(Prefix + "networkId") String netId = networkId networkId = UriUtils.encode(networkId,"UTF-8") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare AA&I url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -573,12 +559,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest) utils.log("DEBUG", Prefix + "requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(requeryIdAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest) String returnCode = response.getStatusCode() execution.setVariable(Prefix + "aaiRequeryIdReturnCode", returnCode) utils.log("DEBUG", " ***** AAI ReQuery Response Code : " + returnCode, isDebugEnabled) @@ -642,7 +623,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -693,12 +673,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) utils.log("DEBUG", Prefix + "queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(queryVpnBindingAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) String returnCode = response.getStatusCode() execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", returnCode) utils.log("DEBUG", " ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode, isDebugEnabled) @@ -747,7 +722,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -781,7 +756,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -835,12 +809,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) utils.log("DEBUG", Prefix + "queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(queryNetworkPolicyAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyAAIRequest) String returnCode = response.getStatusCode() execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", returnCode) utils.log("DEBUG", " ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode, isDebugEnabled) @@ -889,7 +858,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -923,7 +892,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -977,12 +945,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) utils.log("DEBUG", Prefix + "queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(queryNetworkTableRefAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkTableRefAAIRequest) String returnCode = response.getStatusCode() execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", returnCode) utils.log("DEBUG", " ***** AAI query network Table Reference Response Code, NetworkTableRef #" + counting + " : " + returnCode, isDebugEnabled) @@ -1031,7 +994,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -1070,7 +1033,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -1083,7 +1045,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG", Prefix + "updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest, isDebugEnabled) //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion) String payloadXml = utils.formatXml(payload) utils.logAudit(payloadXml) @@ -1096,7 +1058,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", returnCode) utils.log("DEBUG", " ***** AAI Update Contrail Response Code : " + returnCode, isDebugEnabled) String aaiUpdateContrailResponseAsString = response.getResponseBodyAsString() - if (returnCode=='200') { utils.logAudit(aaiUpdateContrailResponseAsString) execution.setVariable(Prefix + "updateContrailAAIResponse", aaiUpdateContrailResponseAsString) @@ -1125,7 +1086,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // aai all errors String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode utils.log("DEBUG", errorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, "2500", errorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) } } } @@ -1153,7 +1114,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // get variables String requestId = execution.getVariable("msoRequestId") if (requestId == null) { - requestId = execution.getVariable("mso-request-id") + requestId = execution.getVariable("mso-request-id") } String messageId = execution.getVariable(Prefix + "messageId") String source = execution.getVariable(Prefix + "source") @@ -1200,12 +1161,12 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String networkId = execution.getVariable(Prefix + "networkId") String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - // get/set 'msoRequestId' and 'mso-request-id' + // get/set 'msoRequestId' and 'mso-request-id' String requestId = execution.getVariable("msoRequestId") if (requestId != null) { - execution.setVariable("mso-request-id", requestId) + execution.setVariable("mso-request-id", requestId) } else { - requestId = execution.getVariable("mso-request-id") + requestId = execution.getVariable("mso-request-id") } execution.setVariable(Prefix + "requestId", requestId) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy index e6276a8852..9f28db727d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy @@ -1,39 +1,39 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= */ -package org.openecomp.mso.bpmn.infrastructure.scripts; +package org.openecomp.mso.bpmn.infrastructure.scripts; import static org.apache.commons.lang3.StringUtils.*; import groovy.xml.XmlUtil import groovy.json.* -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig import java.util.UUID; @@ -134,14 +134,14 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - String personaModelId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") - String personaModelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") + String modelInvariantId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") + String modelVersionId = jsonUtil.getJsonValue(serviceModelInfo, "modelVersionId") - if (personaModelId == null) { - personaModelId = "" + if (modelInvariantId == null) { + modelInvariantId = "" } - if (personaModelVersion == null) { - personaModelVersion = "" + if (modelVersionId == null) { + modelVersionId = "" } if (serviceInstanceName == null) { execution.setVariable("serviceInstanceName", "") @@ -155,9 +155,9 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { String serviceInstanceData = """ ${serviceInstanceName} - active - ${personaModelId} - ${personaModelVersion} + Active + ${modelInvariantId} + ${modelVersionId} """.trim() execution.setVariable("serviceInstanceData", serviceInstanceData) @@ -362,9 +362,9 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { } String sdncAssignRequest = - """ + """ ${sdncRequestId} ${serviceInstanceId} @@ -406,12 +406,14 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { utils.logAudit("sdncAssignRequest: " + sdncAssignRequest) def sdncRequestId2 = UUID.randomUUID().toString() - String sdncRollbackRequest = sdncAssignRequest.replace(">assign<", ">delete<").replace(">CreateServiceInstance<", ">DeleteServiceInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + 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", "sdncRollbackRequest", sdncRollbackRequest) + rollbackData.put("SERVICEINSTANCE", "sdncDeactivate", sdncDeactivate) + rollbackData.put("SERVICEINSTANCE", "sdncDelete", sdncDelete) execution.setVariable("rollbackData", rollbackData) - utils.log("DEBUG","sdncRollbackRequest:\n" + sdncRollbackRequest, isDebugEnabled) utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled) } catch (BpmnError e) { diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy index 1e6541e226..0e9fd7f4b7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy @@ -106,8 +106,12 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso execution.setVariable("skipRollback", true) } - def sdncRollbackRequest = rollbackData.get("SERVICEINSTANCE", "sdncRollbackRequest") - execution.setVariable("sdncRollbackRequest", sdncRollbackRequest) + def sdncDelete = rollbackData.get("SERVICEINSTANCE", "sdncDelete") + execution.setVariable("sdncDelete", sdncDelete) + def sdncDeactivate = rollbackData.get("SERVICEINSTANCE", "sdncDeactivate") + execution.setVariable("sdncDeactivate", sdncDeactivate) + utils.log("DEBUG","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled) + utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled) } else { execution.setVariable("skipRollback", true) @@ -131,31 +135,33 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) } - public void validateSDNCResponse(Execution execution) { + public void validateSDNCResponse(Execution execution, String response, String method) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("DEBUG"," ***** validateSDNCResponse ***** ", isDebugEnabled) String msg = "" try { WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - String response = execution.getVariable("sdncAdapterResponse") - + utils.log("DEBUG", "SDNCResponse: " + response, isDebugEnabled) + utils.log("DEBUG", "workflowException: " + workflowException, isDebugEnabled) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG", "SDNC Adapter for service-instance delete for rollback successful. response", isDebugEnabled) + msg = "SDNC Adapter service-instance rollback successful for " + method + utils.log("DEBUG", msg, isDebugEnabled) }else{ execution.setVariable("rolledBack", false) - execution.setVariable("rollbackError", "Error Response from SDNC Adapter for service-instance delete for rollback") - utils.log("DEBUG","Error Response from SDNC Adapter for service-instance delete for rollback", isDebugEnabled) + msg = "Error Response from SDNC Adapter service-instance rollback for " + method + execution.setVariable("rollbackError", msg) + utils.log("DEBUG", msg, isDebugEnabled) throw new BpmnError("MSOWorkflowException") } } catch (BpmnError e) { throw e; } catch (Exception ex){ - msg = "Exception in Create ServiceInstance Rollback validateSDNCResponse " + ex.getMessage() + msg = "Exception in Create ServiceInstance rollback for " + method + " Exception:" + ex.getMessage() utils.log("DEBUG", msg, isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -187,7 +193,7 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso utils.log("DEBUG","*** Exit postProcessRequest ***", isDebugEnabled) } catch (BpmnError e) { - msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + ex.getMessage() + msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + e.getMessage() utils.log("DEBUG", msg, isDebugEnabled) } catch (Exception ex) { msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + ex.getMessage() diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index 269cb808c4..1fd5ab0abc 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -17,12 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - + package org.openecomp.mso.bpmn.infrastructure.scripts; - -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - + +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.runtime.Execution @@ -37,15 +37,15 @@ import org.openecomp.mso.bpmn.core.json.JsonUtils import org.openecomp.mso.rest.APIResponse import org.openecomp.mso.rest.RESTClient import org.openecomp.mso.rest.RESTConfig -import org.springframework.web.util.UriUtils -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.NamedNodeMap -import org.w3c.dom.Node +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 org.xml.sax.InputSource + + public class DoCreateVfModule extends VfModuleBase { @@ -140,7 +140,7 @@ public class DoCreateVfModule extends VfModuleBase { def requestId = execution.getVariable("msoRequestId") execution.setVariable("DCVFM_requestId", requestId) logDebug("requestId: " + requestId, isDebugLogEnabled) - // Set mso-request-id to request-id for VNF Adapter interface + // Set mso-request-id to request-id for VNF Adapter interface execution.setVariable("mso-request-id", requestId) //serviceId def serviceId = execution.getVariable("serviceId") @@ -175,7 +175,7 @@ public class DoCreateVfModule extends VfModuleBase { //personaModelId execution.setVariable("DCVFM_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantId")) //personaModelVersion - execution.setVariable("DCVFM_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion")) + execution.setVariable("DCVFM_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersionId")) //vfModuleLabel def vfModuleLabel = execution.getVariable("vfModuleLabel") if (vfModuleLabel != null) { @@ -665,7 +665,7 @@ public class DoCreateVfModule extends VfModuleBase { String uuid = execution.getVariable('testReqId') // for junits if(uuid==null){ - uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() + uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() } def callbackUrl = execution.getVariable("DCVFM_sdncCallbackUrl") @@ -680,6 +680,14 @@ public class DoCreateVfModule extends VfModuleBase { 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 @@ -723,7 +731,7 @@ public class DoCreateVfModule extends VfModuleBase { query ${serviceOperation} ${callbackUrl} - mobility + ${msoAction} """ @@ -902,13 +910,13 @@ public class DoCreateVfModule extends VfModuleBase { def requestId = execution.getVariable("mso-request-id") if (requestId == null) { - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id") + 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") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id") } utils.logContext(requestId, serviceInstanceId) @@ -1014,9 +1022,9 @@ public class DoCreateVfModule extends VfModuleBase { if (!sdncVersion.equals("1707")) { sdncRequest = - """ + """ ${requestId} ${svcInstId} @@ -1057,14 +1065,14 @@ public class DoCreateVfModule extends VfModuleBase { else { sdncRequest = - """ + """ ${requestId} ${svcInstId} ${action} - vnf-topology-operation + vf-module-topology-operation ${callbackURL} generic-resource @@ -1081,10 +1089,7 @@ public class DoCreateVfModule extends VfModuleBase { ${serviceEcompModelInformation} ${svcInstId} ${globalSubscriberId} - - - ${vfModuleModelName} - + ${vnfId} ${vnfType} @@ -1095,11 +1100,10 @@ public class DoCreateVfModule extends VfModuleBase { ${vfModuleModelName} ${vfModuleEcompModelInformation} - - ${sdncVersion} + ${vfModuleName} ${tenantId} - ${cloudSiteId} + ${cloudSiteId} ${sdncVNFParamsXml} @@ -1108,9 +1112,9 @@ public class DoCreateVfModule extends VfModuleBase { /* sdncRequest = - """ + """ ${requestId} ${svcInstId} @@ -1142,8 +1146,7 @@ public class DoCreateVfModule extends VfModuleBase { ${vfModuleModelName} ${vfModuleEcompModelInformation} - - ${sdncVersion} + ${vfModuleName} ${tenantId} ${cloudSiteId} @@ -1662,7 +1665,7 @@ public class DoCreateVfModule extends VfModuleBase { def networkPolicyId = UUID.randomUUID().toString() logDebug("Adding network-policy with network-policy-id " + networkPolicyId, isDebugLogEnabled) - String aaiNamespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) logDebug('AAI namespace is: ' + aaiNamespace, isDebugLogEnabled) String payload = """ ${networkPolicyId} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy index 8ca749d1ec..af1161b656 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -1,33 +1,33 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.infrastructure.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse -import org.springframework.web.util.UriUtils +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils @@ -72,7 +72,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ execution.setVariable("DCVFMR_cloudSiteId", cloudSiteId) String heatStackId = rollbackData.get("VFMODULE", "heatstackid") execution.setVariable("DCVFMR_heatStackId", heatStackId) - String requestId = rollbackData.get("VFMODULE", "msorequestid") + String requestId = rollbackData.get("VFMODULE", "attmsorequestid") execution.setVariable("DCVFMR_requestId", requestId) List createdNetworkPolicyFqdnList = [] int i = 0 @@ -92,7 +92,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ execution.setVariable("DCVFMR_oamManagementV4Address", oamManagementV4Address) String oamManagementV6Address = rollbackData.get("VFMODULE", "oamManagementV6Address") execution.setVariable("DCVFMR_oamManagementV6Address", oamManagementV6Address) - //String serviceInstanceId = rollbackData.get("VFMODULE", "msoserviceinstanceid") + //String serviceInstanceId = rollbackData.get("VFMODULE", "attmsoserviceinstanceid") //execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) execution.setVariable("DCVFMR_rollbackPrepareUpdateVfModule", rollbackData.get("VFMODULE", "rollbackPrepareUpdateVfModule")) execution.setVariable("DCVFMR_rollbackUpdateAAIVfModule", rollbackData.get("VFMODULE", "rollbackUpdateAAIVfModule")) @@ -159,9 +159,9 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ return - String request = """ + String request = """ ${requestId} ${vfModuleId} @@ -214,7 +214,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ 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') + '-' + + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy index f54fa5c88b..8e54024c6f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy @@ -303,7 +303,7 @@ class DoCreateVfModuleVolumeV1 extends VfModuleBase { def vnfId = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-id') def vnfName = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-name') def modelCustomizationId = getNodeTextForce(volumeRequest, "model-customization-id") - + String messageId = UUID.randomUUID() utils.log("DEBUG", "messageId to be used is generated: " + messageId, isDebugEnabled) @@ -502,6 +502,9 @@ class DoCreateVfModuleVolumeV1 extends VfModuleBase { utils.logAudit("AAI query generic vnf return code: " + returnCode) utils.logAudit("AAI query generic vnf response: " + aaiResponseAsString) + //utils.log("DEBUG", "AAI query generic vnf return code: " + returnCode, isDebugEnabled) + //utils.log("DEBUG", "AAI query generic vnf response: " + aaiResponseAsString, isDebugEnabled) + ExceptionUtil exceptionUtil = new ExceptionUtil() if (returnCode=='200') { diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy index 55d56a6194..8a6cac4a91 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -16,12 +16,12 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - */ + */ package org.openecomp.mso.bpmn.infrastructure.scripts - + import static org.apache.commons.lang3.StringUtils.* -import org.openecomp.mso.bpmn.core.RollbackData -import org.camunda.bpm.engine.delegate.BpmnError +import org.openecomp.mso.bpmn.core.RollbackData +import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution import org.openecomp.mso.bpmn.common.scripts.AaiUtil import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -30,429 +30,557 @@ import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils import org.openecomp.mso.bpmn.common.scripts.VidUtils import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.core.json.JsonUtils - - -/** - * This class supports the DoCreateVnf building block subflow - * with the creation of a generic vnf for - * infrastructure. - * - */ -class DoCreateVnf extends AbstractServiceTaskProcessor { - - 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(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - utils.log("DEBUG", " *** STARTED DoCreateVnf PreProcessRequest Process*** ", isDebugEnabled) - - // DISABLE SDNC INTERACTION FOR NOW - execution.setVariable("SDNCInteractionEnabled", false) - - - /*******************/ - try{ - // Get Variables - - String cloudConfiguration = execution.getVariable("cloudConfiguration") - String vnfModelInfo = execution.getVariable("vnfModelInfo") - String serviceModelInfo = execution.getVariable("serviceModelInfo") - - String requestId = execution.getVariable("requestId") - execution.setVariable("DoCVNF_requestId", requestId) + + +/** + * This class supports the DoCreateVnf building block subflow + * with the creation of a generic vnf for + * infrastructure. + * + */ +class DoCreateVnf extends AbstractServiceTaskProcessor { + + 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(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED DoCreateVnf PreProcessRequest Process*** ", isDebugEnabled) + + // DISABLE SDNC INTERACTION FOR NOW + execution.setVariable("SDNCInteractionEnabled", false) + + + /*******************/ + try{ + // Get Variables + + 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) - utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId) - utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) - - String vnfType = execution.getVariable("vnfType") - execution.setVariable("DoCVNF_vnfType", vnfType) - utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled) - - String vnfName = execution.getVariable("vnfName") - execution.setVariable("DoCVNF_vnfName", vnfName) - utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled) - - String serviceId = execution.getVariable("productFamilyId") - execution.setVariable("DoCVNF_serviceId", serviceId) - utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled) - - String source = "VID" - execution.setVariable("DoCVNF_source", source) - utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) - - String suppressRollback = execution.getVariable("disableRollback") - execution.setVariable("DoCVNF_suppressRollback", suppressRollback) - utils.log("DEBUG", "Incoming Suppress Rollback is: " + suppressRollback, isDebugEnabled) - - String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantId") - execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId) - utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled) - - String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId") - if (modelVersionId == null) { - modelVersionId = "" - } - execution.setVariable("DoCVNF_modelVersionId", modelVersionId) - utils.log("DEBUG", "Incoming Version Id is: " + modelVersionId, isDebugEnabled) - - String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion") - execution.setVariable("DoCVNF_modelVersion", modelVersion) - utils.log("DEBUG", "Incoming Model Version is: " + modelVersion, isDebugEnabled) - - String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName") - execution.setVariable("DoCVNF_modelName", modelName) - utils.log("DEBUG", "Incoming Model Name is: " + modelName, isDebugEnabled) - - String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationId") - if (modelCustomizationId == null) { - modelCustomizationId = "" - } - execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId) - utils.log("DEBUG", "Incoming Model Customization Id is: " + modelCustomizationId, isDebugEnabled) - - String cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") - execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId) - utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled) - - String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId") - execution.setVariable("DoCVNF_tenantId", tenantId) - utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled) - - String globalSubscriberId = execution.getVariable("globalSubscriberId") - if (globalSubscriberId == null) { - globalSubscriberId = "" - } - execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId) - utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - if (sdncVersion == null) { - sdncVersion = "1702" - } - execution.setVariable("DoCVNF_sdncVersion", sdncVersion) - utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = + utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId) + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + + String vnfType = execution.getVariable("vnfType") + execution.setVariable("DoCVNF_vnfType", vnfType) + utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled) + + String vnfName = execution.getVariable("vnfName") + if (vnfName.equals("") || vnfName.equals("null")) { + vnfName = null + } + execution.setVariable("DoCVNF_vnfName", vnfName) + utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled) + + String serviceId = execution.getVariable("productFamilyId") + execution.setVariable("DoCVNF_serviceId", serviceId) + utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled) + + String source = "VID" + execution.setVariable("DoCVNF_source", source) + utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) + + String suppressRollback = execution.getVariable("disableRollback") + execution.setVariable("DoCVNF_suppressRollback", suppressRollback) + utils.log("DEBUG", "Incoming Suppress Rollback is: " + suppressRollback, isDebugEnabled) + + String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantId") + execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId) + utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled) + + String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId") + if (modelVersionId == null) { + modelVersionId = "" + } + execution.setVariable("DoCVNF_modelVersionId", modelVersionId) + utils.log("DEBUG", "Incoming Version Id is: " + modelVersionId, isDebugEnabled) + + String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion") + execution.setVariable("DoCVNF_modelVersion", modelVersion) + utils.log("DEBUG", "Incoming Model Version is: " + modelVersion, isDebugEnabled) + + String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName") + execution.setVariable("DoCVNF_modelName", modelName) + utils.log("DEBUG", "Incoming Model Name is: " + modelName, isDebugEnabled) + + String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationId") + if (modelCustomizationId == null) { + modelCustomizationId = "" + } + execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId) + utils.log("DEBUG", "Incoming Model Customization Id is: " + modelCustomizationId, isDebugEnabled) + + String cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId) + utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled) + + String tenantId = execution.getVariable("tenantId") + execution.setVariable("DoCVNF_tenantId", tenantId) + utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + if (globalSubscriberId == null) { + globalSubscriberId = "" + } + execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId) + utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null) { + sdncVersion = "1702" + } + execution.setVariable("DoCVNF_sdncVersion", sdncVersion) + utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled) + + //For Completion Handler & Fallout Handler + String requestInfo = """ - ${requestId} - CREATE - ${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() - utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled) - } - } - 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) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { - def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' - logError(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl) - utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) - logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled) - - def rollbackData = execution.getVariable("RollbackData") - if (rollbackData == null) { - rollbackData = new RollbackData() - } - - execution.setVariable("RollbackData", rollbackData) - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", " Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") - - } - utils.log("DEBUG", "*** COMPLETED DoCreateVnf PreProcessRequest Process ***", isDebugEnabled) - } - - - public void prepareCreateGenericVnf (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DoCreateVnf PrepareCreateGenericVnf Process *** ", isDebugEnabled) - try { - //Get Vnf Info - String vnfId = execution.getVariable("DoCVNF_vnfId") - def vnfName = execution.getVariable("DoCVNF_vnfName") - def vnfType = execution.getVariable("DoCVNF_vnfType") - def serviceId = execution.getVariable("DoCVNF_serviceId") - def orchStatus = execution.getVariable("DoCVNF_orchStatus") - def modelInvariantId = execution.getVariable("DoCVNF_modelInvariantId") - def modelVersion = execution.getVariable("DoCVNF_modelVersion") - def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId") - // TODO: 1702 Variable - def equipmentRole = execution.getVariable("DoCVNF_equipmentRole") - - //Get Service Instance Info - def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") - String siRelatedLink = execution.getVariable("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) - - //Get Namespace - AaiUtil aaiUtil = new AaiUtil(this) - def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) - String namespace = aaiUtil.getNamespaceFromUri(aai_uri) - - String payload = - """ - ${vnfId} - ${vnfName} - ${serviceId} - ${vnfType} - PREPROV - ${orchStatus} - ${modelInvariantId} - ${modelVersion} - ${modelCustomizationId} - - - service-instance - ${siRelatedLink} - - customer.global-customer-id - ${globalCustId} - - - service-subscription.service-type - ${serviceType} - - - service-instance.service-instance-id - ${serviceInstanceId} - - - - """ - - execution.setVariable("DoCVNF_genericVnfPayload", payload) - - }catch(Exception ex) { - utils.log("DEBUG", "Error Occured in DoCreateVnf PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PrepareCreateGenericVnf Process") - } - utils.log("DEBUG", "*** COMPLETED DoCreateVnf PrepareCreateGenericVnf Process ***", isDebugEnabled) - } - - public void postProcessCreateGenericVnf (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DoCreateVnf PostProcessCreateGenericVnf Process *** ", isDebugEnabled) - try { - //Get Vnf Info - String vnfId = execution.getVariable("DoCVNF_vnfId") - def rollbackData = execution.getVariable("RollbackData") - rollbackData.put("VNF", "vnfId", vnfId) - execution.setVariable("RollbackData", rollbackData) - }catch(Exception ex) { - utils.log("DEBUG", "Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process") - } - utils.log("DEBUG", "*** COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process ***", isDebugEnabled) - } - - - public void preProcessSDNCAssignRequest(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - def vnfId = execution.getVariable("DoCVNF_vnfId") - def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") - logDebug("NEW VNF ID: " + vnfId, isDebugLogEnabled) - utils.logAudit("NEW VNF ID: " + vnfId) - - try{ - //Build SDNC Request - - String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign") - - assignSDNCRequest = utils.formatXml(assignSDNCRequest) - execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest) - logDebug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessSDNCAssignRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - public void preProcessSDNCActivateRequest(Execution execution) { - def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled) - try{ - String vnfId = execution.getVariable("DoCVNF_vnfId") - String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") - - String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate") - - execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest) - logDebug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest) - - }catch(Exception e){ - log.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled) - } - - public String buildSDNCRequest(Execution execution, String svcInstId, String action){ - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ + ${requestId} + CREATE + ${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() + utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled) + } + } + 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) execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl) + utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) + logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled) + + def rollbackData = execution.getVariable("RollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } + + execution.setVariable("RollbackData", rollbackData) + + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") + + } + utils.log("DEBUG", "*** COMPLETED DoCreateVnf PreProcessRequest Process ***", isDebugEnabled) + } + + + public void prepareCreateGenericVnf (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " *** STARTED DoCreateVnf PrepareCreateGenericVnf Process *** ", isDebugEnabled) + try { + //Get Vnf Info + String vnfId = execution.getVariable("DoCVNF_vnfId") + def vnfName = execution.getVariable("DoCVNF_vnfName") + if (vnfName == null) { + vnfName = "sdncGenerated" + utils.log("DEBUG", "Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName, isDebugEnabled) + } + def vnfType = execution.getVariable("DoCVNF_vnfType") + def serviceId = execution.getVariable("DoCVNF_serviceId") + def orchStatus = execution.getVariable("DoCVNF_orchStatus") + def modelInvariantId = execution.getVariable("DoCVNF_modelInvariantId") + def modelVersionId = execution.getVariable("DoCVNF_modelVersionId") + def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId") + // TODO: 1702 Variable + def equipmentRole = execution.getVariable("DoCVNF_equipmentRole") + + //Get Service Instance Info + def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") + String siRelatedLink = execution.getVariable("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) + + //Get Namespace + AaiUtil aaiUtil = new AaiUtil(this) + def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) + String namespace = aaiUtil.getNamespaceFromUri(execution, aai_uri) + + String payload = + """ + ${vnfId} + ${vnfName} + ${serviceId} + ${vnfType} + PREPROV + ${orchStatus} + ${modelInvariantId} + ${modelVersionId} + ${modelCustomizationId} + + + service-instance + ${siRelatedLink} + + customer.global-customer-id + ${globalCustId} + + + service-subscription.service-type + ${serviceType} + + + service-instance.service-instance-id + ${serviceInstanceId} + + + + """ + + execution.setVariable("DoCVNF_genericVnfPayload", payload) + + }catch(Exception ex) { + utils.log("DEBUG", "Error Occured in DoCreateVnf PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PrepareCreateGenericVnf Process") + } + utils.log("DEBUG", "*** COMPLETED DoCreateVnf PrepareCreateGenericVnf Process ***", isDebugEnabled) + } + + public void postProcessCreateGenericVnf (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " *** STARTED DoCreateVnf PostProcessCreateGenericVnf Process *** ", isDebugEnabled) + try { + //Get Vnf Info + String vnfId = execution.getVariable("DoCVNF_vnfId") + def rollbackData = execution.getVariable("RollbackData") + rollbackData.put("VNF", "vnfId", vnfId) + execution.setVariable("RollbackData", rollbackData) + }catch(Exception ex) { + utils.log("DEBUG", "Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process") + } + utils.log("DEBUG", "*** COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process ***", isDebugEnabled) + } + + + public void preProcessSDNCAssignRequest(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) + def vnfId = execution.getVariable("DoCVNF_vnfId") + def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") + logDebug("NEW VNF ID: " + vnfId, isDebugLogEnabled) + utils.logAudit("NEW VNF ID: " + vnfId) + + try{ + //Build SDNC Request + + String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign") + + assignSDNCRequest = utils.formatXml(assignSDNCRequest) + execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest) + logDebug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest, isDebugLogEnabled) + utils.logAudit("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessSDNCAssignRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) + } + + public void preProcessSDNCActivateRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled) + try{ + String vnfId = execution.getVariable("DoCVNF_vnfId") + String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") + + String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate") + + execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest) + logDebug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest, isDebugLogEnabled) + utils.logAudit("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest) + + }catch(Exception e){ + log.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled) + } + + public String buildSDNCRequest(Execution 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("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") - 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 = + } + 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 = """${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 = """ - - ${requestId} - ${svcInstId} - ${action} - vnf-topology-operation - ${callbackURL} - generic-resource - - - - ${requestId} - CreateVnfInstance - ${source} - - - - - - ${serviceId} - ${serviceId} - ${serviceEcompModelInformation} - ${svcInstId} - ${globalSubscriberId} - - - ${vnfId} - ${vnfType} - ${vnfEcompModelInformation} - - - ${sdncVersion} - - ${tenantId} - ${cloudSiteId} - ${sdncVNFParamsXml} - - - """ - - utils.logAudit("sdncRequest: " + sdncRequest) - return sdncRequest - } - - public void validateSDNCResponse(Execution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - utils.logAudit("workflowException: " + workflowException) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - utils.logAudit("SDNCResponse: " + response) - - String sdncResponse = response - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) - - }else{ - logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - } - - -} + + ${requestId} + ${svcInstId} + ${action} + vnf-topology-operation + ${callbackURL} + generic-resource + + + + ${requestId} + CreateVnfInstance + ${source} + + + + + + ${serviceId} + ${serviceId} + ${serviceEcompModelInformation} + ${svcInstId} + ${globalSubscriberId} + + + ${vnfId} + ${vnfType} + ${vnfEcompModelInformation} + + + ${vnfNameString} + ${tenantId} + ${cloudSiteId} + ${sdncVNFParamsXml} + + + """ + + utils.logAudit("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(Execution execution, String response, String method){ + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + utils.logAudit("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + utils.logAudit("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) + if(method.equals("get")){ + String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse") + String data = utils.getNodeXml(topologyGetResponse, "response-data") + data = data.replaceAll("<", "<") + data = data.replaceAll(">", ">") + utils.log("DEBUG", "topologyGetResponseData: " + data, isDebugLogEnabled) + String vnfName = utils.getNodeText1(data, "vnf-name") + utils.log("DEBUG", "vnfName received from SDNC: " + vnfName, isDebugLogEnabled) + execution.setVariable("vnfName", vnfName) + execution.setVariable("DoCVNF_vnfName", vnfName) + } + + }else{ + logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) + throw new BpmnError("MSOWorkflowException") + } + logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) + } + + public void preProcessSDNCGetRequest(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + utils.log("DEBUG", " ======== STARTED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled) + 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") + utils.logAudit("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") + utils.logAudit("DoCVNF_assignSDNCAdapterResponse is: \n" + response) + + String serviceOperation = "" + + String data = utils.getNodeXml(response, "response-data") + data = data.replaceAll("<", "<") + data = data.replaceAll(">", ">") + utils.log("DEBUG", "responseData: " + data, isDebugLogEnabled) + serviceOperation = utils.getNodeText1(data, "object-path") + utils.log("DEBUG", "VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation, isDebugLogEnabled) + + + //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE + sleep(5000) + + String SDNCGetRequest = + """ + + ${uuid} + ${svcInstId} + query + ${serviceOperation} + ${callbackUrl} + vfmodule + + + """ + + utils.logAudit("SDNCGetRequest: \n" + SDNCGetRequest) + execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest) + utils.log("DEBUG", "Outgoing GetSDNCRequest is: \n" + SDNCGetRequest, isDebugLogEnabled) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) + } + utils.log("DEBUG", "======== COMPLETED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled) + } + + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIGenericVnf(Execution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('DoCVNF_vnfId') + logDebug("VNF ID: " + vnfId, isDebugLogEnabled) + + String updateAAIGenericVnfRequest = """ + + ${vnfId} + Active + + """ + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) + logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled) + + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) + } + } + + + + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy index 861da52397..daae3d7dac 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy @@ -1,285 +1,369 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.bpmn.infrastructure.scripts - -import java.util.UUID; - -import org.json.JSONObject; -import org.json.JSONArray; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution; - -import static org.apache.commons.lang3.StringUtils.*; - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException - - - -/** -* This class supports the macro VID Flow -* with the creation of a generic vnf and related VF modules. -*/ -class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { - - 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(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules PreProcessRequest Process*** ", isDebugEnabled) - - try{ - // Get Variables - - - String cloudConfiguration = execution.getVariable("cloudConfiguration") - String vnfModelInfo = execution.getVariable("vnfModelInfo") - - String requestId = execution.getVariable("requestId") - execution.setVariable("mso-request-id", requestId) - utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) - - String vnfType = execution.getVariable("vnfType") - utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled) - - String vnfName = execution.getVariable("vnfName") - execution.setVariable("CREVI_vnfName", vnfName) - utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled) - - String productFamilyId = execution.getVariable("productFamilyId") - utils.log("DEBUG", "Incoming Product Family Id is: " + productFamilyId, isDebugEnabled) - - String source = "VID" - execution.setVariable("source", source) - utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) - - String disableRollback = execution.getVariable("disableRollback") - utils.log("DEBUG", "Incoming Disable Rollback is: " + disableRollback, isDebugEnabled) - - String asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") - utils.log("DEBUG", "Incoming asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugEnabled) - - String vnfId = execution.getVariable("testVnfId") // for junits - if(isBlank(vnfId)){ - vnfId = execution.getVariable("vnfId") - if (isBlank(vnfId)) { - vnfId = UUID.randomUUID().toString() - utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled) - } - } - execution.setVariable("vnfId", vnfId) - - def rollbackData = execution.getVariable("RollbackData") - if (rollbackData == null) { - rollbackData = new RollbackData() - } - - execution.setVariable("numOfCreatedAddOnModules", 0) - - rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", 0) - execution.setVariable("RollbackData", rollbackData) - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", " Error Occured in DoCreateVnfAndModules PreProcessRequest method!" + e.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") - - } - utils.log("DEBUG", "*** COMPLETED DoCreateVnfAndModules PreProcessRequest Process ***", isDebugEnabled) - } - - - public void queryCatalogDB (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules QueryCatalogDB Process *** ", isDebugEnabled) - try { - //Get Vnf Info - String vnfModelInfo = execution.getVariable("vnfModelInfo") - String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationId") - utils.log("DEBUG", "querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid) - String catalogDbEndpoint = execution.getVariable("URN_mso_catalog_db_endpoint") - - JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(catalogDbEndpoint, - vnfModelCustomizationUuid) - utils.log("DEBUG", "obtained VNF list") - // Only one match here - JSONObject vnf = vnfs[0] - JSONArray vfModules = vnf.getJSONArray("vfModules") - JSONArray addOnModules = new JSONArray() - - // Set up base Vf Module info - for (int i = 0; i < vfModules.length(); i++) { - utils.log("DEBUG", "handling VF Module ") - JSONObject vfModule = vfModules[i] - String isBase = jsonUtil.getJsonValueForKey(vfModule, "isBase") - if (isBase.equals("true")) { - JSONObject baseVfModuleModelInfoObject = vfModule.getJSONObject("modelInfo") - String baseVfModuleModelInfo = baseVfModuleModelInfoObject.toString() - execution.setVariable("baseVfModuleModelInfo", baseVfModuleModelInfo) - String baseVfModuleLabel = jsonUtil.getJsonValueForKey(vfModule, "vfModuleLabel") - execution.setVariable("baseVfModuleLabel", baseVfModuleLabel) - String basePersonaModelId = jsonUtil.getJsonValueForKey(baseVfModuleModelInfoObject, "modelInvariantId") - execution.setVariable("basePersonaModelId", basePersonaModelId) - } - else { - addOnModules.add(vfModules[i]) - } - } - - execution.setVariable("addOnModules", addOnModules) - execution.setVariable("addOnModulesToDeploy", addOnModules.length()) - execution.setVariable("addOnModulesDeployed", 0) - - }catch(Exception ex) { - utils.log("DEBUG", "Error Occured in DoCreateVnfAndModules QueryCatalogDB Process " + ex.getMessage(), isDebugEnabled) - 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) - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PrepareCreateGenericVnf Process ***", isDebugEnabled) - } - - public void preProcessAddOnModule(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessAddOnModule ======== ", isDebugLogEnabled) - - 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, "modelInvariantId") - execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) - String addOnInitialCount = jsonUtil.getJsonValueForKey(addOnModule, "initialCount") - execution.setVariable("initialCount", addOnInitialCount) - - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - public void validateBaseModule(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED validateBaseModule ======== ", isDebugLogEnabled) - - 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) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing validateBaseModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during validateBaseModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED validateBaseModule ======== ", isDebugLogEnabled) - } - - public void validateAddOnModule(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED validateAddOnModule ======== ", isDebugLogEnabled) - - 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){ - utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - public void finishProcessingInitialCountDeployment(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED finishProcessingInitialCountDeployment ======== ", isDebugLogEnabled) - - try { - int addOnModulesDeployed = execution.getVariable("addOnModulesDeployed") - execution.setVariable("addOnModulesDeployed", addOnModulesDeployed + 1) - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - - -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import java.util.UUID; + +import org.json.JSONObject; +import org.json.JSONArray; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.decomposition.ModelInfo +import org.openecomp.mso.bpmn.core.decomposition.ModuleResource +import org.openecomp.mso.bpmn.core.decomposition.ServiceDecomposition +import org.openecomp.mso.bpmn.core.decomposition.VnfResource + + + +/** +* This class supports the macro VID Flow +* with the creation of a generic vnf and related VF modules. +*/ +class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { + + 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(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules PreProcessRequest Process*** ", isDebugEnabled) + + 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) + utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + + String vnfType = execution.getVariable("vnfType") + utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled) + + String vnfName = execution.getVariable("vnfName") + execution.setVariable("CREVI_vnfName", vnfName) + utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled) + + String productFamilyId = execution.getVariable("productFamilyId") + utils.log("DEBUG", "Incoming Product Family Id is: " + productFamilyId, isDebugEnabled) + + String source = "VID" + execution.setVariable("source", source) + utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) + + String lcpCloudRegionId = execution.getVariable("lcpCloudRegionId") + utils.log("DEBUG", "Incoming LCP Cloud Region Id is: " + lcpCloudRegionId) + + String tenantId = execution.getVariable("tenantId") + utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId) + + String disableRollback = execution.getVariable("disableRollback") + utils.log("DEBUG", "Incoming Disable Rollback is: " + disableRollback, isDebugEnabled) + + String asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") + utils.log("DEBUG", "Incoming asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugEnabled) + + String vnfId = execution.getVariable("testVnfId") // for junits + if(isBlank(vnfId)){ + vnfId = execution.getVariable("vnfId") + if (isBlank(vnfId)) { + vnfId = UUID.randomUUID().toString() + utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled) + } + } + execution.setVariable("vnfId", vnfId) + + def rollbackData = execution.getVariable("RollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } + + execution.setVariable("numOfCreatedAddOnModules", 0) + + rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "0") + execution.setVariable("RollbackData", rollbackData) + + sleep (20000) + + + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error Occured in DoCreateVnfAndModules PreProcessRequest method!" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") + + } + utils.log("DEBUG", "*** COMPLETED DoCreateVnfAndModules PreProcessRequest Process ***", isDebugEnabled) + } + + + public void queryCatalogDB (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules QueryCatalogDB Process *** ", isDebugEnabled) + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + // if serviceDecomposition is specified, get info from serviceDecomposition + if (serviceDecomposition != null) { + utils.log("DEBUG", "Getting Catalog DB data from ServiceDecomposition object: " + serviceDecomposition.toJsonString(), isDebugEnabled) + List vnfs = serviceDecomposition.getServiceVnfs() + utils.log("DEBUG", "Read vnfs", isDebugEnabled) + if (vnfs == null) { + utils.log("DEBUG", "Error - vnfs are empty in serviceDecomposition object", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vnfs are empty") + } + VnfResource vnf = vnfs[0] + utils.log("DEBUG", "Read vnfResource", isDebugEnabled) + if (vnf == null) { + utils.log("DEBUG", "Error - vnf is empty in serviceDecomposition object", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vnf is null") + } + + List vfModules = vnf.getAllVfModuleObjects() + utils.log("DEBUG", "Read vfModules", isDebugEnabled) + if (vfModules == null) { + utils.log("DEBUG", "Error - vfModules are empty in serviceDecomposition object", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vf modules are empty") + } + JSONArray addOnModules = new JSONArray() + + for (int i = 0; i < vfModules.size; i++) { + utils.log("DEBUG", "handling VF Module ", isDebugEnabled) + ModuleResource vfModule = vfModules[i] + boolean isBase = vfModule.getIsBase() + if (isBase) { + ModelInfo baseVfModuleModelInfoObject = vfModule.getModelInfo() + String baseVfModuleModelInfoWithRoot = baseVfModuleModelInfoObject.toString() + String baseVfModuleModelInfo = jsonUtil.getJsonValue(baseVfModuleModelInfoWithRoot, "modelInfo") + execution.setVariable("baseVfModuleModelInfo", baseVfModuleModelInfo) + String baseVfModuleLabel = vfModule.getVfModuleLabel() + execution.setVariable("baseVfModuleLabel", baseVfModuleLabel) + String basePersonaModelId = baseVfModuleModelInfoObject.getModelInvariantId() + execution.setVariable("basePersonaModelId", basePersonaModelId) + } + else { + addOnModules.put(vfModules[i]) + } + } + + execution.setVariable("addOnModules", addOnModules) + execution.setVariable("addOnModulesToDeploy", addOnModules.length()) + execution.setVariable("addOnModulesDeployed", 0) + + } + else { + //Get Vnf Info + String vnfModelInfo = execution.getVariable("vnfModelInfo") + utils.log("DEBUG", "vnfModelInfo: " + vnfModelInfo, isDebugEnabled) + String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationId") + if (vnfModelCustomizationUuid == null) { + vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationUuid") + } + utils.log("DEBUG", "querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid, isDebugEnabled) + String catalogDbEndpoint = execution.getVariable("URN_mso_catalog_db_endpoint") + + JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(catalogDbEndpoint, + vnfModelCustomizationUuid) + utils.log("DEBUG", "obtained VNF list") + // Only one match here + JSONObject vnf = vnfs[0] + JSONArray vfModules = vnf.getJSONArray("vfModules") + JSONArray addOnModules = new JSONArray() + + // Set up base Vf Module info + for (int i = 0; i < vfModules.length(); i++) { + utils.log("DEBUG", "handling VF Module ") + JSONObject vfModule = vfModules[i] + String isBase = jsonUtil.getJsonValueForKey(vfModule, "isBase") + if (isBase.equals("true")) { + JSONObject baseVfModuleModelInfoObject = vfModule.getJSONObject("modelInfo") + String baseVfModuleModelInfo = baseVfModuleModelInfoObject.toString() + execution.setVariable("baseVfModuleModelInfo", baseVfModuleModelInfo) + String baseVfModuleLabel = jsonUtil.getJsonValueForKey(vfModule, "vfModuleLabel") + execution.setVariable("baseVfModuleLabel", baseVfModuleLabel) + String basePersonaModelId = jsonUtil.getJsonValueForKey(baseVfModuleModelInfoObject, "modelInvariantId") + execution.setVariable("basePersonaModelId", basePersonaModelId) + } + else { + addOnModules.put(vfModules[i]) + } + } + + execution.setVariable("addOnModules", addOnModules) + execution.setVariable("addOnModulesToDeploy", addOnModules.length()) + execution.setVariable("addOnModulesDeployed", 0) + } + + }catch(Exception ex) { + utils.log("DEBUG", "Error Occured in DoCreateVnfAndModules QueryCatalogDB Process " + ex.getMessage(), isDebugEnabled) + 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") + } + + utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PrepareCreateGenericVnf Process ***", isDebugEnabled) + } + + public void preProcessAddOnModule(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessAddOnModule ======== ", isDebugLogEnabled) + + 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 addOnVfModuleModelInfoWithRoot = addOnVfModuleModelInfoObject.toString() + String addOnVfModuleModelInfo = jsonUtil.getJsonValue(addOnVfModuleModelInfoWithRoot, "modelInfo") + execution.setVariable("addOnVfModuleModelInfo", addOnVfModuleModelInfo) + String addOnVfModuleLabel = jsonUtil.getJsonValueForKey(addOnModule, "vfModuleLabel") + execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel) + String addOnPersonaModelId = jsonUtil.getJsonValueForKey(addOnVfModuleModelInfoObject, "modelInvariantId") + execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) + String addOnInitialCount = jsonUtil.getJsonValueForKey(addOnModule, "initialCount") + execution.setVariable("initialCount", addOnInitialCount) + + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) + } + + public void validateBaseModule(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED validateBaseModule ======== ", isDebugLogEnabled) + + 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) + logDebug("addOnModulesDeployed: " + execution.getVariable("addOnModulesDeployed"), isDebugLogEnabled) + logDebug("addOnModulesToDeploy: " + execution.getVariable("addOnModulesToDeploy"), isDebugLogEnabled) + if (execution.getVariable("addOnModulesDeployed") < execution.getVariable("addOnModulesToDeploy")) { + logDebug("More add on modules to deploy", isDebugLogEnabled) + } + else { + logDebug("No more add on modules to deploy", isDebugLogEnabled) + } + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing validateBaseModule. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during validateBaseModule Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED validateBaseModule ======== ", isDebugLogEnabled) + } + + public void validateAddOnModule(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED validateAddOnModule ======== ", isDebugLogEnabled) + + 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){ + utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) + } + + public void finishProcessingInitialCountDeployment(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED finishProcessingInitialCountDeployment ======== ", isDebugLogEnabled) + + try { + int addOnModulesDeployed = execution.getVariable("addOnModulesDeployed") + execution.setVariable("addOnModulesDeployed", addOnModulesDeployed + 1) + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) + } + + + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 76a86ff516..2bf3e55301 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -1,35 +1,35 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.bpmn.infrastructure.scripts; - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.infrastructure.scripts; + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.NetworkUtils +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig import java.util.UUID; @@ -239,7 +239,6 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String networkInputs = execution.getVariable(Prefix + "networkInputs") String networkId = utils.getNodeText(networkInputs, "network-id") networkId = UriUtils.encode(networkId,"UTF-8") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare AA&I url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -255,11 +254,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() Boolean isVfRelationshipExist = false try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAIRequest) String returnCode = response.getStatusCode() execution.setVariable(Prefix + "aaiReturnCode", returnCode) @@ -520,15 +515,14 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") - // get/set 'msoRequestId' and 'mso-request-id' + // get/set 'msoRequestId' and 'mso-request-id' String requestId = execution.getVariable("msoRequestId") if (requestId != null) { - execution.setVariable("mso-request-id", requestId) + execution.setVariable("mso-request-id", requestId) } else { - requestId = execution.getVariable("mso-request-id") + requestId = execution.getVariable("mso-request-id") } execution.setVariable(Prefix + "requestId", requestId) - utils.log("DEBUG", Prefix + "requestId " + requestId, isDebugEnabled) String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") @@ -655,7 +649,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "rollbackNetworkRequest", "") } else { String rollbackNetwork = - """ + """ ${rollbackData} """ String rollbackNetworkXml = utils.formatXml(rollbackNetwork) @@ -996,12 +990,12 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") - // get/set 'msoRequestId' and 'mso-request-id' + // get/set 'msoRequestId' and 'mso-request-id' String requestId = execution.getVariable("msoRequestId") if (requestId != null) { - execution.setVariable("mso-request-id", requestId) + execution.setVariable("mso-request-id", requestId) } else { - requestId = execution.getVariable("mso-request-id") + requestId = execution.getVariable("mso-request-id") } execution.setVariable(Prefix + "requestId", requestId) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy index 6daec69b9d..32197c1bc2 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy @@ -1,420 +1,420 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.bpmn.infrastructure.scripts; - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -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.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 - -/** - * 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 - sdncVersion - * @param - failNotFound - TODO - * @param - serviceInputParams - TODO - * - * Outputs: - * @param - WorkflowException - * - * Rollback - Deferred - */ -public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="DDELSI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - - public void preProcessRequest (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** 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 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" - utils.log("DEBUG", 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("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void preProcessSDNCDelete (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled) - String msg = "" - - try { - /* - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() - } - */ - def serviceInstanceId = execution.getVariable("serviceInstanceId") - def serviceInstanceName = execution.getVariable("serviceInstanceName") - def callbackURL = execution.getVariable("sdncCallbackUrl") - 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 modelInvariantId = "" - def modelVersion = "" - def modelUUId = "" - def modelName = "" - if (!isBlank(serviceModelInfo)) - { - modelInvariantId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") - modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") - modelUUId = jsonUtil.getJsonValue(serviceModelInfo, "modelVersionId") - modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") - - if (modelInvariantId == null) { - modelInvariantId = "" - } - if (modelVersion == null) { - modelVersion = "" - } - if (modelUUId == null) { - modelUUId = "" - } - if (modelName == null) { - modelName = "" - } - } - if (serviceInstanceName == null) { - serviceInstanceName = "" - } - if (serviceId == null) { - serviceId = "" - } - - def sdncRequestId = UUID.randomUUID().toString() - - String sdncDelete = - """ - - ${sdncRequestId} - ${serviceInstanceId} - delete - service-topology-operation - ${callbackURL} - - - - ${requestId} - MSO - - - - DeleteServiceInstance - - - ${serviceId} - ${subscriptionServiceType} - - ${modelInvariantId} - ${modelUUId} - ${modelVersion} - ${modelName} - - ${serviceInstanceId} - - ${globalSubscriberId} - - - ${serviceInstanceName} - - - """ - - utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled) - sdncDelete = utils.formatXml(sdncDelete) - execution.setVariable("sdncDelete", sdncDelete) - utils.logAudit("sdncDelete: " + sdncDelete) - - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage()) - } - utils.log("DEBUG"," *****Exit preProcessSDNCDelete *****", isDebugEnabled) - } - - public void postProcessSDNCDelete(Execution execution) { - - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessSDNCDelete ***** ", isDebugEnabled) - String msg = "" - - try { - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - String response = execution.getVariable("sdncAdapterResponse") - utils.logAudit("SDNCResponse: " + response) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG","Good response from SDNC Adapter for service-instance topology assign: \n" + response, isDebugEnabled) - - }else{ - msg = "Bad Response from SDNC Adapter for service-instance delete" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg) - } - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in postProcessSDNCDelete. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage()) - } - utils.log("DEBUG"," *** Exit postProcessSDNCDelete *** ", isDebugEnabled) - } - - public void postProcessAAIGET(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessAAIGET ***** ", isDebugEnabled) - String msg = "" - - try { - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - - if(foundInAAI == true){ - utils.log("DEBUG","Found Service-instance in AAI", isDebugEnabled) - - //Extract GlobalSubscriberId - String siRelatedLink = execution.getVariable("GENGS_siResourceLink") - if (isBlank(siRelatedLink)) - { - msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - else - { - utils.log("DEBUG","Found Service-instance in AAI. link: " + siRelatedLink, isDebugEnabled) - 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 serviceType = execution.getVariable("subscriptionServiceType") - if(isBlank(serviceType)){ - int serviceStart = siRelatedLink.indexOf("service-subscription/") - int serviceEnd = siRelatedLink.indexOf("/service-instances/") - String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd) - serviceType = UriUtils.decode(serviceTypeEncoded, "UTF-8") - execution.setVariable("subscriptionServiceType", serviceType) - } - - if (isBlank(globalSubscriberId) || isBlank(serviceType)) - { - msg = "Could not retrive global-customer-id & service-type from AAI to delete id:" + serviceInstanceId - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - } - - String siData = execution.getVariable("GENGS_service") - utils.log("DEBUG", "SI Data", isDebugEnabled) - if (isBlank(siData)) - { - msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - else - { - utils.log("DEBUG", "SI Data" + siData, isDebugEnabled) - //Confirm there are no related service instances (vnf/network or volume) - if (utils.nodeExists(siData, "relationship-list")) { - utils.log("DEBUG", "SI Data relationship-list exists:", isDebugEnabled) - 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")){ - utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs or l3-networks", isDebugEnabled) - execution.setVariable("siInUse", true) - //there are relationship dependencies to this Service Instance - msg = " Stopped deleting Service Instance, it has dependencies. Service instance id: " + serviceInstanceId - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - }else{ - utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled) - } - } - } - } - } - }else{ - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(succInAAI != true){ - utils.log("DEBUG","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("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - utils.log("DEBUG","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteServiceInstance.postProcessAAIGET. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled) - } - - public void postProcessAAIDEL(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessAAIDEL ***** ", isDebugEnabled) - String msg = "" - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator") - if(succInAAI != true){ - msg = "Error deleting Service-instance in AAI" + serviceInstanceId - utils.log("DEBUG", msg, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteServiceInstance.postProcessAAIDEL. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *** Exit postProcessAAIDEL *** ", isDebugEnabled) - } -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.infrastructure.scripts; + +import static org.apache.commons.lang3.StringUtils.*; +import groovy.xml.XmlUtil +import groovy.json.* + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig + +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.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 + +/** + * 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 - sdncVersion + * @param - failNotFound - TODO + * @param - serviceInputParams - TODO + * + * Outputs: + * @param - WorkflowException + * + * Rollback - Deferred + */ +public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { + + String Prefix="DDELSI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + + public void preProcessRequest (Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** 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 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" + utils.log("DEBUG", 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("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) + } + + public void preProcessSDNCDelete (Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled) + String msg = "" + + try { + /* + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() + } + */ + def serviceInstanceId = execution.getVariable("serviceInstanceId") + def serviceInstanceName = execution.getVariable("serviceInstanceName") + def callbackURL = execution.getVariable("sdncCallbackUrl") + 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 modelInvariantId = "" + def modelVersion = "" + def modelUUId = "" + def modelName = "" + if (!isBlank(serviceModelInfo)) + { + modelInvariantId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") + modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") + modelUUId = jsonUtil.getJsonValue(serviceModelInfo, "modelVersionId") + modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") + + if (modelInvariantId == null) { + modelInvariantId = "" + } + if (modelVersion == null) { + modelVersion = "" + } + if (modelUUId == null) { + modelUUId = "" + } + if (modelName == null) { + modelName = "" + } + } + if (serviceInstanceName == null) { + serviceInstanceName = "" + } + if (serviceId == null) { + serviceId = "" + } + + def sdncRequestId = UUID.randomUUID().toString() + + String sdncDelete = + """ + + ${sdncRequestId} + ${serviceInstanceId} + delete + service-topology-operation + ${callbackURL} + + + + ${requestId} + MSO + + + + DeleteServiceInstance + + + ${serviceId} + ${subscriptionServiceType} + + ${modelInvariantId} + ${modelUUId} + ${modelVersion} + ${modelName} + + ${serviceInstanceId} + + ${globalSubscriberId} + + + ${serviceInstanceName} + + + """ + + 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) + utils.log("DEBUG","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled) + utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled) + + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage()) + } + utils.log("DEBUG"," *****Exit preProcessSDNCDelete *****", isDebugEnabled) + } + + public void postProcessSDNCDelete(Execution execution, String response, String method) { + + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** postProcessSDNC " + method + " *****", isDebugEnabled) + String msg = "" + + try { + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + utils.log("DEBUG", "SDNCResponse: " + response, isDebugEnabled) + utils.log("DEBUG", "workflowException: " + workflowException, isDebugEnabled) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + utils.log("DEBUG","Good response from SDNC Adapter for service-instance " + method + "response:\n" + response, isDebugEnabled) + + }else{ + msg = "Bad Response from SDNC Adapter for service-instance " + method + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg) + } + } catch (BpmnError e) { + throw e; + } catch(Exception ex) { + msg = "Exception in postProcessSDNC " + method + " Exception:" + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," *** Exit postProcessSDNC " + method + " ***", isDebugEnabled) + } + + public void postProcessAAIGET(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** postProcessAAIGET ***** ", isDebugEnabled) + String msg = "" + + try { + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") + + if(foundInAAI == true){ + utils.log("DEBUG","Found Service-instance in AAI", isDebugEnabled) + + //Extract GlobalSubscriberId + String siRelatedLink = execution.getVariable("GENGS_siResourceLink") + if (isBlank(siRelatedLink)) + { + msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + else + { + utils.log("DEBUG","Found Service-instance in AAI. link: " + siRelatedLink, isDebugEnabled) + 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 serviceType = execution.getVariable("subscriptionServiceType") + if(isBlank(serviceType)){ + int serviceStart = siRelatedLink.indexOf("service-subscription/") + int serviceEnd = siRelatedLink.indexOf("/service-instances/") + String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd) + serviceType = UriUtils.decode(serviceTypeEncoded, "UTF-8") + execution.setVariable("subscriptionServiceType", serviceType) + } + + if (isBlank(globalSubscriberId) || isBlank(serviceType)) + { + msg = "Could not retrive global-customer-id & service-type from AAI to delete id:" + serviceInstanceId + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + } + + String siData = execution.getVariable("GENGS_service") + utils.log("DEBUG", "SI Data", isDebugEnabled) + if (isBlank(siData)) + { + msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + else + { + utils.log("DEBUG", "SI Data" + siData, isDebugEnabled) + //Confirm there are no related service instances (vnf/network or volume) + if (utils.nodeExists(siData, "relationship-list")) { + utils.log("DEBUG", "SI Data relationship-list exists:", isDebugEnabled) + 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")){ + utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs or l3-networks", isDebugEnabled) + execution.setVariable("siInUse", true) + //there are relationship dependencies to this Service Instance + msg = " Stopped deleting Service Instance, it has dependencies. Service instance id: " + serviceInstanceId + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + }else{ + utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled) + } + } + } + } + } + }else{ + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(succInAAI != true){ + utils.log("DEBUG","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("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + utils.log("DEBUG","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteServiceInstance.postProcessAAIGET. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled) + } + + public void postProcessAAIDEL(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** postProcessAAIDEL ***** ", isDebugEnabled) + String msg = "" + try { + String serviceInstanceId = execution.getVariable("serviceInstanceId") + boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator") + if(succInAAI != true){ + msg = "Error deleting Service-instance in AAI" + serviceInstanceId + utils.log("DEBUG", msg, isDebugEnabled) + WorkflowException workflowException = execution.getVariable("WorkflowException") + utils.logAudit("workflowException: " + workflowException) + if(workflowException != null){ + exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) + } + else + { + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) + } + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + msg = "Exception in DoDeleteServiceInstance.postProcessAAIDEL. " + ex.getMessage() + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + utils.log("DEBUG"," *** Exit postProcessAAIDEL *** ", isDebugEnabled) + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy index 92456b0216..208caa790d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy @@ -1,256 +1,484 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.bpmn.infrastructure.scripts - -import java.util.UUID; - -import org.json.JSONObject; -import org.json.JSONArray; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution; - -import static org.apache.commons.lang3.StringUtils.*; - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException - -/** - * This class supports the macro VID Flow - * with the deletion of a generic vnf and related VF modules. - */ -class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { - - String Prefix="DDVAM_" - 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(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - utils.log("DEBUG", " *** STARTED DoDeleteVnfAndModules PreProcessRequest Process*** ", isDebugEnabled) - - try{ - // Get Variables - - String cloudConfiguration = execution.getVariable("cloudConfiguration") - - String requestId = execution.getVariable("requestId") - execution.setVariable("mso-request-id", requestId) - utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) - - String vnfId = execution.getVariable("vnfId") - utils.log("DEBUG", "Incoming Vnf Id is: " + vnfId, isDebugEnabled) - - String source = "VID" - execution.setVariable("source", source) - utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) - - execution.setVariable("DDVAM_moduleCount", 0) - execution.setVariable("DDVAM_nextModule", 0) - - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", " Error Occured in DoCreateVnfAndModules PreProcessRequest method!" + e.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") - - } - utils.log("DEBUG", "*** COMPLETED DoCreateVnfAndModules PreProcessRequest Process ***", isDebugEnabled) - } - - - - public void preProcessAddOnModule(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessAddOnModule ======== ", isDebugLogEnabled) - - 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, "modelInvariantId") - execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) - String addOnInitialCount = jsonUtil.getJsonValueForKey(addOnModule, "initialCount") - execution.setVariable("initialCount", addOnInitialCount) - - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - /** - * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info. - * A 200 response is expected with the VNF info in the response body. Will find out the base module info. - * - * @param execution The flow's execution instance. - */ - public void queryAAIVfModule(Execution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - def method = getClass().getSimpleName() + '.queryAAIVfModule(' + - 'execution=' + execution.getId() + - ')' - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DvnfId') - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) - - String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - utils.logAudit("AAI endPoint: " + endPoint) - - try { - RESTConfig config = new RESTConfig(endPoint); - def responseData = '' - def aaiRequestId = UUID.randomUUID().toString() - RESTClient client = new RESTClient(config). - addHeader('X-TransactionId', aaiRequestId). - addHeader('X-FromAppId', 'MSO'). - addHeader('Content-Type', 'application/xml'). - addHeader('Accept','application/xml'); - logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) - APIResponse response = client.httpGet() - utils.logAudit("createVfModule - invoking httpGet() to AAI") - - responseData = response.getResponseBodyAsString() - if (responseData != null) { - logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) - - } - - utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData) - utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) - - execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', response.getStatusCode()) - execution.setVariable('DCVFM_queryAAIVfModuleResponse', responseData) - logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) - logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) - //Map[] vfModules = new HashMap[] - List> vfModulesList = new ArrayList>(); - if (response.getStatusCode() == 200) { - // Parse the VNF record from A&AI to find base module info - logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled) - if (responseData != null) { - def vfModulesText = utils.getNodeXml(responseData, "vf-modules") - def xmlVfModules= new XmlSlurper().parseText(vfModulesText) - def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"} - execution.setVariable("DDVAM_moduleCount", vfModules.size()) - int vfModulesSize = 0 - for (i in 0..vfModules.size()-1) { - def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) - - Map vfModuleEntry = new HashMap() - def vfModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id") - vfModuleEntry.put("vfModuleId", vfModuleName) - def vfModuleName = utils.getNodeText1(vfModuleXml, "vf-module-name") - vfModuleEntry.put("vfModuleName", vfModuleName) - vfModulesList.add(vfModuleEntry) - } - - } - } - execution.setVariable("DDVAM_vfModules", vfModules) - } catch (Exception ex) { - ex.printStackTrace() - logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) - } - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) - } - } - - public void prepareNextModuleToDelete(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED prepareNextModuleToDelete ======== ", isDebugLogEnabled) - - 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) - - - // HARDCODED FOR NOW - def vfModuleModelInfo = "" - execution.setVariable("DDVAM_vfModuleModelInfo", vfModuleModelInfo) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - - - -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import java.util.UUID; + +import org.json.JSONObject; +import org.json.JSONArray; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution; + +import static org.apache.commons.lang3.StringUtils.*; + +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.common.scripts.VidUtils +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException + +/** + * This class supports the macro VID Flow + * with the deletion of a generic vnf and related VF modules. + */ +class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { + + 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(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED DoDeleteVnfAndModules PreProcessRequest Process*** ", isDebugEnabled) + + try{ + // Get Variables + + String cloudConfiguration = execution.getVariable("cloudConfiguration") + + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("requestId", requestId) + execution.setVariable("mso-request-id", requestId) + utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + + String vnfId = execution.getVariable("vnfId") + utils.log("DEBUG", "Incoming Vnf Id is: " + vnfId, isDebugEnabled) + + String source = "VID" + execution.setVariable("DDVAM_source", source) + utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null) { + sdncVersion = "1702" + } + execution.setVariable("DDVAM_sdncVersion", sdncVersion) + utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled) + + String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) + logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled) + + if (!sdncVersion.equals("1702")) { + //String vnfModelInfo = execution.getVariable("vnfModelInfo") + //String serviceModelInfo = execution.getVariable("serviceModelInfo") + + String serviceId = execution.getVariable("productFamilyId") + execution.setVariable("DDVAM_serviceId", serviceId) + utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled) + + + //String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantId") + //execution.setVariable("DDVAM_modelInvariantId", modelInvariantId) + //utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled) + + //String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId") + //if (modelVersionId == null) { + // modelVersionId = "" + //} + //execution.setVariable("DDVAM_modelVersionId", modelVersionId) + //utils.log("DEBUG", "Incoming Version Id is: " + modelVersionId, isDebugEnabled) + + //String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion") + //execution.setVariable("DDVAM_modelVersion", modelVersion) + //utils.log("DEBUG", "Incoming Model Version is: " + modelVersion, isDebugEnabled) + + //String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName") + //execution.setVariable("DDVAM_modelName", modelName) + //utils.log("DEBUG", "Incoming Model Name is: " + modelName, isDebugEnabled) + + //String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationId") + //if (modelCustomizationId == null) { + // modelCustomizationId = "" + //} + //execution.setVariable("DDVAM_modelCustomizationId", modelCustomizationId) + //utils.log("DEBUG", "Incoming Model Customization Id is: " + modelCustomizationId, isDebugEnabled) + + String cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("DDVAM_cloudSiteId", cloudSiteId) + utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled) + + String tenantId = execution.getVariable("tenantId") + execution.setVariable("DDVAM_tenantId", tenantId) + utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + if (globalSubscriberId == null) { + globalSubscriberId = "" + } + execution.setVariable("DDVAM_globalSubscriberId", globalSubscriberId) + utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) + } + execution.setVariable("DDVAM_moduleCount", 0) + execution.setVariable("DDVAM_nextModule", 0) + + + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error Occured in DoCreateVnfAndModules PreProcessRequest method!" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") + + } + utils.log("DEBUG", "*** COMPLETED DoCreateVnfAndModules PreProcessRequest Process ***", isDebugEnabled) + } + + + + public void preProcessAddOnModule(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessAddOnModule ======== ", isDebugLogEnabled) + + 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, "modelInvariantId") + execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) + String addOnInitialCount = jsonUtil.getJsonValueForKey(addOnModule, "initialCount") + execution.setVariable("initialCount", addOnInitialCount) + + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) + } + + /** + * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info. + * A 200 response is expected with the VNF info in the response body. Will find out the base module info. + * + * @param execution The flow's execution instance. + */ + public void queryAAIVfModule(Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def method = getClass().getSimpleName() + '.queryAAIVfModule(' + + 'execution=' + execution.getId() + + ')' + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('vnfId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + + String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + utils.logAudit("AAI endPoint: " + endPoint) + + try { + RESTConfig config = new RESTConfig(endPoint); + def responseData = '' + def aaiRequestId = UUID.randomUUID().toString() + RESTClient client = new RESTClient(config). + addHeader('X-TransactionId', aaiRequestId). + addHeader('X-FromAppId', 'MSO'). + addHeader('Content-Type', 'application/xml'). + addHeader('Accept','application/xml'); + logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) + APIResponse response = client.httpGet() + utils.logAudit("createVfModule - invoking httpGet() to AAI") + + responseData = response.getResponseBodyAsString() + if (responseData != null) { + logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) + + } + + utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData) + utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) + + execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('DCVFM_queryAAIVfModuleResponse', responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + //Map[] vfModules = new HashMap[] + def vfModulesList = new ArrayList>() + def vfModules = null + def vfModuleBaseEntry = null + if (response.getStatusCode() == 200) { + // Parse the VNF record from A&AI to find base module info + logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled) + if (responseData != null) { + def vfModulesText = utils.getNodeXml(responseData, "vf-modules") + logDebug("vModulesText: " + vfModulesText, isDebugLogEnabled) + if (vfModulesText != null && !vfModulesText.trim().isEmpty()) { + def xmlVfModules= new XmlSlurper().parseText(vfModulesText) + vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"} + execution.setVariable("DDVAM_moduleCount", vfModules.size()) + int vfModulesSize = 0 + for (i in 0..vfModules.size()-1) { + def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) + + Map vfModuleEntry = new HashMap() + def vfModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id") + vfModuleEntry.put("vfModuleId", vfModuleId) + def vfModuleName = utils.getNodeText1(vfModuleXml, "vf-module-name") + vfModuleEntry.put("vfModuleName", vfModuleName) + + def 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() + logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) + } + } + + public void prepareNextModuleToDelete(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED prepareNextModuleToDelete ======== ", isDebugLogEnabled) + + 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) + + + // HARDCODED FOR NOW + def vfModuleModelInfo = "" + execution.setVariable("DDVAM_vfModuleModelInfo", vfModuleModelInfo) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToDelete Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED prepareNextModuleToDelete ======== ", isDebugLogEnabled) + } + + public void preProcessSDNCDeactivateRequest(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) + def vnfId = execution.getVariable("vnfId") + def serviceInstanceId = execution.getVariable("serviceInstanceId") + + try{ + //Build SDNC Request + + String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") + + deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) + execution.setVariable("DDVAM_deactivateSDNCRequest", deactivateSDNCRequest) + logDebug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest, isDebugLogEnabled) + utils.logAudit("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + + }catch(Exception e){ + utils.log("ERROR", "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) + } + + public void preProcessSDNCUnassignRequest(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) + try{ + String vnfId = execution.getVariable("vnfId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") + + execution.setVariable("DDVAM_unassignSDNCRequest", unassignSDNCRequest) + logDebug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest, isDebugLogEnabled) + utils.logAudit("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + + }catch(Exception e){ + log.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e, isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) + } + logDebug("======== COMPLETED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) + } + + public String buildSDNCRequest(Execution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("mso-request-id") + "-" + 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 = + """ + + ${requestId} + ${svcInstId} + ${action} + vnf-topology-operation + ${callbackURL} + generic-resource + + + + ${requestId} + DeleteVnfInstance + ${source} + + + + + + + + ${serviceInstanceId} + + + + ${vnfId} + + + + + ${tenantId} + ${cloudSiteId} + + + """ + + utils.logAudit("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(Execution execution, String response, String method){ + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + utils.logAudit("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + utils.logAudit("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) + }else{ + logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) + throw new BpmnError("MSOWorkflowException") + } + logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) + } + + + + + + + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index dd35334ddf..5bd9f96bc6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -365,7 +365,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String networkId = utils.getNodeText1(networkRequest, "network-id") networkId = UriUtils.encode(networkId,"UTF-8") execution.setVariable(Prefix + "networkId", networkId) - String messageId = execution.getVariable(Prefix + "messageId") // Prepare AA&I url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -433,7 +432,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String networkRequest = execution.getVariable(Prefix + "networkRequest") String networkId = utils.getNodeText1(networkRequest, "network-id") networkId = UriUtils.encode(networkId,"UTF-8") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare AA&I url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -509,7 +507,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -609,7 +606,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -643,7 +640,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -746,7 +742,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -780,7 +776,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -883,7 +878,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -922,7 +917,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") String updateNetworkResponse = execution.getVariable(Prefix + "updateNetworkResponse") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -935,7 +929,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG", " UPDNETI_updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest, isDebugEnabled) //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, updateNetworkResponse, schemaVersion) String payloadXml = utils.formatXml(payload) utils.logAudit(payloadXml) @@ -973,7 +967,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { // aai all errors String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode utils.log("DEBUG", errorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, "2500", errorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) } } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy index 5999857608..f07bb0df49 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy @@ -1,919 +1,921 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VfModule -import org.openecomp.mso.bpmn.common.scripts.VfModuleBase -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.rest.APIResponse -import org.springframework.web.util.UriUtils - -public class DoUpdateVfModule extends VfModuleBase { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - public void initProcessVariables(Execution 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_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(Execution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - initProcessVariables(execution) - def xml = getVariable(execution, 'DoUpdateVfModuleRequest') - utils.logAudit("DoUpdateVfModule request: " + xml) - logDebug('Received request xml:\n' + xml, isDebugLogEnabled) - - if (xml == null || xml.isEmpty()) { - // Building Block-type request - - String cloudConfiguration = execution.getVariable("cloudConfiguration") - String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") - - def serviceModelInfo = execution.getVariable("serviceModelInfo") - logDebug("serviceModelInfo: " + serviceModelInfo, isDebugLogEnabled) - def vnfModelInfo = execution.getVariable("vnfModelInfo") - - - //tenantId - def tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId") - execution.setVariable("DOUPVfMod_tenantId", tenantId) - - //volumeGroupId - def volumeGroupId = execution.getVariable("volumeGroupId") - execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId) - //volumeGroupName - def volumeGroupName = execution.getVariable("volumeGroupName") - execution.setVariable("DOUPVfMod_volumeGroupName", volumeGroupName) - //cloudSiteId - def cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId") - execution.setVariable("DOUPVfMod_cloudSiteId", cloudSiteId) - - logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled) - //vnfType - def vnfType = execution.getVariable("vnfType") - execution.setVariable("DOUPVfMod_vnfType", vnfType) - - logDebug("vnfType: " + vnfType, isDebugLogEnabled) - //vnfName - def vnfName = execution.getVariable("vnfName") - execution.setVariable("DOUPVfMod_vnfName", vnfName) - - logDebug("vnfName: " + vnfName, isDebugLogEnabled) - //vnfId - def vnfId = execution.getVariable("vnfId") - execution.setVariable("DOUPVfMod_vnfId", vnfId) - - logDebug("vnfId: " + vnfId, isDebugLogEnabled) - //vfModuleName - def vfModuleName = execution.getVariable("vfModuleName") - execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName) - - logDebug("vfModuleName: " + vfModuleName, isDebugLogEnabled) - //vfModuleModelName - def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") - execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName) - - logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled) - //modelCustomizationUuid - def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationId") - execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid) - - logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled) - //vfModuleId - def vfModuleId = execution.getVariable("vfModuleId") - execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId) - logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled) - def requestId = execution.getVariable("requestId") - execution.setVariable("DOUPVfMod_requestId", requestId) - logDebug("requestId: " + requestId, isDebugLogEnabled) - // 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) - logDebug("serviceId: " + serviceId, isDebugLogEnabled) - //serviceInstanceId - def serviceInstanceId = execution.getVariable("serviceInstanceId") - execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId) - - logDebug("serviceInstanceId: " + serviceInstanceId, isDebugLogEnabled) - //source - HARDCODED - def source = "VID" - execution.setVariable("DOUPVfMod_source", source) - - logDebug("source: " + source, isDebugLogEnabled) - //backoutOnFailure - def disableRollback = execution.getVariable("disableRollback") - def backoutOnFailure = true - if (disableRollback != null && disableRollback.equals("true")) { - backoutOnFailure = false - } - execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure) - logDebug("backoutOnFailure: " + backoutOnFailure, isDebugLogEnabled) - //isBaseVfModule - def isBaseVfModule = execution.getVariable("isBaseVfModule") - execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule) - logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled) - //asdcServiceModelVersion - def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") - execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion) - logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled) - //personaModelId - execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantId")) - //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() - logDebug("Generated messageId (UUID) is: " + uuid, isDebugLogEnabled) - }else{ - logDebug("Found messageId (UUID) is: " + uuid, isDebugLogEnabled) - } - //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("DOUPVfMod_globalSubscriberId", globalSubscriberId) - logDebug("globalSubsrciberId: " + globalSubscriberId, isDebugLogEnabled) - //vnfQueryPath - String vnfQueryPath = execution.getVariable("vnfQueryPath") - execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath) - logDebug("vnfQueryPath: " + vnfQueryPath, isDebugLogEnabled) - - String vnfParamsChildNodes = execution.getVariable("vfModuleInputParams") - execution.setVariable('DOUPVfMod_vnfParams', vnfParamsChildNodes) - } - 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) - } - logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled) - - 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) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { - def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' - logError(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) - } - } - - /** - * 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(Execution execution) { - def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DOUPVfMod_vnfId') - def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') - def orchestrationStatus = 'pending-update' - - String prepareUpdateAAIVfModuleRequest = """ - - ${vnfId} - ${vfModuleId} - ${orchestrationStatus} - - """ - prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest) - execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest) - utils.logAudit("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest) - logDebug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow. Currently, - * there is really nothing to do, so we just log that we're passing through. - * - * @param execution The flow's execution instance. - */ - public void prepConfirmVolumeGroupTenant(Execution execution) { - def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - // Nothing to do - just log that we're passing through here - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepConfirmVolumeGroupTenant(): ' + e.getMessage()) - } - } - - /** - * Prepare 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(Execution execution) { - def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestId = execution.getVariable('DOUPVfMod_requestId') - def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') - def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - 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') - - // 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 = """ - - - ${requestId} - ${serviceInstanceId} - changeassign - vnf-topology-operation - ${callbackUrl} - - - - ${requestId} - ChangeVNFActivateRequest - PORTAL - - - - - - ${serviceId} - ${vnfId} - dontcare - - - ${vfModuleId} - ${vfModuleModelName} - ${vfModuleName} - ${vnfId} - ${vnfName} - ${vnfType} - ${tenantId} - ${aicCloudRegion} - ${vnfNetworks} - - - - """ - sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) - execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest) - utils.logAudit("sdncChangeAssignRequest : " + sdncTopologyRequest) - logDebug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in 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(Execution execution) { - def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestId = execution.getVariable('DOUPVfMod_requestId') - def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') - def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - 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 = """ - - - ${requestId} - ${svcInstId} - query - /VNF-API:vnfs/vnf-list/${vfModuleId} - ${callbackUrl} - mobility - - - """ - sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) - execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest) - utils.logAudit("sdncTopologyRequest : " + sdncTopologyRequest) - logDebug('Request for SDNCAdapter query:\n' + sdncTopologyRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the VnfAdapterRest subflow. - * - * @param execution The flow's execution instance. - */ - public void prepVnfAdapterRest(Execution execution) { - def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - 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 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 vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') - def vfModuleParamsEntries = transformParamsToEntries(vnfParamsXml) - - def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) - def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") - if ('true'.equals(useQualifiedHostName)) { - notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) - } - - String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse') - - String vfModuleParams = buildVfModuleParams(vfModuleParamsEntries, sdncGetResponse, vnfId, vnfName, - vfModuleId, vfModuleName, null) - - - String vnfAdapterRestRequest = """ - - ${cloudId} - ${tenantId} - ${vnfId} - ${vfModuleId} - ${heatStackId} - ${vnfType} - ${asdcServiceModelVersion} - ${modelCustomizationUuid} - ${vfModuleModelName} - ${volumeGroupId} - ${baseVfModuleId} - ${baseVfModuleStackId} - true - ${backoutOnFailure} - false - - ${vfModuleParams} - - - ${requestId} - ${serviceInstanceId} - - ${messageId} - ${notificationUrl} - - """ - vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest) - execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest) - utils.logAudit("vnfAdapterRestRequest : " + vnfAdapterRestRequest) - logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateAAIGenericVnf(Execution execution) { - def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DOUPVfMod_vnfId') - def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs') - - def personaModelId = utils.getNodeText1(vnfInputs, 'vnf-persona-model-id') - def personaModelVersion = utils.getNodeText1(vnfInputs, 'vnf-persona-model-version') - if ((personaModelId == null) || (personaModelVersion == null)) { - logDebug('Skipping update for Generic VNF ' + vnfId + - ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent', isDebugLogEnabled) - execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true) - } else { - def personaModelIdElement = '' + personaModelId + '' - def personaModelVersionElement = '' + personaModelVersion + '' - - String updateAAIGenericVnfRequest = """ - - ${vnfId} - ${personaModelIdElement} - ${personaModelVersionElement} - - """ - updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) - execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) - utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) - logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the UpdateAAIVfModule subflow. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateAAIVfModule(Execution execution) { - def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - 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.getNodeText1(vnfInputs, 'persona-model-id') - if (personaModelId != null) { - personaModelIdElement = '' + personaModelId + '' - } - def personaModelVersionElement = '' - def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version') - if (personaModelVersion != null) { - personaModelVersionElement = '' + personaModelVersion + '' - } - def contrailServiceInstanceFqdnElement = '' - def contrailServiceInstanceFqdn = utils.getNodeText1(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 = """ - - ${vnfId} - ${vfModuleId} - ${orchestrationStatus} - ${volumeGroupIdElement} - ${personaModelIdElement} - ${personaModelVersionElement} - ${contrailServiceInstanceFqdnElement} - ${personaModelCustomizationIdElement} - - """ - updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) - execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest) - utils.logAudit("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest) - logDebug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in 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(Execution execution) { - def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestId = execution.getVariable('DOUPVfMod_requestId') - def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') - def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - 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') - - def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') - def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) - - String sdncTopologyRequest = """ - - - ${requestId} - ${serviceInstanceId} - activate - vnf-topology-operation - ${callbackUrl} - - - - ${requestId} - ChangeVNFActivateRequest - PORTAL - - - - - - ${serviceId} - ${vnfId} - dontcare - - - ${vfModuleId} - ${vfModuleModelName} - ${vfModuleName} - ${vnfId} - ${vnfName} - ${vnfType} - ${tenantId} - ${aicCloudRegion} - - - - """ - sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) - execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest) - utils.logAudit("sdncActivateRequest : " + sdncTopologyRequest) - logDebug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest, isDebugLogEnabled) - - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage()) - } - } - - /** - * Log a WorkflowException that has been created. - * - * @param execution The flow's execution instance. - */ - public void handleWorkflowException(Execution execution) { - def method = getClass().getSimpleName() + '.handleWorkflowException(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException') - logError(method + ' caught WorkflowException: ' + workflowException.getErrorMessage()) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage()) - } - } - - public void validateSDNCResponse(Execution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - def prefix = execution.getVariable("prefix") - - logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - utils.logAudit("workflowException: " + workflowException) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - utils.logAudit("SDNCResponse: " + response) - - String sdncResponse = response - if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){ - logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) - }else{ - logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - } - - /** - * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info. - * A 200 response is expected with the VNF info in the response body. Will find out the base module info. - * - * @param execution The flow's execution instance. - */ - public void queryAAIVfModule(Execution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - def method = getClass().getSimpleName() + '.getVfModule(' + - 'execution=' + execution.getId() + - ')' - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DOUPVfMod_vnfId') - def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) - - String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - utils.logAudit("AAI endPoint: " + endPoint) - - try { - def aaiRequestId = UUID.randomUUID().toString() - logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) - utils.logAudit("createVfModule - invoking httpGet() to AAI") - - def responseData = response.getResponseBodyAsString() - if (responseData != null) { - logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) - - } - - utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData) - utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) - - execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode()) - execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData) - logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) - logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) - if (response.getStatusCode() == 200) { - // Parse the VNF record from A&AI to find base module info - logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled) - if (responseData != null) { - def vfModulesText = utils.getNodeXml(responseData, "vf-modules") - 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.getNodeText1(vfModuleXml, "vf-module-id") - execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId) - logDebug('Received baseVfModuleId: ' + baseModuleId, isDebugLogEnabled) - String baseModuleHeatStackId = utils.getNodeText1(vfModuleXml, "heat-stack-id") - execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId) - logDebug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId, isDebugLogEnabled) - } - } - } - } - } catch (Exception ex) { - ex.printStackTrace() - logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) - } - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) - } - } - - -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.NetworkUtils +import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils +import org.openecomp.mso.bpmn.common.scripts.VfModule +import org.openecomp.mso.bpmn.common.scripts.VfModuleBase +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils; +import org.openecomp.mso.rest.APIResponse +import org.springframework.web.util.UriUtils + +public class DoUpdateVfModule extends VfModuleBase { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(Execution 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_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(Execution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + initProcessVariables(execution) + def xml = getVariable(execution, 'DoUpdateVfModuleRequest') + utils.logAudit("DoUpdateVfModule request: " + xml) + logDebug('Received request xml:\n' + xml, isDebugLogEnabled) + + if (xml == null || xml.isEmpty()) { + // Building Block-type request + + String cloudConfiguration = execution.getVariable("cloudConfiguration") + String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") + + def serviceModelInfo = execution.getVariable("serviceModelInfo") + logDebug("serviceModelInfo: " + serviceModelInfo, isDebugLogEnabled) + def vnfModelInfo = execution.getVariable("vnfModelInfo") + + + //tenantId + def tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId") + execution.setVariable("DOUPVfMod_tenantId", tenantId) + + //volumeGroupId + def volumeGroupId = execution.getVariable("volumeGroupId") + execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId) + //volumeGroupName + def volumeGroupName = execution.getVariable("volumeGroupName") + execution.setVariable("DOUPVfMod_volumeGroupName", volumeGroupName) + //cloudSiteId + def cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId") + execution.setVariable("DOUPVfMod_cloudSiteId", cloudSiteId) + + logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled) + //vnfType + def vnfType = execution.getVariable("vnfType") + execution.setVariable("DOUPVfMod_vnfType", vnfType) + + logDebug("vnfType: " + vnfType, isDebugLogEnabled) + //vnfName + def vnfName = execution.getVariable("vnfName") + execution.setVariable("DOUPVfMod_vnfName", vnfName) + + logDebug("vnfName: " + vnfName, isDebugLogEnabled) + //vnfId + def vnfId = execution.getVariable("vnfId") + execution.setVariable("DOUPVfMod_vnfId", vnfId) + + logDebug("vnfId: " + vnfId, isDebugLogEnabled) + //vfModuleName + def vfModuleName = execution.getVariable("vfModuleName") + execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName) + + logDebug("vfModuleName: " + vfModuleName, isDebugLogEnabled) + //vfModuleModelName + def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") + execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName) + + logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled) + //modelCustomizationUuid + def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationId") + execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid) + + logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled) + //vfModuleId + def vfModuleId = execution.getVariable("vfModuleId") + execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId) + logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled) + def requestId = execution.getVariable("requestId") + execution.setVariable("DOUPVfMod_requestId", requestId) + logDebug("requestId: " + requestId, isDebugLogEnabled) + // 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) + logDebug("serviceId: " + serviceId, isDebugLogEnabled) + //serviceInstanceId + def serviceInstanceId = execution.getVariable("serviceInstanceId") + execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId) + + logDebug("serviceInstanceId: " + serviceInstanceId, isDebugLogEnabled) + //source - HARDCODED + def source = "VID" + execution.setVariable("DOUPVfMod_source", source) + + logDebug("source: " + source, isDebugLogEnabled) + //backoutOnFailure + def disableRollback = execution.getVariable("disableRollback") + def backoutOnFailure = true + if (disableRollback != null && disableRollback.equals("true")) { + backoutOnFailure = false + } + execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure) + logDebug("backoutOnFailure: " + backoutOnFailure, isDebugLogEnabled) + //isBaseVfModule + def isBaseVfModule = execution.getVariable("isBaseVfModule") + execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule) + logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled) + //asdcServiceModelVersion + def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") + execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion) + logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled) + //personaModelId + execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantId")) + //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() + logDebug("Generated messageId (UUID) is: " + uuid, isDebugLogEnabled) + }else{ + logDebug("Found messageId (UUID) is: " + uuid, isDebugLogEnabled) + } + //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("DOUPVfMod_globalSubscriberId", globalSubscriberId) + logDebug("globalSubsrciberId: " + globalSubscriberId, isDebugLogEnabled) + //vnfQueryPath + String vnfQueryPath = execution.getVariable("vnfQueryPath") + execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath) + logDebug("vnfQueryPath: " + vnfQueryPath, isDebugLogEnabled) + + Map vfModuleInputParams = execution.getVariable("vfModuleInputParams") + if (vfModuleInputParams != null) { + execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams) + } + } + 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) + } + logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled) + + 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) execution.getVariable('URN_mso_workflow_sdncadapter_callback') + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) + } + } + + /** + * 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(Execution execution) { + def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('DOUPVfMod_vnfId') + def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') + def orchestrationStatus = 'pending-update' + + String prepareUpdateAAIVfModuleRequest = """ + + ${vnfId} + ${vfModuleId} + ${orchestrationStatus} + + """ + prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest) + execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest) + utils.logAudit("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest) + logDebug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest, isDebugLogEnabled) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow. Currently, + * there is really nothing to do, so we just log that we're passing through. + * + * @param execution The flow's execution instance. + */ + public void prepConfirmVolumeGroupTenant(Execution execution) { + def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + // Nothing to do - just log that we're passing through here + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepConfirmVolumeGroupTenant(): ' + e.getMessage()) + } + } + + /** + * Prepare 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(Execution execution) { + def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def requestId = execution.getVariable('DOUPVfMod_requestId') + def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') + def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') + 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') + + // 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 = """ + + + ${requestId} + ${serviceInstanceId} + changeassign + vnf-topology-operation + ${callbackUrl} + + + + ${requestId} + ChangeVNFActivateRequest + PORTAL + + + + + + ${serviceId} + ${vnfId} + dontcare + + + ${vfModuleId} + ${vfModuleModelName} + ${vfModuleName} + ${vnfId} + ${vnfName} + ${vnfType} + ${tenantId} + ${aicCloudRegion} + ${vnfNetworks} + + + + """ + sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) + execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest) + utils.logAudit("sdncChangeAssignRequest : " + sdncTopologyRequest) + logDebug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest, isDebugLogEnabled) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in 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(Execution execution) { + def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def requestId = execution.getVariable('DOUPVfMod_requestId') + def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') + def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') + 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 = """ + + + ${requestId} + ${svcInstId} + query + /VNF-API:vnfs/vnf-list/${vfModuleId} + ${callbackUrl} + mobility + + + """ + sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) + execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest) + utils.logAudit("sdncTopologyRequest : " + sdncTopologyRequest) + logDebug('Request for SDNCAdapter query:\n' + sdncTopologyRequest, isDebugLogEnabled) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the VnfAdapterRest subflow. + * + * @param execution The flow's execution instance. + */ + public void prepVnfAdapterRest(Execution execution) { + def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + 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 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 = execution.getVariable("URN_mso_use_qualified_host") + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + Map vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap") + + String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse') + + String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName, + vfModuleId, vfModuleName, null) + + + String vnfAdapterRestRequest = """ + + ${cloudId} + ${tenantId} + ${vnfId} + ${vfModuleId} + ${heatStackId} + ${vnfType} + ${asdcServiceModelVersion} + ${modelCustomizationUuid} + ${vfModuleModelName} + ${volumeGroupId} + ${baseVfModuleId} + ${baseVfModuleStackId} + true + ${backoutOnFailure} + false + + ${vfModuleParams} + + + ${requestId} + ${serviceInstanceId} + + ${messageId} + ${notificationUrl} + + """ + vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest) + execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest) + utils.logAudit("vnfAdapterRestRequest : " + vnfAdapterRestRequest) + logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIGenericVnf(Execution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('DOUPVfMod_vnfId') + def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs') + + def personaModelId = utils.getNodeText1(vnfInputs, 'vnf-persona-model-id') + def personaModelVersion = utils.getNodeText1(vnfInputs, 'vnf-persona-model-version') + if ((personaModelId == null) || (personaModelVersion == null)) { + logDebug('Skipping update for Generic VNF ' + vnfId + + ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent', isDebugLogEnabled) + execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true) + } else { + def personaModelIdElement = '' + personaModelId + '' + def personaModelVersionElement = '' + personaModelVersion + '' + + String updateAAIGenericVnfRequest = """ + + ${vnfId} + ${personaModelIdElement} + ${personaModelVersionElement} + + """ + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) + logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled) + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) + } + } + + /** + * Prepare a Request for invoking the UpdateAAIVfModule subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIVfModule(Execution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + 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.getNodeText1(vnfInputs, 'persona-model-id') + if (personaModelId != null) { + personaModelIdElement = '' + personaModelId + '' + } + def personaModelVersionElement = '' + def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version') + if (personaModelVersion != null) { + personaModelVersionElement = '' + personaModelVersion + '' + } + def contrailServiceInstanceFqdnElement = '' + def contrailServiceInstanceFqdn = utils.getNodeText1(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 = """ + + ${vnfId} + ${vfModuleId} + ${orchestrationStatus} + ${volumeGroupIdElement} + ${personaModelIdElement} + ${personaModelVersionElement} + ${contrailServiceInstanceFqdnElement} + ${personaModelCustomizationIdElement} + + """ + + logDebug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest, isDebugLogEnabled) + updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) + execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest) + utils.logAudit("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest) + logDebug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest, isDebugLogEnabled) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in 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(Execution execution) { + def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def requestId = execution.getVariable('DOUPVfMod_requestId') + def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') + def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') + 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') + + def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') + def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) + + String sdncTopologyRequest = """ + + + ${requestId} + ${serviceInstanceId} + activate + vnf-topology-operation + ${callbackUrl} + + + + ${requestId} + ChangeVNFActivateRequest + PORTAL + + + + + + ${serviceId} + ${vnfId} + dontcare + + + ${vfModuleId} + ${vfModuleModelName} + ${vfModuleName} + ${vnfId} + ${vnfName} + ${vnfType} + ${tenantId} + ${aicCloudRegion} + + + + """ + sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) + execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest) + utils.logAudit("sdncActivateRequest : " + sdncTopologyRequest) + logDebug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest, isDebugLogEnabled) + + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage()) + } + } + + /** + * Log a WorkflowException that has been created. + * + * @param execution The flow's execution instance. + */ + public void handleWorkflowException(Execution execution) { + def method = getClass().getSimpleName() + '.handleWorkflowException(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException') + logError(method + ' caught WorkflowException: ' + workflowException.getErrorMessage()) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage()) + } + } + + public void validateSDNCResponse(Execution execution, String response, String method){ + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def prefix = execution.getVariable("prefix") + + logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + utils.logAudit("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + utils.logAudit("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){ + logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) + }else{ + logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) + throw new BpmnError("MSOWorkflowException") + } + logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) + } + + /** + * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info. + * A 200 response is expected with the VNF info in the response body. Will find out the base module info. + * + * @param execution The flow's execution instance. + */ + public void queryAAIVfModule(Execution execution) { + def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def method = getClass().getSimpleName() + '.getVfModule(' + + 'execution=' + execution.getId() + + ')' + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + def vnfId = execution.getVariable('DOUPVfMod_vnfId') + def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') + + AaiUtil aaiUriUtil = new AaiUtil(this) + String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) + + String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + utils.logAudit("AAI endPoint: " + endPoint) + + try { + def aaiRequestId = UUID.randomUUID().toString() + logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) + utils.logAudit("createVfModule - invoking httpGet() to AAI") + + def responseData = response.getResponseBodyAsString() + if (responseData != null) { + logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) + + } + + utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData) + utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) + + execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + if (response.getStatusCode() == 200) { + // Parse the VNF record from A&AI to find base module info + logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled) + if (responseData != null) { + def vfModulesText = utils.getNodeXml(responseData, "vf-modules") + 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.getNodeText1(vfModuleXml, "vf-module-id") + execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId) + logDebug('Received baseVfModuleId: ' + baseModuleId, isDebugLogEnabled) + String baseModuleHeatStackId = utils.getNodeText1(vfModuleXml, "heat-stack-id") + execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId) + logDebug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId, isDebugLogEnabled) + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace() + logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) + } + } + + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfra.groovy deleted file mode 100644 index 5f0f65bd85..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfra.groovy +++ /dev/null @@ -1,1639 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.common.scripts.AaiUtil; -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils; -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -/** - * This groovy class supports the UpdateNetworkInstanceInfra.bpmn process. - */ -public class UpdateNetworkInstanceInfra extends AbstractServiceTaskProcessor { - 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 UpdateNetworkInstanceInfra.bpmn process. - * @param execution - */ - public InitializeProcessVariables(Execution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable("UPDNETI_messageId", "") - execution.setVariable("BasicAuthHeaderValuePO", "") - execution.setVariable("BasicAuthHeaderValueSDNC", "") - execution.setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", "") - execution.setVariable("UPDNETI_networkRequest", "") - execution.setVariable("UPDNETI_networkInputs", "") - execution.setVariable("UPDNETI_networkOutputs", "") - execution.setVariable("UPDNETI_requestId", "") - execution.setVariable("UPDNETI_source", "") - execution.setVariable("UPDNETI_networkId", "") - - execution.setVariable("UPDNETI_CompleteMsoProcessRequest", "") - execution.setVariable("UPDNETI_FalloutHandlerRequest", "") - execution.setVariable("UPDNETI_isSilentSuccess", false) - execution.setVariable("UPDNETI_isPONR", false) // Point-of-no-return, means, rollback is not needed - - // AAI query Cloud Region - execution.setVariable("UPDNETI_queryCloudRegionRequest","") - execution.setVariable("UPDNETI_queryCloudRegionReturnCode","") - execution.setVariable("UPDNETI_queryCloudRegionResponse","") - execution.setVariable("UPDNETI_cloudRegionPo","") - execution.setVariable("UPDNETI_cloudRegionSdnc","") - execution.setVariable("UPDNETI_isCloudRegionGood", false) - - // AAI query Id - execution.setVariable("UPDNETI_queryIdAAIRequest","") - execution.setVariable("UPDNETI_queryIdAAIResponse", "") - execution.setVariable("UPDNETI_aaiIdReturnCode", "") - - // AAI query vpn binding - execution.setVariable("UPDNETI_queryVpnBindingAAIRequest","") - execution.setVariable("UPDNETI_queryVpnBindingAAIResponse", "") - execution.setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "") - execution.setVariable("UPDNETI_vpnBindings", null) - execution.setVariable("UPDNETI_vpnCount", 0) - execution.setVariable("UPDNETI_routeCollection", "") - - // AAI query network policy - execution.setVariable("UPDNETI_queryNetworkPolicyAAIRequest","") - execution.setVariable("UPDNETI_queryNetworkPolicyAAIResponse", "") - execution.setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", "") - execution.setVariable("UPDNETI_networkPolicyUriList", null) - execution.setVariable("UPDNETI_networkPolicyCount", 0) - execution.setVariable("UPDNETI_networkCollection", "") - - // AAI query route table reference - execution.setVariable("UPDNETI_queryNetworkTableRefAAIRequest","") - execution.setVariable("UPDNETI_queryNetworkTableRefAAIResponse", "") - execution.setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", "") - execution.setVariable("UPDNETI_networkTableRefUriList", null) - execution.setVariable("UPDNETI_networkTableRefCount", 0) - execution.setVariable("UPDNETI_tableRefCollection", "") - - // AAI requery Id - execution.setVariable("UPDNETI_requeryIdAAIRequest","") - execution.setVariable("UPDNETI_requeryIdAAIResponse", "") - execution.setVariable("UPDNETI_aaiRequeryIdReturnCode", "") - - // AAI update contrail - execution.setVariable("UPDNETI_updateContrailAAIUrlRequest","") - execution.setVariable("UPDNETI_updateContrailAAIPayloadRequest","") - execution.setVariable("UPDNETI_updateContrailAAIResponse", "") - execution.setVariable("UPDNETI_aaiUpdateContrailReturnCode", "") - - execution.setVariable("UPDNETI_updateNetworkRequest", "") - execution.setVariable("UPDNETI_updateNetworkResponse", "") - execution.setVariable("UPDNETI_rollbackNetworkRequest", "") - execution.setVariable("UPDNETI_rollbackNetworkResponse", "") - execution.setVariable("UPDNETI_networkReturnCode", "") - execution.setVariable("UPDNETI_rollbackNetworkReturnCode", "") - execution.setVariable("UPDNETI_isNetworkRollbackNeeded", false) - - execution.setVariable("UPDNETI_changeAssignSDNCRequest", "") - execution.setVariable("UPDNETI_changeAssignSDNCResponse", "") - execution.setVariable("UPDNETI_rollbackSDNCRequest", "") - execution.setVariable("UPDNETI_rollbackSDNCResponse", "") - execution.setVariable("UPDNETI_sdncReturnCode", "") - execution.setVariable("UPDNETI_rollbackSDNCReturnCode", "") - execution.setVariable("UPDNETI_isSdncRollbackNeeded", false) - execution.setVariable("UPDNETI_sdncResponseSuccess", false) - - execution.setVariable("UPDNETI_updateDBRequest", "") - execution.setVariable("UPDNETI_updateDBResponse", "") - execution.setVariable("UPDNETI_dbReturnCode", "") - - execution.setVariable("UPDNETI_isVnfBindingPresent", false) - execution.setVariable("UPDNETI_Success", false) - execution.setVariable("UPDNETI_serviceInstanceId", "") - execution.setVariable("GENGS_type", "service-instance") // Setting for Generic Sub Flow use - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the UpdateNetworkInstanceInfra.bpmn process. - * @param execution - */ - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest UpdateNetworkInstanceInfra Request ***** ", isDebugEnabled) - - // initialize flow variables - InitializeProcessVariables(execution) - - // get Incoming request & validate json format - String updateNetworkJsonIncoming = execution.getVariable("bpmnRequest") - utils.logAudit(updateNetworkJsonIncoming) - try { - def prettyJson = JsonOutput.prettyPrint(updateNetworkJsonIncoming.toString()) - utils.log("DEBUG", " Incoming message formatted . . . : " + '\n' + prettyJson, isDebugEnabled) - - } catch (Exception ex) { - String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = execution.getVariable("URN_mso_adapters_po_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for PO/SDNC adapter: " + basicAuthValuePO, isDebugEnabled) - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, , isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - try { - // Catalog DB headers Authorization - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - try { - - execution.setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", updateNetworkJsonIncoming) - - // recreate the xml network-request - String networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, updateNetworkJsonIncoming) - execution.setVariable("UPDNETI_networkRequest", networkRequest) - utils.log("DEBUG", " network-request - " + '\n' + networkRequest, isDebugEnabled) - - String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","") - execution.setVariable("UPDNETI_networkInputs", networkInputs) - utils.log("DEBUG", " networkInputs - " + '\n' + networkInputs, isDebugEnabled) - - String netId = utils.getNodeText1(networkRequest, "network-id") - String netName = utils.getNodeText1(networkRequest, "network-name") - String networkOutputs = - """ - ${netId} - ${netName} - """ - execution.setVariable("UPDNETI_networkOutputs", networkOutputs) - utils.log("DEBUG", " networkOutputs - " + '\n' + networkOutputs, isDebugEnabled) - - String requestId = execution.getVariable("mso-request-id") - if (requestId == null || requestId == "") { - requestId = execution.getVariable("requestId") - } - execution.setVariable("UPDNETI_requestId", requestId) - execution.setVariable("UPDNETI_source", utils.getNodeText1(networkRequest, "source")) - - // prepare messageId - String messageId = execution.getVariable("UPDNETI_messageId") // for testing - if (messageId == null || messageId == "") { - messageId = UUID.randomUUID() - utils.log("DEBUG", " UPDNETI_messageId, random generated: " + messageId, isDebugEnabled) - } else { - utils.log("DEBUG", " UPDNETI_messageId, pre-assigned: " + messageId, isDebugEnabled) - } - execution.setVariable("UPDNETI_messageId", messageId) - - // validate 'backout-on-failure' to override 'URN_mso_rollback' - boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest) - execution.setVariable("UPDNETI_rollbackEnabled", rollbackEnabled) - - String networkId = "" - if (utils.nodeExists(networkRequest, "network-id")) { - networkId = utils.getNodeText1(networkRequest, "network-id") - if (networkId == 'null' || networkId == "") { - sendSyncError(execution) - // missing value of networkId - String dataErrorMessage = "Variable 'network-id' value/element is missing." - utils.log("DEBUG", " Invalid Request - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - - String lcpCloudRegion = "" - if (utils.nodeExists(networkRequest, "aic-cloud-region")) { - lcpCloudRegion = utils.getNodeText1(networkRequest, "aic-cloud-region") - if ((lcpCloudRegion == 'null') || (lcpCloudRegion == "")) { - sendSyncError(execution) - String dataErrorMessage = "requestDetails has missing 'aic-cloud-region' value/element." - utils.log("DEBUG", " Invalid Request - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } - - String serviceInstanceId = "" - if (utils.nodeExists(networkRequest, "service-instance-id")) { - serviceInstanceId = utils.getNodeText1(networkRequest, "service-instance-id") - if ((serviceInstanceId == 'null') || (lcpCloudRegion == "")) { - sendSyncError(execution) - String dataErrorMessage = "Variable 'serviceInstanceId' value/element is missing." - utils.log("DEBUG", " Invalid Request - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } - - execution.setVariable("UPDNETI_serviceInstanceId", serviceInstanceId) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex){ - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in UpdateNetworkInstanceInfra, PreProcessRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncResponse of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - try { - String serviceInstanceId = execution.getVariable("UPDNETI_serviceInstanceId") - String requestId = execution.getVariable("mso-request-id") - - // RESTResponse (for API Handler (APIH) Reply Task) - String updateNetworkRestRequest = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " sendSyncResponse to APIH - " + "\n" + updateNetworkRestRequest, isDebugEnabled) - sendWorkflowResponse(execution, 202, updateNetworkRestRequest) - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstanceInfra flow. sendSyncResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - } - - public void callRESTQueryAAICloudRegion (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAICloudRegion of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - String networkInputs = execution.getVariable("UPDNETI_networkInputs") - String cloudRegion = utils.getNodeText1(networkInputs, "aic-cloud-region") - cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - utils.logAudit(queryCloudRegionRequest) - execution.setVariable("UPDNETI_queryCloudRegionRequest", queryCloudRegionRequest) - utils.log("DEBUG", " UPDNETI_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugEnabled) - - String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) - String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) - - if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { - execution.setVariable("UPDNETI_cloudRegionPo", cloudRegionPo) - execution.setVariable("UPDNETI_cloudRegionSdnc", cloudRegionSdnc) - execution.setVariable("UPDNETI_isCloudRegionGood", true) - - } else { - String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable("UPDNETI_queryCloudRegionReturnCode") - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - - utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable("UPDNETI_isCloudRegionGood"), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // try error - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstanceInfra flow - callRESTQueryAAICloudRegion() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkId(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkId of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - // get variables - String networkRequest = execution.getVariable("UPDNETI_networkRequest") - String networkId = utils.getNodeText1(networkRequest, "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - execution.setVariable("UPDNETI_networkId", networkId) - String messageId = execution.getVariable("UPDNETI_messageId") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId - utils.logAudit(queryIdAAIRequest) - execution.setVariable("UPDNETI_queryIdAAIRequest", queryIdAAIRequest) - utils.log("DEBUG", " UPDNETI_queryIdAAIRequest - " + "\n" + queryIdAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_aaiIdReturnCode", returnCode) - - utils.log("DEBUG", " ***** AAI Response Code : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable("UPDNETI_queryIdAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " QueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString, isDebugEnabled) - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)." - utils.log("DEBUG", " AAI Query Failed. " + dataErrorMessage, isDebugEnabled) - 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 - utils.log("DEBUG", "Unexpected Response from QueryAAINetworkId - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstanceInfra flow. callRESTQueryAAINetworkId() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTReQueryAAINetworkId(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTReQueryAAINetworkId of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - // get variables - String networkId = utils.getNodeText1(execution.getVariable("UPDNETI_changeAssignSDNCResponse"), "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - String messageId = execution.getVariable("UPDNETI_messageId") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId - utils.logAudit(requeryIdAAIRequest) - execution.setVariable("UPDNETI_requeryIdAAIRequest", requeryIdAAIRequest) - utils.log("DEBUG", " UPDNETI_requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_aaiRequeryIdReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI ReQuery Response Code : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable("UPDNETI_requeryIdAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " ReQueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString, isDebugEnabled) - - String netId = utils.getNodeText1(aaiResponseAsString, "network-id") - String netName = utils.getNodeText1(aaiResponseAsString, "network-name") - String networkOutputs = - """ - ${netId} - ${netName} - """ - execution.setVariable("UPDNETI_networkOutputs", networkOutputs) - utils.log("DEBUG", " networkOutputs - " + '\n' + networkOutputs, isDebugEnabled) - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)." - utils.log("DEBUG", " AAI ReQuery Failed. - " + dataErrorMessage, isDebugEnabled) - 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 - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstanceInfra flow. callRESTReQueryAAINetworkId() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkVpnBinding(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkVpnBinding of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - - // get variables - String messageId = execution.getVariable("UPDNETI_messageId") - String queryIdAAIResponse = execution.getVariable("UPDNETI_requeryIdAAIResponse").replace('', "") - String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") - utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) - - // Check if Vnf Binding is present, then build a List of vnfBinding - List vpnBindingUri = networkUtils.getVnfBindingObject(relationship) - int vpnCount = vpnBindingUri.size() - execution.setVariable("UPDNETI_vpnCount", vpnCount) - utils.log("DEBUG", " UPDNETI_vpnCount - " + vpnCount, isDebugEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - - if (vpnCount > 0) { - execution.setVariable("UPDNETI_vpnBindings", vpnBindingUri) - utils.log("DEBUG", " vpnBindingUri List - " + vpnBindingUri, isDebugEnabled) - - 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) - } else { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] - } - - } 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 - } - - utils.logAudit(queryVpnBindingAAIRequest) - execution.setVariable("UPDNETI_queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) - utils.log("DEBUG", " UPDNETI_queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable("UPDNETI_queryVpnBindingAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled) - - String routeTarget = "" - if (utils.nodeExists(aaiResponseAsString, "global-route-target")) { - routeTarget = utils.getNodeText1(aaiResponseAsString, "global-route-target") - routeTargets += "" + routeTarget + "" + '\n' - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - 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 - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } // end loop - - execution.setVariable("UPDNETI_routeCollection", routeTargets) - utils.log("DEBUG", " UPDNETI_routeCollection - " + '\n' + routeTargets, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) - String aaiStubResponse = - """ - - - - """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable("UPDNETI_queryVpnBindingAAIResponse", aaiStubResponseAsXml) - execution.setVariable("UPDNETI_routeCollection", "") - utils.log("DEBUG", " No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstanceInfra flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkPolicy(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkPolicy of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - // get variables - String messageId = execution.getVariable("UPDNETI_messageId") - String queryIdAAIResponse = execution.getVariable("UPDNETI_requeryIdAAIResponse").replace('', "") - String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") - utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) - - // Check if Network Policy is present, then build a List of network policy - List networkPolicyUriList = networkUtils.getNetworkPolicyObject(relationship) - int networkPolicyCount = networkPolicyUriList.size() - execution.setVariable("UPDNETI_networkPolicyCount", networkPolicyCount) - utils.log("DEBUG", " UPDNETI_networkPolicyCount - " + networkPolicyCount, isDebugEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - - if (networkPolicyCount > 0) { - execution.setVariable("UPDNETI_networkPolicyUriList", networkPolicyUriList) - utils.log("DEBUG", " networkPolicyUri List - " + networkPolicyUriList, isDebugEnabled) - - 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) - } else { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] - } - } 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 - - } - - - utils.logAudit(queryNetworkPolicyAAIRequest) - execution.setVariable("UPDNETI_queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) - utils.log("DEBUG", " UPDNETI_queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable("UPDNETI_queryNetworkPolicyAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " QueryAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled) - - String networkPolicy = "" - if (utils.nodeExists(aaiResponseAsString, "network-policy-fqdn")) { - networkPolicy = utils.getNodeText1(aaiResponseAsString, "network-policy-fqdn") - networkPolicies += "" + networkPolicy + "" + '\n' - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - 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 - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } // end loop - - execution.setVariable("UPDNETI_networkCollection", networkPolicies) - utils.log("DEBUG", " UPDNETI_networkCollection - " + '\n' + networkPolicies, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) - String aaiStubResponse = - """ - - - - """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable("UPDNETI_queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) - execution.setVariable("UPDNETI_networkCollection", "") - utils.log("DEBUG", " No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstanceInfra flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkTableRef(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkTableRef of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - // get variables - String messageId = execution.getVariable("UPDNETI_messageId") - String queryIdAAIResponse = execution.getVariable("UPDNETI_requeryIdAAIResponse").replace('', "") - String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") - utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) - - // Check if Network TableREf is present, then build a List of network policy - List networkTableRefUriList = networkUtils.getNetworkTableRefObject(relationship) - int networkTableRefCount = networkTableRefUriList.size() - execution.setVariable("UPDNETI_networkTableRefCount", networkTableRefCount) - utils.log("DEBUG", " UPDNETI_networkTableRefCount - " + networkTableRefCount, isDebugEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - - if (networkTableRefCount > 0) { - execution.setVariable("UPDNETI_networkTableRefUriList", networkTableRefUriList) - utils.log("DEBUG", " networkTableRefUri List - " + networkTableRefUriList, isDebugEnabled) - - // 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) - } else { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] - } - } 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 - - } - - - utils.logAudit(queryNetworkTableRefAAIRequest) - execution.setVariable("UPDNETI_queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) - utils.log("DEBUG", " UPDNETI_queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkTableRefAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI query network Table Reference Response Code, NetworkTableRef #" + counting + " : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable("UPDNETI_queryNetworkTableRefAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " QueryAAINetworkTableRef Success REST Response, , NetworkTableRef #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled) - - String networkTableRef = "" - if (utils.nodeExists(aaiResponseAsString, "route-table-reference-fqdn")) { - networkTableRef = utils.getNodeText1(aaiResponseAsString, "route-table-reference-fqdn") - networkTableRefs += "" + networkTableRef + "" + '\n' - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - 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 - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } // end loop - - execution.setVariable("UPDNETI_tableRefCollection", networkTableRefs) - utils.log("DEBUG", " UPDNETI_tableRefCollection - " + '\n' + networkTableRefs, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) - String aaiStubResponse = - """ - - - - """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable("UPDNETI_queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) - execution.setVariable("UPDNETI_tableRefCollection", "") - utils.log("DEBUG", " No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstanceInfra flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTUpdateContrailAAINetwork(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTUpdateContrailAAINetwork of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - // get variables - String networkId = utils.getNodeText1(execution.getVariable("UPDNETI_changeAssignSDNCResponse"), "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - String requeryIdAAIResponse = execution.getVariable("UPDNETI_requeryIdAAIResponse") - String updateNetworkResponse = execution.getVariable("UPDNETI_updateNetworkResponse") - String messageId = execution.getVariable("UPDNETI_messageId") - - // Prepare url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId - - utils.logAudit(updateContrailAAIUrlRequest) - execution.setVariable("UPDNETI_updateContrailAAIUrlRequest", updateContrailAAIUrlRequest) - utils.log("DEBUG", " UPDNETI_updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest, isDebugEnabled) - - //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) - String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, updateNetworkResponse, schemaVersion) - String payloadXml = utils.formatXml(payload) - utils.logAudit(payloadXml) - execution.setVariable("UPDNETI_updateContrailAAIPayloadRequest", payloadXml) - utils.log("DEBUG", " 'payload' to Update Contrail - " + "\n" + payloadXml, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, updateContrailAAIUrlRequest, payload) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_aaiUpdateContrailReturnCode", returnCode) - - utils.log("DEBUG", " ***** AAI Update Contrail Response Code : " + returnCode, isDebugEnabled) - - String aaiUpdateContrailResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiUpdateContrailResponseAsString) - execution.setVariable("UPDNETI_updateContrailAAIResponse", aaiUpdateContrailResponseAsString) - utils.log("DEBUG", " AAI Update Contrail Success REST Response - " + "\n" + aaiUpdateContrailResponseAsString, isDebugEnabled) - // Point-of-no-return is set to false, rollback not needed. - execution.setVariable("UPDNETI_isPONR", true) - - } else { - if (returnCode=='404') { - String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - 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 - utils.log("DEBUG", errorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, "2500", errorMessage) - } - } - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstanceInfra flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareUpdateNetworkRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareUpdateNetworkRequest of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - try { - - // get variables - String requestId = execution.getVariable("UPDNETI_requestId") - String messageId = execution.getVariable("UPDNETI_messageId") - String source = execution.getVariable("UPDNETI_source") - - String requestInput = execution.getVariable("UPDNETI_networkRequest") - String queryIdResponse = execution.getVariable("UPDNETI_requeryIdAAIResponse") - String cloudRegionId = execution.getVariable("UPDNETI_cloudRegionPo") - String backoutOnFailure = execution.getVariable("UPDNETI_rollbackEnabled") - - // Prepare Network request - String routeCollection = execution.getVariable("UPDNETI_routeCollection") - String policyCollection = execution.getVariable("UPDNETI_networkCollection") - String tableCollection = execution.getVariable("UPDNETI_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:", "") - utils.logAudit(buildUpdateNetworkRequestAsString) - - execution.setVariable("UPDNETI_updateNetworkRequest", buildUpdateNetworkRequestAsString) - utils.log("DEBUG", " UPDNETI_updateNetworkRequest - " + "\n" + buildUpdateNetworkRequestAsString, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. prepareUpdateNetworkRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareSDNCRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareSDNCRequest of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - try { - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String updateNetworkInput = execution.getVariable("UPDNETI_networkRequest") - String cloudRegionId = execution.getVariable("UPDNETI_cloudRegionSdnc") - - String networkId = "" - if (utils.nodeExists(updateNetworkInput, "network-id")) { - networkId = utils.getNodeText1(updateNetworkInput, "network-id") - } - if (networkId == null) {networkId = ""} - - String serviceInstanceId = utils.getNodeText1(updateNetworkInput, "service-instance-id") - - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, updateNetworkInput, serviceInstanceId, sdncCallback, "changeassign", "NetworkActivateRequest", cloudRegionId, networkId, null, null) - - String sndcTopologyUpdateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - utils.logAudit(sndcTopologyUpdateRequesAsString) - execution.setVariable("UPDNETI_changeAssignSDNCRequest", sndcTopologyUpdateRequesAsString) - utils.log("DEBUG", " UPDNETI_changeAssignSDNCRequest - " + "\n" + sndcTopologyUpdateRequesAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. prepareSDNCRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareDBRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - // Catalog DB headers Authorization - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequest of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - String networkOutputs = execution.getVariable("UPDNETI_networkOutputs") - String networkName = "" - try { - networkName = utils.getNodeText1(networkOutputs, "network-name") - if (networkName == null) {networkName = ""} - } catch (Exception ex) { - networkName = "" - utils.log("DEBUG", " No 'network-name' found in '' ! ", isDebugEnabled) - } - String networkId = "" - try { - networkId = utils.getNodeText1(networkOutputs, "network-id") - if (networkId == null) {networkId = ""} - } catch (Exception) { - networkId = "" - utils.log("DEBUG", " No 'network-id' found in '' ! ", isDebugEnabled) - } - String requestId = execution.getVariable("UPDNETI_requestId") - - String statusMessage = "Network successfully updated." - - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - COMPLETED - 100 - <network-id>${networkId}</network-id><network-name>${networkName}</network-names> - ${networkId} - - - """ - - String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) - execution.setVariable("UPDNETI_updateDBRequest", buildDeleteDBRequestAsString) - utils.log("DEBUG", " DB Adapter Request - " + "\n" + buildDeleteDBRequestAsString, isDebugEnabled) - utils.logAudit(buildDeleteDBRequestAsString) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. prepareDBRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareDBRequestError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - // Catalog DB headers Authorization - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequestError of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - String statusMessage = "" - WorkflowException wfe = null - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - wfe = execution.getVariable("WorkflowException") - statusMessage = wfe.getErrorMessage() - } else { - String workflowException = execution.getVariable("WorkflowException") - try { - statusMessage = utils.getNodeText1(workflowException, "ErrorMessage") - } catch (Exception ex) { - statusMessage = "Encountered Error during DB Update. " + ex.getMessage() - } - } - String networkOutputs = execution.getVariable("UPDNETI_networkOutputs") - String requestId = execution.getVariable("UPDNETI_requestId") - String networkId = "" - try { - networkId = utils.getNodeText1(networkOutputs, "network-id") - if (networkId == null) {networkId = ""} - } catch (Exception) { - networkId = "" - utils.log("DEBUG", " No 'network-id' found in '' ! ", isDebugEnabled) - } - String networkName = "" - try { - networkName = utils.getNodeText1(networkOutputs, "network-name") - if (networkName == null) {networkName = ""} - } catch (Exception ex) { - networkName = "" - utils.log("DEBUG", " No 'network-name' found in '' ! ", isDebugEnabled) - } - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - FAILED - <network-id>${networkId}</network-id><network-name>${networkName}</network-names> - - - """ - - execution.setVariable("UPDNETI_updateDBRequest", dbRequest) - utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled) - utils.logAudit(dbRequest) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. prepareDBRequestError() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - // ************************************************** - // Post or Validate Response Section - // ************************************************** - - public void validateUpdateNetworkResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside validateUpdateNetworkResponse of UpdateNetworkInstanceInfra *****", isDebugEnabled) - - try { - String returnCode = execution.getVariable("UPDNETI_networkReturnCode") - String networkResponse = execution.getVariable("UPDNETI_updateNetworkResponse") - if (networkResponse==null) { - networkResponse="" // reset - } - - utils.log("DEBUG", " Network Adapter update responseCode: " + returnCode, isDebugEnabled) - - String errorMessage = "" - if (returnCode == "200") { - execution.setVariable("UPDNETI_isNetworkRollbackNeeded", true) - utils.logAudit(networkResponse) - execution.setVariable("UPDNETI_updateNetworkResponse", networkResponse) - utils.log("DEBUG", " Network Adapter update Success Response - " + "\n" + networkResponse, isDebugEnabled) - - // prepare rollback data - String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") - String rollbackNetwork = - """ - ${rollbackData} - """ - String rollbackNetworkXml = utils.formatXml(rollbackNetwork) - execution.setVariable("UPDNETI_rollbackNetworkRequest", rollbackNetworkXml) - utils.log("DEBUG", " Network Adapter rollback data - " + "\n" + rollbackNetworkXml, isDebugEnabled) - - } else { // network error - if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx - if (networkResponse.contains("updateNetworkError")) { - networkResponse = networkResponse.replace('', '') - errorMessage = utils.getNodeText1(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 UpdateNetworkInstanceInfra flow. validateUpdateNetworkResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - public void validateSDNCResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside validateSDNCResponse of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - String response = execution.getVariable("UPDNETI_changeAssignSDNCResponse") - WorkflowException workflowException = null - try { - workflowException = execution.getVariable("UPDNETI_WorkflowException") - //execution.setVariable("WorkflowException", workflowException) - } catch (Exception ex) { - utils.log("DEBUG", " Sdnc 'WorkflowException' object is empty or null. ", isDebugEnabled) - } - - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String changeAssignSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable("UPDNETI_changeAssignSDNCResponse")) - changeAssignSDNCResponseDecodeXml = changeAssignSDNCResponseDecodeXml.replace("&", "&").replace('', "") - execution.setVariable("UPDNETI_changeAssignSDNCResponse", changeAssignSDNCResponseDecodeXml) - - if (execution.getVariable("UPDNETI_sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess' - execution.setVariable("UPDNETI_isSdncRollbackNeeded", true) - utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled) - - } else { - utils.log("DEBUG", "Did NOT Successfully Validated SDNC Response", isDebugEnabled) - throw new BpmnError("MSOWorkflowException") - } - - } - - - public void postProcessResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside postProcessResponse of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - try { - // Display DB response: UPDNETI_updateDBResponse / UPDNETI_dbReturnCode - String dbReturnCode = execution.getVariable("UPDNETI_dbReturnCode") - utils.log("DEBUG", " ***** DB Update Response Code : " + dbReturnCode, isDebugEnabled) - String updateDBResponse = execution.getVariable("UPDNETI_updateDBResponse") - utils.log("DEBUG", " ***** DB Update Response String: " + '\n' + updateDBResponse, isDebugEnabled) - utils.logAudit(updateDBResponse) - - String source = execution.getVariable("UPDNETI_source") - String requestId = execution.getVariable("UPDNETI_requestId") - - String msoCompletionRequest = - """ - - ${requestId} - UPDATE - ${source} - - BPMN Network action: UPDATE - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - if (dbReturnCode == "200") { - utils.logAudit(updateDBResponse) - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable("UPDNETI_Success", true) - execution.setVariable("UPDNETI_CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } else { - String errorMessage = " DB Update failed, code: " + dbReturnCode - utils.log("DEBUG", errorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - - } - - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. postProcessResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - public void prepareSDNCRollbackRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareSDNCRollbackRequest of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - try { - // for some reason the WorkflowException object is null after the sdnc rollback call task, need to save WorkflowException. - execution.setVariable("UPDNETI_WorkflowException", execution.getVariable("WorkflowException")) - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String updateNetworkInput = execution.getVariable("UPDNETI_networkRequest") - String cloudRegionId = execution.getVariable("UPDNETI_cloudRegionSdnc") - String changeAssignSDNCResponse = execution.getVariable("UPDNETI_changeAssignSDNCResponse") - String networkId = utils.getNodeText1(changeAssignSDNCResponse, "network-id") - - String serviceInstanceId = utils.getNodeText1(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("UPDNETI_rollbackSDNCRequest", sndcTopologyRollbackRequestAsString) - utils.log("DEBUG", " Preparing request for SDNC Topology assign's rollback/compensation . . . - " + "\n" + sndcTopologyRollbackRequestAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. prepareSDNCRollbackRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void validateRollbackResponses (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - // Note: Updates do not support rollback. To restore a previous state, another Update would be needed to revert to the original settings. - // This would need to be managed by the client. - String rollbackNetworkErrorMessages = "" - Boolean isNetworkRollbackNeeded = execution.getVariable("UPDNETI_isNetworkRollbackNeeded") - if (isNetworkRollbackNeeded == true) { - rollbackNetworkErrorMessages = " + PO Network rollback is not supported for Update. Submit another Update to restore/rollback." - } - - // validate SDNC rollback response - String rollbackSdncErrorMessages = "" - Boolean isSdncRollbackNeeded = execution.getVariable("UPDNETI_isSdncRollbackNeeded") - if (isSdncRollbackNeeded == true) { - String rollbackSDNCReturnCode = execution.getVariable("UPDNETI_rollbackSDNCReturnCode") - String rollbackSDNCReturnInnerCode = "" - String rollbackSDNCResponse = execution.getVariable("UPDNETI_rollbackSDNCResponse") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - rollbackSDNCResponse = sdncAdapterUtils.decodeXML(rollbackSDNCResponse) - rollbackSDNCResponse = rollbackSDNCResponse.replace("&", "&").replace('$', '').replace('', "") - - if (rollbackSDNCReturnCode == "200") { - if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { - rollbackSDNCReturnInnerCode = utils.getNodeText1(rollbackSDNCResponse, "response-code") - if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") { - rollbackSdncErrorMessages = " + SNDC rollback completed." - } else { - rollbackSdncErrorMessages = " + SDNC rollback failed. " - } - } else { - rollbackSdncErrorMessages = " + SNDC rollback completed." - } - } else { - rollbackSdncErrorMessages = " + SDNC rollback failed. " - } - - utils.log("DEBUG", " SDNC rollback Code - " + rollbackSDNCReturnCode, isDebugEnabled) - utils.log("DEBUG", " SDNC rollback Response - " + rollbackSDNCResponse, isDebugEnabled) - - } - - //WorkflowException wfe = execution.getVariable("WorkflowException") - //String statusMessage = wfe.getErrorMessage() - //int errorCode = wfe.getErrorCode() - - String statusMessage = "" - int errorCode = 0 - WorkflowException wfe = execution.getVariable("WorkflowException") - if (wfe instanceof WorkflowException) { - statusMessage = wfe.getErrorMessage() - errorCode = wfe.getErrorCode() - } else { - if (execution.getVariable("UPDNETI_WorkflowException") instanceof WorkflowException) { - // get saved WorkflowException - WorkflowException swfe = execution.getVariable("UPDNETI_WorkflowException") - statusMessage = swfe.getErrorMessage() - errorCode = swfe.getErrorCode() - } else { - statusMessage = "Encountered Error, please see previous tasks/activities/steps for error messages." - errorCode = 7000 - } - } - - // recreate WorkflowException to include the rollback Message - statusMessage = statusMessage + rollbackNetworkErrorMessages + rollbackSdncErrorMessages - exceptionUtil.buildWorkflowException(execution, errorCode, statusMessage) - - } catch (Exception ex) { - execution.setVariable("WorkflowException", null) - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. validateRollbackResponses() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - - - } - - // ******************************* - // Build Error Section - // ******************************* - - // Prepare for FalloutHandler - public void buildErrorResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. *****", isDebugEnabled) - - String dbReturnCode = execution.getVariable("UPDNETI_dbReturnCode") - utils.log("DEBUG", " ***** DB Update Response Code : " + dbReturnCode, isDebugEnabled) - String updateDBResponse = execution.getVariable("UPDNETI_updateDBResponse") - utils.log("DEBUG", " ***** DB Update Response String: " + '\n' + updateDBResponse, isDebugEnabled) - utils.logAudit(updateDBResponse) - - String falloutHandlerRequest = "" - String requestId = execution.getVariable("UPDNETI_requestId") - String source = execution.getVariable("UPDNETI_source") - try { - execution.setVariable("UPDNETI_Success", false) - WorkflowException wfe = execution.getVariable("WorkflowException") - String errorCode = String.valueOf(wfe.getErrorCode()) - String errorMessage = wfe.getErrorMessage() - falloutHandlerRequest = - """ - - ${requestId} - UPDATE - ${source} - - - ${errorMessage} - ${errorCode} - - """ - - utils.logAudit(falloutHandlerRequest) - execution.setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - - } catch (Exception ex) { - String errorException = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - utils.log("DEBUG", errorException, isDebugEnabled) - falloutHandlerRequest = - """ - - ${requestId} - UPDATE - ${source} - - - ${errorException} - 7000 - - """ - - execution.setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - - } - - } - - - public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - 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) { - utils.log("DEBUG", " Bpmn error encountered in UpdateNetworkInstanceInfra flow. sendSyncError() - " + ex.getMessage(), isDebugEnabled) - } - - } - - - public void processJavaException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("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){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - 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") - } - utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModule.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModule.groovy index d428cc33dd..5c313775dd 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModule.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModule.groovy @@ -1,24 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.infrastructure.scripts import groovy.util.Node import groovy.util.XmlParser; @@ -29,11 +29,11 @@ import java.io.Serializable; import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils; +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.openecomp.mso.bpmn.core.RollbackData public class UpdateVfModule extends AbstractServiceTaskProcessor { @@ -204,7 +204,7 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { String updateInfraRequest = """ + xmlns:req="http://org.openecomp.mso/requestsdb"> @@ -255,8 +255,8 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { def requestInfo = getVariable(execution, 'UPDVfMod_requestInfo') String content = """ - + ${requestInfo} MSO_ACTIVATE_BPEL @@ -304,10 +304,10 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { } String content = """ - + ${requestInformation} ${encErrorResponseMsg} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy index 6d532527d0..9ca247714b 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy @@ -1,24 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.infrastructure.scripts import java.util.concurrent.ExecutionException; @@ -26,12 +26,12 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution import org.apache.commons.lang3.* import org.springframework.web.util.UriUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.VfModuleBase -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil +import org.openecomp.mso.bpmn.common.scripts.AaiUtil +import org.openecomp.mso.bpmn.common.scripts.VfModuleBase +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils; +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil class UpdateVfModuleVolume extends VfModuleBase { @@ -130,7 +130,7 @@ class UpdateVfModuleVolume extends VfModuleBase { def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs') String synchResponse = """ - + ${requestId} UPDATE_VF_MODULE_VOL @@ -238,7 +238,7 @@ class UpdateVfModuleVolume extends VfModuleBase { def requestId = execution.getVariable('UPDVfModVol_requestId') def serviceId = execution.getVariable('UPDVfModVol_serviceId') - def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") if ('true'.equals(useQualifiedHostName)) { @@ -297,7 +297,7 @@ class UpdateVfModuleVolume extends VfModuleBase { String updateInfraRequest = """ + xmlns:req="http://org.openecomp.mso/requestsdb"> @@ -340,8 +340,8 @@ class UpdateVfModuleVolume extends VfModuleBase { def requestInfo = execution.getVariable('UPDVfModVol_requestInfo') String content = """ - + ${requestInfo} MSO_ACTIVATE_BPEL @@ -385,10 +385,10 @@ class UpdateVfModuleVolume extends VfModuleBase { } String content = """ - + ${requestInfo} ${encErrorResponseMsg} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn new file mode 100644 index 0000000000..dbd40c072e --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn @@ -0,0 +1,336 @@ + + + + + SequenceFlow_0lp2z7l + + + + SequenceFlow_10 + SequenceFlow_14 + + + + + SequenceFlow_10 + + + + + SequenceFlow_14 + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0eto8sn + 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_0eto8sn + + + + + SequenceFlow_1lj31zp + SequenceFlow_1o4wwba + SequenceFlow_1mdnv3l + + + SequenceFlow_1mdnv3l + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn index 7b9b8212e5..a3a36529da 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn @@ -1,1203 +1,1243 @@ - - - - - SequenceFlow_7 - SequenceFlow_3 + + + + + SequenceFlow_7 + SequenceFlow_3 - - - - SequenceFlow_1 - - - - SequenceFlow_1 - SequenceFlow_7 +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.sendSyncResponse(execution)]]> + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_7 - - - +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.preProcessRequest(execution) +]]> + + + SequenceFlow_10o22u2 - - - - SequenceFlow_0afe2pg - SequenceFlow_29 + + + + SequenceFlow_0afe2pg + SequenceFlow_29 - - - - - - - - - - - - - - SequenceFlow_29 - SequenceFlow_8 - - - - SequenceFlow_8 - SequenceFlow_6 - - - - - SequenceFlow_6 - - - - - SequenceFlow_2 - - - - SequenceFlow_5 - - - - SequenceFlow_2 - SequenceFlow_5 +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.postProcessResponse(execution)]]> + + + + + + + + + + + + + + SequenceFlow_29 + SequenceFlow_8 + + + + SequenceFlow_8 + SequenceFlow_6 + + + + + SequenceFlow_6 + + + + + SequenceFlow_2 + + + + SequenceFlow_5 + + + + SequenceFlow_2 + SequenceFlow_5 - - - - - SequenceFlow_12ilko1 - - - - - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_1bwbn7r - SequenceFlow_12ag2bk - - - SequenceFlow_0cmebdc - SequenceFlow_0dfkfh1 - SequenceFlow_1bwbn7r +def CreateServiceInstanceInfra = new CreateServiceInstanceInfra() +CreateServiceInstanceInfra.processJavaException(execution)]]> + + + + + SequenceFlow_12ilko1 + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1bwbn7r + SequenceFlow_12ag2bk + + + SequenceFlow_0cmebdc + SequenceFlow_0dfkfh1 + SequenceFlow_1bwbn7r - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_0j6sjye - SequenceFlow_1ky2sv9 - - - - - - - - - - - - - - - - - - - - SequenceFlow_1h77psn - SequenceFlow_0qi5uxg - - - SequenceFlow_0bvecvm - SequenceFlow_1h77psn +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.prepareNetworkCreate(execution)]]> + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0j6sjye + SequenceFlow_1ky2sv9 + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1h77psn + SequenceFlow_0qi5uxg + + + SequenceFlow_0bvecvm + SequenceFlow_1h77psn - - - SequenceFlow_0xowenu - - - - SequenceFlow_3 - - - - - SequenceFlow_0zq7i3q - SequenceFlow_0zpbskl - SequenceFlow_0dhf2js - - - SequenceFlow_0zq7i3q - - - - SequenceFlow_0zpbskl - SequenceFlow_1sx5llu - SequenceFlow_02o4yqx - - - SequenceFlow_0sdb3on - SequenceFlow_05lo85t - SequenceFlow_0xtr1g5 - - - SequenceFlow_05lo85t - SequenceFlow_09xerwk - SequenceFlow_19mxskt - SequenceFlow_0tmepzk - - - - - - - - - - - SequenceFlow_0807ukc - SequenceFlow_19yywk8 - - - SequenceFlow_19yywk8 - - - SequenceFlow_19mxskt - SequenceFlow_1brxd2r - SequenceFlow_08s0ew2 - - - SequenceFlow_0jg47xm - SequenceFlow_0807ukc +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.prepareVnfAndModulesCreate(execution)]]> + + + SequenceFlow_0xowenu + + + + SequenceFlow_3 + + + + + SequenceFlow_0zq7i3q + SequenceFlow_0zpbskl + SequenceFlow_0dhf2js + + + SequenceFlow_0zq7i3q + + + + SequenceFlow_0zpbskl + SequenceFlow_1sx5llu + SequenceFlow_02o4yqx + + + SequenceFlow_0sdb3on + SequenceFlow_05lo85t + SequenceFlow_0xtr1g5 + + + SequenceFlow_05lo85t + SequenceFlow_09xerwk + SequenceFlow_19mxskt + SequenceFlow_0tmepzk + + + + + + + + + + + SequenceFlow_0807ukc + SequenceFlow_19yywk8 + + + SequenceFlow_19yywk8 + + + SequenceFlow_19mxskt + SequenceFlow_1brxd2r + SequenceFlow_08s0ew2 + + + SequenceFlow_0jg47xm + SequenceFlow_0807ukc - - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_0xtr1g5 - SequenceFlow_09xerwk - - - - - - - - - - - SequenceFlow_0136s37 - SequenceFlow_1fqmrda - SequenceFlow_1dmsx0d - - - SequenceFlow_1ieiew4 - SequenceFlow_1os9x7w - SequenceFlow_0g7scsg - - - - - - - - - - SequenceFlow_1os9x7w - SequenceFlow_1f1hd3l - - - SequenceFlow_1sx5llu - SequenceFlow_0dhf2js - SequenceFlow_1rabks0 - SequenceFlow_0jg47xm - - - - - - - - - - - SequenceFlow_1dmsx0d - SequenceFlow_1otyild +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.prepareFalloutRequest(execution)]]> + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0xtr1g5 + SequenceFlow_09xerwk + + + + + + + + + + + SequenceFlow_0136s37 + SequenceFlow_1fqmrda + SequenceFlow_1dmsx0d + + + SequenceFlow_1ieiew4 + SequenceFlow_1os9x7w + SequenceFlow_0g7scsg + + + + + + + + + + SequenceFlow_1os9x7w + SequenceFlow_1f1hd3l + + + SequenceFlow_1sx5llu + SequenceFlow_0dhf2js + SequenceFlow_1rabks0 + SequenceFlow_0jg47xm + + + + + + + + + + + SequenceFlow_1dmsx0d + SequenceFlow_1otyild - - - SequenceFlow_1otyild - SequenceFlow_0136s37 - SequenceFlow_12u8ufr - - - - - 0 }]]> - - - - SequenceFlow_0tmepzk - SequenceFlow_1fqmrda - SequenceFlow_1brxd2r - - - - - - - - - - SequenceFlow_12u8ufr - SequenceFlow_08s0ew2 - SequenceFlow_1ieiew4 - SequenceFlow_0sezboq - - - - - - - - - SequenceFlow_1f1hd3l - SequenceFlow_0g7scsg - SequenceFlow_0sezboq - SequenceFlow_0f4u373 - - - SequenceFlow_02o4yqx - SequenceFlow_0sdb3on +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.validateNetworkRollback(execution)]]> + + + SequenceFlow_1otyild + SequenceFlow_0136s37 + SequenceFlow_12u8ufr + + + + + 0 }]]> + + + + SequenceFlow_0tmepzk + SequenceFlow_1fqmrda + SequenceFlow_1brxd2r + + + + + + + + + + SequenceFlow_12u8ufr + SequenceFlow_08s0ew2 + SequenceFlow_1ieiew4 + SequenceFlow_0sezboq + + + + + + + + + SequenceFlow_1f1hd3l + SequenceFlow_0g7scsg + SequenceFlow_0sezboq + SequenceFlow_0f4u373 + + + SequenceFlow_02o4yqx + SequenceFlow_0sdb3on - - - SequenceFlow_0f4u373 - SequenceFlow_1rabks0 +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.preProcessRollback(execution)]]> + + + SequenceFlow_0f4u373 + SequenceFlow_1rabks0 - - - - - - - SequenceFlow_1vwssu7 - SequenceFlow_19etqmx +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.postProcessRollback(execution)]]> + + + + + + + SequenceFlow_1vwssu7 + SequenceFlow_19etqmx - - - SequenceFlow_10o22u2 - SequenceFlow_0j6sjye +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.getDataFromDecomposition(execution)]]> + + + SequenceFlow_0hvcwa1 + SequenceFlow_0j6sjye - - - - SequenceFlow_12ilko1 - SequenceFlow_0afe2pg - - - - - - - - - SequenceFlow_1vwssu7 - - - - SequenceFlow_13uceka - - - - SequenceFlow_19etqmx - SequenceFlow_0cmebdc - SequenceFlow_1f26zbk - - - SequenceFlow_04vlq8r - SequenceFlow_1n7r495 - SequenceFlow_0dfkfh1 - - - - - - 0}]]> - - - SequenceFlow_1n7r495 - SequenceFlow_1f26zbk - SequenceFlow_1j7n6qx - - - - SequenceFlow_1j7n6qx - - - - - - - SequenceFlow_10tbv62 - - - - SequenceFlow_10tbv62 - SequenceFlow_0bvecvm - SequenceFlow_0w7328u - - - SequenceFlow_0qi5uxg - SequenceFlow_0w7328u - SequenceFlow_0xowenu - - - - 0}]]> - - - in 1702 scope only one VNF will be created - - - - - SequenceFlow_12ag2bk - SequenceFlow_04vlq8r +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.prepareCreateServiceInstance(execution)]]> + + + SequenceFlow_12ilko1 + SequenceFlow_0afe2pg + + + + + + + + + SequenceFlow_1vwssu7 + + + + SequenceFlow_13uceka + + + + SequenceFlow_19etqmx + SequenceFlow_0cmebdc + SequenceFlow_1f26zbk + + + SequenceFlow_04vlq8r + SequenceFlow_1n7r495 + SequenceFlow_0dfkfh1 + + + + + + 0}]]> + + + SequenceFlow_1n7r495 + SequenceFlow_1f26zbk + SequenceFlow_1j7n6qx + + + + SequenceFlow_1j7n6qx + + + + + + + SequenceFlow_10tbv62 + + + + SequenceFlow_10tbv62 + SequenceFlow_0bvecvm + SequenceFlow_0w7328u + + + SequenceFlow_0qi5uxg + SequenceFlow_0w7328u + SequenceFlow_0xowenu + + + + 0}]]> + + + in 1702 scope only one VNF will be created + + + + + SequenceFlow_12ag2bk + SequenceFlow_04vlq8r - - - - - - - - - ${URN_mso_adapters_db_endpoint} - - - - application/soap+xml - - - POST - - soap-http-connector - - - SequenceFlow_0vj46ej - SequenceFlow_13uceka - - - - SequenceFlow_1ky2sv9 - SequenceFlow_0vj46ej +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.validateNetworkCreate(execution)]]> + + + + + + + + + ${URN_mso_adapters_db_endpoint} + + + + application/soap+xml + + + POST + + soap-http-connector + + + SequenceFlow_0vj46ej + SequenceFlow_13uceka + + + + SequenceFlow_1ky2sv9 + SequenceFlow_0vj46ej - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.postProcessServiceInstanceCreate(execution)]]> + + + + + + + + + + + + + + SequenceFlow_00h6hmd + SequenceFlow_0hvcwa1 + + + SequenceFlow_1eu60rt + SequenceFlow_00h6hmd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateServiceInstance.bpmn deleted file mode 100644 index fa114c5e76..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateServiceInstance.bpmn +++ /dev/null @@ -1,336 +0,0 @@ - - - - - SequenceFlow_0lp2z7l - - - - SequenceFlow_10 - SequenceFlow_14 - - - - - SequenceFlow_10 - - - - - SequenceFlow_14 - - - - - - - - - - - - - - - - - - - - - SequenceFlow_0eto8sn - 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_0eto8sn - - - - - SequenceFlow_1lj31zp - SequenceFlow_1o4wwba - SequenceFlow_1mdnv3l - - - SequenceFlow_1mdnv3l - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn index 7a8133ec7f..c58fec9dd9 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn @@ -1,22 +1,42 @@ - + SequenceFlow_1 - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_7 SequenceFlow_4 @@ -28,17 +48,17 @@ def createVfModule = new CreateVfModuleInfra() createVfModule.sendResponse(execution)]]> - + SequenceFlow_4 - + - + SequenceFlow_5 - + - + SequenceFlow_5 SequenceFlow_6 @@ -49,7 +69,6 @@ createVfModule.prepareUpdateInfraRequest(execution)]]> - http-connector ${URN_mso_adapters_db_endpoint} @@ -62,13 +81,14 @@ createVfModule.prepareUpdateInfraRequest(execution)]]> ${statusCode} ${response} + http-connector SequenceFlow_6 SequenceFlow_8 - - + + updateInfraRequestResponseGood SequenceFlow_12 @@ -76,15 +96,15 @@ createVfModule.prepareUpdateInfraRequest(execution)]]> def createVfModule = new CreateVfModuleInfra() createVfModule.postProcessResponse(execution)]]> - + - - - - - - + + + + + + SequenceFlow_12 SequenceFlow_14 @@ -94,13 +114,13 @@ createVfModule.postProcessResponse(execution)]]> updateInfraRequestResponseBad updateInfraRequestResponseGood - + updateInfraRequestResponseBad - + @@ -110,37 +130,37 @@ createVfModule.postProcessResponse(execution)]]> def createVfModule = new CreateVfModuleInfra() createVfModule.validateRollbackResponse(execution)]]> - + - - - - + + + + SequenceFlow_19 SequenceFlow_17 - + SequenceFlow_13 - + - + - - - - + + + + SequenceFlow_10 SequenceFlow_11 - + SequenceFlow_11 - + SequenceFlow_22 @@ -149,19 +169,19 @@ createVfModule.validateRollbackResponse(execution)]]> def cvfm = new CreateVfModuleInfra() cvfm.falloutHandlerPrep(execution, 'CVFMI_FalloutHandlerRequest')]]> - + SequenceFlow_21 isRollbackOnNoSequenceFlow SequenceFlow_22 - + SequenceFlow_13 isRollbackOnNoSequenceFlow IsRollbackOnYesSequenceFlow - + IsRollbackOnYesSequenceFlow SequenceFlow_19 @@ -172,7 +192,7 @@ cvfm.logAndSaveOriginalException(execution)]]> - + SequenceFlow_14 @@ -181,18 +201,18 @@ cvfm.logAndSaveOriginalException(execution)]]> SequenceFlow_16 - + - - + + SequenceFlow_15 - + - + SequenceFlow_15 - + SequenceFlow_1 @@ -201,272 +221,272 @@ cvfm.logAndSaveOriginalException(execution)]]> def createVfModule = new CreateVfModuleInfra() createVfModule.preProcessRequest(execution)]]> - + - - + + - + - - + + - + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - - + + - - - - + + + + - + - - - - + + + + - + - - - - + + + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - + - + - - + + - - + + - + - + - + - + - + - - - - + + + + - + - - - - + + + + - + - - - + + + - + - - - - + + + + - + - + - - + + - + - + - - + + - + - - + + - \ No newline at end of file + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn index e8d27b6014..b10e98b56f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn @@ -23,7 +23,7 @@ createVnf.sendSyncResponse(execution)]]> - + @@ -31,12 +31,13 @@ createVnf.sendSyncResponse(execution)]]> - + + SequenceFlow_3 SequenceFlow_0lso26t diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DelServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DelServiceInstance.bpmn deleted file mode 100644 index 4488e8de1c..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DelServiceInstance.bpmn +++ /dev/null @@ -1,331 +0,0 @@ - - - - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn new file mode 100644 index 0000000000..ceb0c72218 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/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/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn index eeb32599d3..bb2c487e8a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn @@ -1,771 +1,773 @@ - - - - - SequenceFlow_7 - SequenceFlow_3 + + + + + SequenceFlow_7 + SequenceFlow_3 - - - - SequenceFlow_1 - - - - SequenceFlow_1 - SequenceFlow_7 +def DeleteGenericMacroServiceNetworkVnf = new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.sendSyncResponse(execution)]]> + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_7 - - - - SequenceFlow_10o22u2 - - - - SequenceFlow_12ilko1 - SequenceFlow_29 +def DeleteGenericMacroServiceNetworkVnf = new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.preProcessRequest(execution) +]]> + + + + SequenceFlow_10o22u2 + + + + SequenceFlow_12ilko1 + SequenceFlow_29 - - - - - - - - - - - - - - SequenceFlow_29 - SequenceFlow_8 - - - - SequenceFlow_8 - SequenceFlow_6 - - - - - SequenceFlow_6 - - - - - SequenceFlow_2 - - - - SequenceFlow_5 - - - - SequenceFlow_2 - SequenceFlow_5 +def DeleteGenericMacroServiceNetworkVnf = new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.postProcessResponse(execution)]]> + + + + + + + + + + + + + + SequenceFlow_29 + SequenceFlow_8 + + + + SequenceFlow_8 + SequenceFlow_6 + + + + + SequenceFlow_6 + + + + + SequenceFlow_2 + + + + SequenceFlow_5 + + + + SequenceFlow_2 + SequenceFlow_5 - - - - - SequenceFlow_12ilko1 - - - - - - - - - - - - - - - - - - - SequenceFlow_1bwbn7r - SequenceFlow_12ag2bk - - - SequenceFlow_0cmebdc - SequenceFlow_0dfkfh1 - SequenceFlow_1bwbn7r +def DeleteServiceInstanceInfra = new DeleteServiceInstanceInfra() +DeleteServiceInstanceInfra.processJavaException(execution)]]> + + + + + SequenceFlow_12ilko1 + + + + + + + + + + + + + + + + + + + SequenceFlow_1bwbn7r + SequenceFlow_12ag2bk + + + SequenceFlow_0cmebdc + SequenceFlow_0dfkfh1 + SequenceFlow_1bwbn7r - - - - - - - - - - - - - - SequenceFlow_10o22u2 - SequenceFlow_04ao07f - - - - - - - - - - - - - - SequenceFlow_1h77psn - SequenceFlow_1dmn40p - - - SequenceFlow_0bvecvm - SequenceFlow_0mr8jgt - SequenceFlow_1h77psn +def DeleteGenericMacroServiceNetworkVnf= new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.prepareNetworkDelete(execution)]]> + + + + + + + + + + + + + + SequenceFlow_10o22u2 + SequenceFlow_04ao07f + + + + + + + + + + + + + + + + SequenceFlow_1h77psn + SequenceFlow_1dmn40p + + + SequenceFlow_0bvecvm + SequenceFlow_0mr8jgt + SequenceFlow_1h77psn - - - SequenceFlow_0xowenu - - - - SequenceFlow_3 - - - - - SequenceFlow_06llof4 - - - - - - - - - - - - SequenceFlow_0807ukc - SequenceFlow_19yywk8 - - - SequenceFlow_19yywk8 - - - SequenceFlow_06llof4 - SequenceFlow_0807ukc +def DeleteGenericMacroServiceNetworkVnf= new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.prepareVnfAndModulesDelete(execution)]]> + + + SequenceFlow_0xowenu + + + + SequenceFlow_3 + + + + + SequenceFlow_06llof4 + + + + + + + + + + + + SequenceFlow_0807ukc + SequenceFlow_19yywk8 + + + SequenceFlow_19yywk8 + + + SequenceFlow_06llof4 + SequenceFlow_0807ukc - - - - - - - - - - - - SequenceFlow_1vwssu7 - - - - SequenceFlow_04ao07f - - - - SequenceFlow_1vwssu7 - SequenceFlow_0cmebdc - SequenceFlow_1f26zbk - - - SequenceFlow_04vlq8r - SequenceFlow_1n7r495 - SequenceFlow_0dfkfh1 - - - - - - 0}]]> - - - SequenceFlow_1n7r495 - SequenceFlow_1f26zbk - SequenceFlow_1j7n6qx - - - - SequenceFlow_1j7n6qx - - - - - - SequenceFlow_10tbv62 - - - - SequenceFlow_10tbv62 - SequenceFlow_0bvecvm - SequenceFlow_0w7328u - - - SequenceFlow_0w7328u - SequenceFlow_1wc8h5g - SequenceFlow_0xowenu - - - - 0}]]> - - - - - SequenceFlow_12ag2bk - SequenceFlow_04vlq8r +def DeleteGenericMacroServiceNetworkVnf = new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.prepareFalloutRequest(execution)]]> + + + + + + + + + + + + SequenceFlow_1vwssu7 + + + + SequenceFlow_04ao07f + + + + SequenceFlow_1vwssu7 + SequenceFlow_0cmebdc + SequenceFlow_1f26zbk + + + SequenceFlow_04vlq8r + SequenceFlow_1n7r495 + SequenceFlow_0dfkfh1 + + + + + + 0}]]> + + + SequenceFlow_1n7r495 + SequenceFlow_1f26zbk + SequenceFlow_1j7n6qx + + + + SequenceFlow_1j7n6qx + + + + + + SequenceFlow_10tbv62 + + + + SequenceFlow_10tbv62 + SequenceFlow_0bvecvm + SequenceFlow_0w7328u + + + SequenceFlow_0w7328u + SequenceFlow_1wc8h5g + SequenceFlow_0xowenu + + + + 0}]]> + + + + + SequenceFlow_12ag2bk + SequenceFlow_04vlq8r - - - - - - - - - - - - - - - SequenceFlow_0jek18q - SequenceFlow_1ttswdr - - - SequenceFlow_1ttswdr - SequenceFlow_18103ca +def DeleteGenericMacroServiceNetworkVnf= new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.validateNetworkDelete(execution)]]> + + + + + + + + + + + + + + + SequenceFlow_0jek18q + SequenceFlow_1ttswdr + + + SequenceFlow_1ttswdr + SequenceFlow_18103ca - - - SequenceFlow_0jek18q - - - - SequenceFlow_18103ca - - - - - - - - SequenceFlow_1dmn40p - SequenceFlow_0g2cw86 +def DeleteGenericMacroServiceNetworkVnf = new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.prepareServiceInstanceDelete(execution)]]> + + + SequenceFlow_0jek18q + + + + SequenceFlow_18103ca + + + + + + + + SequenceFlow_1dmn40p + SequenceFlow_0g2cw86 - - - SequenceFlow_0g2cw86 - SequenceFlow_0mr8jgt - SequenceFlow_1wc8h5g - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +def DeleteGenericMacroServiceNetworkVnf= new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.validateVnfDelete(execution)]]> + + + SequenceFlow_0g2cw86 + SequenceFlow_0mr8jgt + SequenceFlow_1wc8h5g + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVnfInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVnfInfra.bpmn index b5b10a0fda..95c0a727ce 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVnfInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVnfInfra.bpmn @@ -129,7 +129,7 @@ deleteVnf.prepareCompletionHandlerRequest(execution)]]> - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstanceInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstanceInfra.bpmn deleted file mode 100644 index f49149b709..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstanceInfra.bpmn +++ /dev/null @@ -1,1014 +0,0 @@ - - - - - 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_27 - SequenceFlow_29 - - - - - - SequenceFlow_23 - isRollbackOn_YesNetwork_SequenceFlow - isRollbackOn_NoNetwork_SequenceFlow - - - - - - - SequenceFlow_23 - - - - - isRollbackOn_YesNetwork_SequenceFlow - isPONR_Yes_SequenceFlow - isPONR_No_SequenceFlow - - - - - - - isPONR_No_SequenceFlow - isNetworkOk_No_SequenceFlow - isNetworkOk_Yes_SequenceFlow - - - - - - - isNetworkOk_No_SequenceFlow - isNetworkOk_Yes_SequenceFlow - sdncOk_Yeso_ExclusiveGateway - sdncOk_No_ExclusiveGateway - - - - - - - sdncOk_Yeso_ExclusiveGateway - SequenceFlow_53 - - - - - SequenceFlow_53 - SequenceFlow_55 - - - - - SequenceFlow_47 - SequenceFlow_22 - - - - - - - http-connector - - ${URN_mso_adapters_db_endpoint} - ${UPDNETI_updateDBRequest} - - - application/soap+xml - - - POST - ${response} - ${statusCode} - - - - SequenceFlow_22 - SequenceFlow_19 - - - - - - - - - - - - - - SequenceFlow_25 - SequenceFlow_18 - - - - SequenceFlow_18 - - - SequenceFlow_55 - sdncOk_No_ExclusiveGateway - SequenceFlow_4 - - - - - isRollbackOn_NoNetwork_SequenceFlow - isPONR_Yes_SequenceFlow - SequenceFlow_4 - SequenceFlow_47 - - - - SequenceFlow_19 - SequenceFlow_25 - - - - - - SequenceFlow_13 - SequenceFlow_35 - - - - - SequenceFlow_35 - SequenceFlow_46 - - - - - SequenceFlow_46 - SequenceFlow_37 - - - - - - - http-connector - - ${URN_mso_adapters_db_endpoint} - ${UPDNETI_updateDBRequest} - - - application/soap+xml - - - POST - ${response} - ${statusCode} - - - - SequenceFlow_37 - SequenceFlow_27 - - - - - - - - - - - - - - SequenceFlow_29 - SequenceFlow_17 - - - - SequenceFlow_17 - - - - SequenceFlow_10 - SequenceFlow_14 - - - - - SequenceFlow_10 - - - - - SequenceFlow_14 - - - - SequenceFlow_1 - SequenceFlow_7 - - - - - SequenceFlow_24 - SequenceFlow_32 - - - - - siFoundYes - SequenceFlow_24 - - - - - SequenceFlow_30 - - - - siFoundNo - SequenceFlow_30 - - - - - SequenceFlow_3 - siFoundYes - siFoundNo - - - - - - - - - - - - - - - - SequenceFlow_28 - SequenceFlow_3 - - - - SequenceFlow_7 - SequenceFlow_28 - - - - - SequenceFlow_59 - SequenceFlow_13 - - - - - - - http-connector - - ${UPDNETI_updateNetworkRequest} - ${URN_mso_adapters_network_rest_endpoint}/${UPDNETI_networkId} - - - #{BasicAuthHeaderValuePO} - application/xml - - - PUT - ${statusCode} - ${response} - - - - SequenceFlow_61 - SequenceFlow_59 - - - - SequenceFlow_2 - SequenceFlow_61 - - - - - SequenceFlow_38 - SequenceFlow_2 - - - - - sdncTopoYes_SequenceFlow - SequenceFlow_6 - - - - - SequenceFlow_6 - SequenceFlow_15 - - - - - SequenceFlow_15 - SequenceFlow_38 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn index ecd23f0ca9..5488350afc 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn @@ -623,12 +623,12 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + - + @@ -675,10 +675,10 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - - + + - + @@ -795,46 +795,46 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + - - - + + + - + - - + + - + - + - + - - - + + + - + - - - + + + - + @@ -861,7 +861,7 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + @@ -1074,24 +1074,24 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + - - + + - + - - - + + + - + @@ -1133,24 +1133,24 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + - - + + - + - - - + + + - + @@ -1178,7 +1178,7 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + @@ -1187,9 +1187,9 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + @@ -1211,17 +1211,17 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - - + + - + - + @@ -1233,98 +1233,98 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - - + + - + - - + + - + - - - + + + - + - - + + - + - + - - + + - + - - + + - + - + - + - - + + - + - - + + - + - + - + - - + + - + - + - + - - + + - + @@ -1338,17 +1338,17 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + - - - + + + - + @@ -1359,20 +1359,20 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - - + + - + - - + + - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstance.bpmn index a770c8c11a..19fd490b9f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstance.bpmn @@ -1,390 +1,431 @@ - - - - - SequenceFlow_1 - - - - SequenceFlow_2 - SequenceFlow_3 + + + + + SequenceFlow_1 + + + + SequenceFlow_2 + SequenceFlow_3 - - - - SequenceFlow_1 - SequenceFlow_2 +def dcsi = new DoCreateServiceInstance() +dcsi.getAAICustomerById(execution)]]> + + + + SequenceFlow_1 + SequenceFlow_2 - - - - SequenceFlow_156ih25 - SequenceFlow_14 +def dcsi = new DoCreateServiceInstance() +dcsi.preProcessRequest(execution) +]]> + + + + SequenceFlow_156ih25 + SequenceFlow_14 - - - SequenceFlow_9 - SequenceFlow_10 +def dcsi = new DoCreateServiceInstance() +dcsi.preProcessSDNCAssignRequest(execution)]]> + + + SequenceFlow_9 + SequenceFlow_10 - - - - - - - - - - - SequenceFlow_14 - SequenceFlow_9 - - - SequenceFlow_10 - - - - - - - - - - - - - - - SequenceFlow_11fnnkb - SequenceFlow_4 - - - - - - - - - - - - - SequenceFlow_1uw2p9a - SequenceFlow_1w01tqs - SequenceFlow_129ih1g - - - - SequenceFlow_3 - SequenceFlow_11fnnkb - SequenceFlow_1uw2p9a - - - - - - - - SequenceFlow_0tgrn11 - - - - SequenceFlow_1xzgv5k - - - - - - - - - - SequenceFlow_1lqktwf - SequenceFlow_0eumzpf - - - - - SequenceFlow_0tgrn11 - SequenceFlow_1lqktwf +def dcsi = new DoCreateServiceInstance() +dcsi.postProcessSDNCAssign(execution)]]> + + + + + + + + + + + SequenceFlow_14 + SequenceFlow_9 + + + SequenceFlow_01q6pl4 + + + + + + + + + + + + + + + SequenceFlow_11fnnkb + SequenceFlow_4 + + + + + + + + + + + + + SequenceFlow_1uw2p9a + SequenceFlow_1w01tqs + SequenceFlow_129ih1g + + + + SequenceFlow_3 + SequenceFlow_11fnnkb + SequenceFlow_1uw2p9a + + + + + + + + SequenceFlow_0tgrn11 + + + + SequenceFlow_1xzgv5k + + + + + + + + + + SequenceFlow_1lqktwf + SequenceFlow_0eumzpf + + + + + SequenceFlow_0tgrn11 + SequenceFlow_1lqktwf - - - - SequenceFlow_0eumzpf - SequenceFlow_1xzgv5k +def dcsi = new DoCreateServiceInstance() +dcsi.preProcessRollback(execution) +]]> + + + + SequenceFlow_0eumzpf + SequenceFlow_1xzgv5k - - - - - SequenceFlow_1dd86x8 - SequenceFlow_156ih25 - SequenceFlow_00v4npo - - - - SequenceFlow_00v4npo - - - - - - SequenceFlow_4 - SequenceFlow_1w01tqs +def dcsi = new DoCreateServiceInstance() +dcsi.postProcessRollback(execution) +]]> + + + + + SequenceFlow_1dd86x8 + SequenceFlow_156ih25 + SequenceFlow_00v4npo + + + + SequenceFlow_00v4npo + + + + + + SequenceFlow_4 + SequenceFlow_1w01tqs - - - - SequenceFlow_129ih1g - SequenceFlow_1dd86x8 +def dcsi = new DoCreateServiceInstance() +dcsi.postProcessAAIGET(execution)]]> + + + + SequenceFlow_129ih1g + SequenceFlow_1dd86x8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +def ddsi = new DoCreateServiceInstance() +ddsi.postProcessAAIPUT(execution)]]> + + + + + + + + + + + + + + SequenceFlow_10 + SequenceFlow_0tx5frq + + + + + SequenceFlow_0tx5frq + SequenceFlow_01q6pl4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn index 80ace28ae7..6c24696cbd 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn @@ -1,338 +1,379 @@ - - - - - SequenceFlow_1 - - - - SequenceFlow_1 - SequenceFlow_2 + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 - - - SequenceFlow_01l4ssl - - - - SequenceFlow_8 - - - - SequenceFlow_7 - - - - SequenceFlow_8 - SequenceFlow_7 +def rbk = new DoCreateServiceInstanceRollback() +rbk.preProcessRequest(execution) +]]> + + + SequenceFlow_01l4ssl + + + + SequenceFlow_8 + + + + SequenceFlow_7 + + + + SequenceFlow_8 + SequenceFlow_7 - - - - - - - - - - - - - - - - SequenceFlow_1x9eh33 - SequenceFlow_05wu9i7 - - - SequenceFlow_06aasqh - SequenceFlow_11fnnkb - SequenceFlow_1uw2p9a - - - - - - - rollback AAI - SequenceFlow_1uw2p9a - SequenceFlow_0khjo7l - SequenceFlow_1n7wade - SequenceFlow_1x9eh33 - - - - - - - - - - - - - - - - - SequenceFlow_11fnnkb - SequenceFlow_0k28xib - - - SequenceFlow_0k28xib - SequenceFlow_0khjo7l +def rbk= new DoCreateServiceInstanceRollback() +rbk.processRollbackException(execution)]]> + + + + + + + + + + + + + + + + SequenceFlow_1x9eh33 + SequenceFlow_05wu9i7 + + + 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 +String response = execution.getVariable("sdncDeactivateResponse") +def rbk= new DoCreateServiceInstanceRollback() +rbk.validateSDNCResponse(execution, response, "deactivate")]]> + + + + SequenceFlow_2 + SequenceFlow_06aasqh + SequenceFlow_1rzlaoy + + + SequenceFlow_05wu9i7 + SequenceFlow_1n7wade + SequenceFlow_1rzlaoy + SequenceFlow_01l4ssl - - - - - - - - - SequenceFlow_1ch4xrf - - - - SequenceFlow_1ch4xrf - SequenceFlow_1pjk2ff +def rbk = new DoCreateServiceInstanceRollback() +rbk.postProcessRequest(execution)]]> + + + + + + + + + SequenceFlow_1ch4xrf + + + + SequenceFlow_1ch4xrf + SequenceFlow_1pjk2ff - - - SequenceFlow_1pjk2ff - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +def rbk= new DoCreateServiceInstanceRollback() +rbk.processRollbackJavaException(execution)]]> + + + SequenceFlow_1pjk2ff + + + + + + + SequenceFlow_006g9e8 + SequenceFlow_1njogr1 + + + + + + + + + + + + SequenceFlow_0khjo7l + SequenceFlow_006g9e8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn index 5e88527676..8411c56bef 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn @@ -9,7 +9,7 @@ SequenceFlow_1 SequenceFlow_2 @@ -42,7 +42,7 @@ exceptionUtil.buildWorkflowException(execution, 404, "Service Instance Not Found found - + @@ -64,7 +64,7 @@ exceptionUtil.buildWorkflowException(execution, 404, "Service Instance Not Found - found + VnfNameSpecified1 SequenceFlow_7 @@ -86,9 +86,10 @@ exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist vnfExistNo + VnfNameNotSpecified1 SequenceFlow_11 @@ -123,21 +124,20 @@ exceptionUtil.processJavaException(execution)]]> - SequenceFlow_15z3gpq - SequenceFlow_0ay5l4b + SdncInteractionNotEnabled + SequenceFlow_0bj7c4s - - + - SequenceFlow_0ttqcwx + SdncInteractionEnabled SequenceFlow_1q6udwm @@ -155,19 +155,20 @@ createVnf.preProcessSDNCAssignRequest(execution)]]> SequenceFlow_15knw0q - SequenceFlow_0c5h00o SequenceFlow_0lnh79j + +String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse") + +def createVnfInfra = new DoCreateVnf() createVnfInfra.validateSDNCResponse(execution, response, "assign")]]> - SequenceFlow_0c5h00o + SequenceFlow_1q1poly + VnfNameSpecified2 SequenceFlow_1lalmvp @@ -187,30 +188,102 @@ createVnf.preProcessSDNCActivateRequest(execution)]]> SequenceFlow_0eb41vb SequenceFlow_15z3gpq - + SequenceFlow_1gc18ih - SequenceFlow_0ttqcwx - SequenceFlow_0ay5l4b + SdncInteractionEnabled + SdncInteractionNotEnabled - - + + - + SequenceFlow_0seif8n 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 + + @@ -243,27 +316,27 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - + - + - + - + - - + + - + @@ -280,11 +353,10 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - - - + + - + @@ -339,9 +411,9 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - + - + @@ -400,32 +472,25 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - - - - - - - - - + + - + - - + + - + - - + + - + @@ -438,36 +503,37 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - + - + - + - + - + - - - + + + - + - - - - + + + + + - + @@ -479,14 +545,114 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn index 433957572d..be54119bda 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn @@ -13,7 +13,7 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> - + @@ -36,6 +36,9 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> + + + SequenceFlow_1hf7k7q SequenceFlow_1ixcnb6 @@ -44,7 +47,7 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> - + @@ -67,6 +70,9 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> + + + SequenceFlow_1lh21yl SequenceFlow_1llbx0k @@ -97,7 +103,7 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]> - + @@ -105,7 +111,6 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]> - @@ -115,6 +120,9 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]> + + + SequenceFlow_1xd3ri5 SequenceFlow_08i3uo6 @@ -141,10 +149,10 @@ doCreateVnfAndModules.queryCatalogDB(execution)]]> SequenceFlow_1vrogpr - + - + @@ -159,6 +167,7 @@ doCreateVnfAndModules.queryCatalogDB(execution)]]> + SequenceFlow_1ifw9tw SequenceFlow_1hf7k7q @@ -171,6 +180,7 @@ doCreateVnfAndModules.queryCatalogDB(execution)]]> + SequenceFlow_0kld3qt SequenceFlow_1lh21yl @@ -193,7 +203,27 @@ doCreateVnfAndModules.finisthProcessingInitialCountDeployment(execution)]]> + + + SequenceFlow_11bmhi4 + SequenceFlow_1kjlzrn + + + + SequenceFlow_1kjlzrn + + + SequenceFlow_11bmhi4 + + + + + + + @@ -374,6 +404,38 @@ doCreateVnfAndModules.validateBaseModule(execution)]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn index 9d21cc8301..49274bd8a6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn @@ -1,332 +1,373 @@ - - - - - SequenceFlow_0jfgn05 - - - SequenceFlow_0jfgn05 - SequenceFlow_1jqc16k + + + + + SequenceFlow_0jfgn05 + + + SequenceFlow_0jfgn05 + SequenceFlow_1jqc16k - - - SequenceFlow_1wyvxwi - - - - - - - - - - - - - SequenceFlow_1w8ao21 - SequenceFlow_0riudmc - SequenceFlow_05wu9i7 - - - - - - - - - - - - - SequenceFlow_0rtflal - SequenceFlow_0k28xib - - - SequenceFlow_0k28xib - SequenceFlow_1w8ao21 +def ddsi = new DoDeleteServiceInstance() +ddsi.preProcessRequest(execution) +]]> + + + SequenceFlow_1wyvxwi + + + + + + + + + + + + + SequenceFlow_0riudmc + SequenceFlow_0znbzxu + SequenceFlow_05wu9i7 + + + + + + + + + + + + + SequenceFlow_0rtflal + SequenceFlow_0k28xib + + + SequenceFlow_0k28xib + SequenceFlow_1w8ao21 - - - - SequenceFlow_1dwch0k - SequenceFlow_0rtflal + +String response = execution.getVariable("sdncDeactivateResponse") +def ddsi = new DoDeleteServiceInstance() +ddsi.postProcessSDNCDelete(execution, response, "deactivate")]]> + + + + SequenceFlow_1dwch0k + SequenceFlow_0rtflal - - - - SequenceFlow_1up0j5r - SequenceFlow_1hcfvcj - SequenceFlow_05jfuko - - - - - - SequenceFlow_05jfuko - - - - - SequenceFlow_1hcfvcj - SequenceFlow_0riudmc - SequenceFlow_1dwch0k - - - - - - - - - - - - - - - - SequenceFlow_1jqc16k - SequenceFlow_1grea1r - - - - SequenceFlow_1grea1r - SequenceFlow_1up0j5r +def ddsi = new DoDeleteServiceInstance() +ddsi.preProcessSDNCDelete(execution)]]> + + + + SequenceFlow_1up0j5r + SequenceFlow_1hcfvcj + SequenceFlow_05jfuko + + + + + + SequenceFlow_05jfuko + + + + + SequenceFlow_1hcfvcj + SequenceFlow_0riudmc + SequenceFlow_1dwch0k + + + + + + + + + + + + + + + + SequenceFlow_1jqc16k + SequenceFlow_1grea1r + + + + SequenceFlow_1grea1r + SequenceFlow_1up0j5r - - - - - SequenceFlow_05wu9i7 - SequenceFlow_1wyvxwi +def ddsi = new DoDeleteServiceInstance() +ddsi.postProcessAAIGET(execution)]]> + + + + + SequenceFlow_05wu9i7 + SequenceFlow_1wyvxwi - - - - - SequenceFlow_0u33vy6 - - - - SequenceFlow_0hevfee - - - SequenceFlow_0u33vy6 - SequenceFlow_0hevfee +def ddsi = new DoDeleteServiceInstance() +ddsi.postProcessAAIDEL(execution)]]> + + + + + SequenceFlow_0u33vy6 + + + + SequenceFlow_0hevfee + + + SequenceFlow_0u33vy6 + SequenceFlow_0hevfee - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)]]> + + + + + + + + + + + + + + SequenceFlow_1w8ao21 + SequenceFlow_14x55db + + + SequenceFlow_14x55db + SequenceFlow_0znbzxu + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModule.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModule.bpmn index ab0812343b..b8c6aa32a4 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModule.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModule.bpmn @@ -1,8 +1,7 @@ - + SequenceFlow_0fp1wqz SequenceFlow_28 - + @@ -21,8 +19,7 @@ dvm.prepUpdateAAIVfModule(execution)]]> SequenceFlow_31 - + @@ -34,8 +31,7 @@ dvm.prepUpdateAAIVfModule(execution)]]> SequenceFlow_1j9dvfx - + @@ -49,16 +45,14 @@ dvm.prepUpdateAAIVfModule(execution)]]> SequenceFlow_33 - + SequenceFlow_1j9dvfx SequenceFlow_4 - + SequenceFlow_31 SequenceFlow_32 - + @@ -82,8 +75,7 @@ dvm.prepSDNCAdapterRequest(execution, "delete")]]> SequenceFlow_35 - + @@ -94,8 +86,7 @@ dvm.prepSDNCAdapterRequest(execution, "delete")]]> SequenceFlow_35 - + SequenceFlow_2 SequenceFlow_34 SequenceFlow_0t4yszi - SequenceFlow_0lu7b1v + SequenceFlow_1tt31qu + SequenceFlow_1fccvli SequenceFlow_1qrkdn3 SequenceFlow_1936oc0 - + SequenceFlow_05ujwz8 + SequenceFlow_1x25m7t SequenceFlow_1uqlr6b - + @@ -63,20 +65,22 @@ exceptionUtil.processJavaException(execution)]]> - + + - SequenceFlow_1qoor0l + SequenceFlow_1xujrk5 SequenceFlow_1p4ycii - + SequenceFlow_1936oc0 SequenceFlow_05ujwz8 + SDNCInteractionEnabled2 - + SequenceFlow_08nd69s @@ -92,15 +96,115 @@ ddvam.queryAAIVfModule(execution)]]> def ddvam = new DoDeleteVnfAndModules() ddvam.prepareNextModuleToDelete(execution)]]> - - - + + + SequenceFlow_1p4ycii + SequenceFlow_0xl033m SequenceFlow_0t4yszi +int nextModule = execution.getVariable("DDVAM_nextModule") + execution.setVariable("DDVAM_nextModule", nextModule + 1)]]> + + + 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 + + + + + + @@ -123,51 +227,51 @@ int nextModule = execution.getVariable("nextModule") - + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + @@ -177,87 +281,208 @@ int nextModule = execution.getVariable("nextModule") - - - + + + - + - + - + - + - - - - + + + - + - - - + + + - + - - - - + + - + - - + + - + - - + + - + - + - + - + - - - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy deleted file mode 100644 index a90cf12ecb..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy +++ /dev/null @@ -1,3055 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts; - -import static org.junit.Assert.* -import static org.mockito.Mockito.* -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCloudRegion -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetwork -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetwork -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkRouteTable -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding - -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.Ignore; -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.openecomp.mso.bpmn.common.scripts.MsoUtils -import org.openecomp.mso.bpmn.core.WorkflowException - -import com.github.tomakehurst.wiremock.client.WireMock -import com.github.tomakehurst.wiremock.junit.WireMockRule - - -@RunWith(MockitoJUnitRunner.class) -class UpdateNetworkInstanceInfraTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - def utils = new MsoUtils() - - 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" - } - ] - } - }}""" - - String jsonIncomingRequest_Missingname = - """{ "requestDetails": { - "modelInfo": { - "modelType": "networkTyp", - "modelId": "modelId", - "modelNameVersionId": "modelNameVersionId", - "modelName": "CONTRAIL_EXTERNAL", - "modelVersion": "1" - }, - "cloudConfiguration": { - "lcpCloudRegionId": "RDM2WAGPLCP", - "tenantId": "7dd5365547234ee8937416c65507d266" - }, - "requestInfo": { - "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 jsonIncomingRequest_MissingCloudRegion = - """{ "requestDetails": { - "modelInfo": { - "modelType": "networkTyp", - "modelId": "modelId", - "modelNameVersionId": "modelNameVersionId", - "modelName": "CONTRAIL_EXTERNAL", - "modelVersion": "1" - }, - "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 - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - - - someValue1 - - -""" - - -String expectedNetworkRequestMissingCloudRegion = -""" - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - UPDATE - PORTAL - - - HSL_direct_net_2 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - - e81d842d3e8b45c5a59f57cd76af3aaf - - - 1 - -""" - - // vnfRESTRequest - String networkRESTRequest = -""" - - - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - UPDATE - PORTAL - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - dvs-slcp3-01 - 3008 - - - 1 - 0 - - - - """ - - String networkInputsMissingName = - """ - - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - e81d842d3e8b45c5a59f57cd76af3aaf - """ - -String networkInputsMissingCloudRegion = -""" - HSL_direct_net_2 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - - e81d842d3e8b45c5a59f57cd76af3aaf -""" - - String expectedUpdateNetworkInstanceInfraRequest = - """ - - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - UPDATE - PORTAL - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - dvs-slcp3-01 - 3008 - - - 1 - 0 - - -""" - - String expectedUpdateNetworkInstanceInfraRequest_Output = - """ - - - 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 - - -""" - - // expectedNetworkRequest - String expectedNetworkRequest = - """ - - UPDATE - VID - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - - - true - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - true - 10.10.125.1 - -""" - -String expectedNetworkInputs = -""" - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true -""" - - - 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 - -""" - - - // 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 networkOutputs = - """ - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - """ - - String queryAAIResponse = - """ - - - - - - - - - - - - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - HSL_direct_net_2 - CONTRAIL_EXTERNAL - dmz_direct - contrail - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - pending-delete - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - - - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ - - vpn-binding.vpn-id - 85f015d0-2e32-4c30-96d2-87a1a27f8017 - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ - - vpn-binding.vpn-id - c980a6ef-3b88-49f0-9751-dbad8608d0a6 - - - - tenant - https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ - - tenant.tenant-id - 7dd5365547234ee8937416c65507d266 - - - - - -""" - - String queryIdAIIResponse = - """ - - - - - - - - - - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - dmz_direct - contrail - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - l3-version - pending-delete - ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - subnetName - - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - subnetName - - - - - 414 - 4132176 - - - 415 - 4132176 - - - - inner - ctag-version - - - tenant - https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ - - tenant.tenant-id - 897deadc2b954a6bac6d3c197fb3525e - - - tenant.tenant-name - MSOTest1 - - - - vpn-binding - https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ - - vpn-binding.vpn-id - a290b841-f672-44dd-b9cd-6f8c20d7d8c8 - - - vpn-binding.vpn-name - oam_protected_net_6_MTN5_msotest2 - - - - vpn-binding - https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ - - vpn-binding.vpn-id - 24a4b507-853a-4a38-99aa-05fcc54be24d - - - vpn-binding.vpn-name - oam_protected_net_6_MTN5_msotest1 - - - - - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ - - vpn-binding.vpn-id - 85f015d0-2e32-4c30-96d2-87a1a27f8017 - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ - - vpn-binding.vpn-id - c980a6ef-3b88-49f0-9751-dbad8608d0a6 - - - - tenant - https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ - - tenant.tenant-id - 7dd5365547234ee8937416c65507d266 - - - - network-policy - https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg - - network-policy.network-policy-id - cee6d136-e378-4678-a024-2cd15f0ee0cg - - - - route-table-reference - https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 - - route-table-reference.route-table-reference-id - cee6d136-e378-4678-a024-2cd15f0ee0hi - - - - route-table-reference - https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 - - route-table-reference.route-table-reference-id - cee6d136-e378-4678-a024-2cd15f0ee0hi - - - - - -""" - - String queryIdAIIResponseTestScenario01 = - """ - - 4da55fe4-7a9e-478c-a434-8a98d62265ab - GN_EVPN_direct_net_0_ST1 - CONTRAIL30_BASIC - GN_EVPN_direct - contrail - false - 9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - 1465398611 - pending-delete - networkName - false - true - false - - - cb1a7b47-5428-44c9-89c2-8b17541c3228 - 108.239.40.1 - 108.239.40.0 - 28 - 4 - pending-delete - true - 108.239.40.0 - 108.239.40.0 - 1465398611 - subnetName - - - - e2cc7c14-90f0-4205-840d-b4e07f04e621 - 2606:ae00:2e01:604::1 - 2606:ae00:2e01:604:: - 64 - 6 - pending-delete - true - 2606:ae00:2e01:604:: - 2606:ae00:2e01:604:: - 1465398611 - subnetName - - - - - - 416 - 4132176 - - - - cloud-region - https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/ - - - cloud-region.cloud-region-id - AAIAIC25 - - - cloud-region.cloud-owner - att-aic - - - cloud-region.owner-defined-type - - - - - tenant - https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/4ae1d3446a4c48b2bec44b6cfba06d68/ - - tenant.tenant-id - 4ae1d3446a4c48b2bec44b6cfba06d68 - - - - cloud-region.cloud-owner - att-aic - - - cloud-region.cloud-region-id - AAIAIC25 - - - tenant.tenant-name - Ruchira Contrail 3.0 test - - - - vpn-binding - https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ - - vpn-binding.vpn-id - 9a7b327d9-287aa00-82c4b0-100001 - - - vpn-binding.vpn-name - GN_EVPN_direct_net_0_ST1 - - - - route-table-reference - - route-table-reference.route-table-reference-id - cee6d136-e378-4678-a024-2cd15f0ee0hi - - - -""" - - String queryIdAIIResponseVpnNotPresent = - """ - - - - - - - - - - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - dmz_direct - contrail - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - pending-delete - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - subnetName - - - - - - -""" - - String queryNameAIIResponse = - """ - - - - - - - - - - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - dmz_direct - contrail - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - pending-delete - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - - - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ - - vpn-binding.vpn-id - 85f015d0-2e32-4c30-96d2-87a1a27f8017 - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ - - vpn-binding.vpn-id - c980a6ef-3b88-49f0-9751-dbad8608d0a6 - - - - tenant - https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ - - tenant.tenant-id - 7dd5365547234ee8937416c65507d266 - - - - - - """ - - String queryNameAIIResponseVpnNotPresent = - """ - - - - - - - - - - - - - - -""" - - String queryVpnBindingAAIResponse = - """ - - - - - - - - - - - - 9a7b327d9-287aa00-82c4b0-105757 - GN_EVPN_Test - 13979:105757 - - - l3-network - https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/689ec39e-c5fc-4462-8db2-4f760763ad28/ - - l3-network.network-id - 689ec39e-c5fc-4462-8db2-4f760763ad28 - - - - l3-network - https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/1a49396b-19b3-40a4-8792-aa2fbd0f0704/ - - l3-network.network-id - 1a49396b-19b3-40a4-8792-aa2fbd0f0704 - - - - l3-network - https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/ - - l3-network.network-id - 774f3329-3c83-4771-86c7-9e6207cd50fd - - - - - -""" - - String updateDBRequest_Active = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Network MNS-25180-L-01-dmz_direct_net_1 already exists. Silent success. - - COMPLETED - 100 - <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id><network-name>MNS-25180-L-01-dmz_direct_net_1</network-names> - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - - -""" - - String updateDBRequest = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Network successfully updated. - - COMPLETED - 100 - <network-id></network-id><network-name></network-names> - - - -""" - - String updateDBRequestError = - """ - - - - 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 updateDBRequestError01 = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Received error unexpectedly from SDN-C. - - FAILED - <network-id></network-id><network-name></network-names> - - - """ - - String updateDBRequest_Outputs = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Network successfully updated. - - COMPLETED - 100 - <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id><network-name>MNS-25180-L-01-dmz_direct_net_1</network-names> - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - - -""" - - 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 - - - CONTRAIL - - networkName - 414,415 - - - true - false - 13979:105757 - 13979:105757 - GN_EVPN_Test - refFQDN1 - refFQDN2 - - true - true - false - - true - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - true - 10.10.125.1 - - - 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 - - true - true - false - - true - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - true - 10.10.125.1 - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - null - - messageId_generated - -""" - - String updateNetworkResponseREST = - """ - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - c4f4e878-cde0-4b15-ae9a-bda857759cea - default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 - - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - - - - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - c4f4e878-cde0-4b15-ae9a-bda857759cea - - CONTRAIL_EXTERNAL - true - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - - - - messageId_generated -""" - - String updateRollbackNetworkRequest = - """ - - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - c4f4e878-cde0-4b15-ae9a-bda857759cea - - CONTRAIL_EXTERNAL - true - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - - - -""" - - String updateNetworkResponse = - """ - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - c4f4e878-cde0-4b15-ae9a-bda857759cea - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - - - - RDM2WAGPLCP - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - - - true - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - CONTRAIL_EXTERNAL - false - c4f4e878-cde0-4b15-ae9a-bda857759cea - 7dd5365547234ee8937416c65507d266 - -""" - - String updateContrailAAIPayloadRequest = - """ - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - dmz_direct - contrail - c4f4e878-cde0-4b15-ae9a-bda857759cea - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - l3-version - active - ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 - default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - 107.239.52.1 - 107.239.52.0 - 24 - 4 - active - true - subnetName - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - 107.239.52.1 - 107.239.52.0 - 24 - 4 - active - true - subnetName - - - - 414 - - - 415 - - - - inner - ctag-version - - - tenant - https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ - - tenant.tenant-id - 897deadc2b954a6bac6d3c197fb3525e - - - tenant.tenant-name - MSOTest1 - - - - vpn-binding - https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ - - vpn-binding.vpn-id - a290b841-f672-44dd-b9cd-6f8c20d7d8c8 - - - vpn-binding.vpn-name - oam_protected_net_6_MTN5_msotest2 - - - - vpn-binding - https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ - - vpn-binding.vpn-id - 24a4b507-853a-4a38-99aa-05fcc54be24d - - - vpn-binding.vpn-name - oam_protected_net_6_MTN5_msotest1 - - - - - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ - - vpn-binding.vpn-id - 85f015d0-2e32-4c30-96d2-87a1a27f8017 - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ - - vpn-binding.vpn-id - c980a6ef-3b88-49f0-9751-dbad8608d0a6 - - - - tenant - https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ - - tenant.tenant-id - 7dd5365547234ee8937416c65507d266 - - - - network-policy - https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg - - network-policy.network-policy-id - cee6d136-e378-4678-a024-2cd15f0ee0cg - - - - route-table-reference - https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 - - route-table-reference.route-table-reference-id - cee6d136-e378-4678-a024-2cd15f0ee0hi - - - - route-table-reference - https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 - - route-table-reference.route-table-reference-id - cee6d136-e378-4678-a024-2cd15f0ee0hi - - - -""" - - String updateContrailAAIResponse = - """ - - - - - - - - -""" - - String updateNetworkErrorResponse = - """ - 680bd458-5ec1-4a16-b77c-509022e53450INTERNAL - 400 Bad Request: The server could not comply with the request since it is either malformed or otherwise incorrect., error.type=StackValidationFailed, error.message=Property error: : resources.network.properties: : Unknown Property network_ipam_refs_data - true - """ - - - String networkException500 = - """soap:VersionMismatch"http://org.openecomp.mso/network", the namespace on the "updateNetworkContrail" element, is not a valid SOAP version.""" - - String aaiResponse = - """ - - - - - - - - - - - - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - HSL_direct_net_2 - CONTRAIL_BASIC - HSL_direct - contrail - 8bbd3edf-b835-4610-96a2-a5cafa029042 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - active - HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 - - - ea5f2a2c-604f-47ff-a9c5-253ee4f0ef0a - 5a77fdc2-7789-4649-a1b9-6eaf1db1813a - 172.16.34.1 - 172.16.34.0 - 28 - 4 - active - true - - - - - - tenant - https://aai-app-e2e.test.com:8443/aai/v3/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ - - tenant.tenant-id - e81d842d3e8b45c5a59f57cd76af3aaf - - - - - - """ - - String changeAssignSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - changeassign - network-topology-operation - sdncCallback - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - NetworkActivateRequest - VID - - - - - - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MSO-dev-service-type - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - MSO_1610_dev - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -String assignResponse = -""" 006927ca-f5a3-47fd-880c-dfcbcd81a093 200 OK 200006927ca-f5a3-47fd-880c-dfcbcd81a093Ynotsurewecarea9a77d5a-123e-4ca2-9eb9-0b015d2ee0fbGN_EVPN_direct_net_0_ST_noGW8abc633a-810b-4ca5-8b3a-09511d13a2ce """ - - String sdncRollbackRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - NetworkActivateRequest - VID - - - - - - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MSO-dev-service-type - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - MSO_1610_dev - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - - String sdncAdapterWorkflowResponse = - """ - - - 745b1b50-e39e-4685-9cc8-c71f0bde8bf0 - 200 - OK - - <output xmlns="org:openecomp: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 falloutHandlerRequest = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - UPDATE - PORTAL - - - Received error from SDN-C: No availability zone available. - 5300 - - """ - - String falloutHandlerRequestObject = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - UPDATE - VID - - - Received error from SDN-C: No availability zone available - 7000 - - """ - - - String falloutHandlerRequest_Scenario01 = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - UPDATE - VID - - - Unexpected Response from AAI - 400 - 7020 - - """ - - String completeMsoProcessRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - UPDATE - PORTAL - - BPMN Network action: UPDATE -""" - -// - - - - - - - - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - - } - - public void initializeVariables (Execution mockExecution) { - - verify(mockExecution).setVariable("UPDNETI_messageId", "") - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "") - verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", "") - verify(mockExecution).setVariable("UPDNETI_networkRequest", "") - verify(mockExecution).setVariable("UPDNETI_networkInputs", "") - verify(mockExecution).setVariable("UPDNETI_networkOutputs", "") - verify(mockExecution).setVariable("UPDNETI_requestId", "") - verify(mockExecution).setVariable("UPDNETI_source", "") - verify(mockExecution).setVariable("UPDNETI_networkId", "") - - verify(mockExecution).setVariable("UPDNETI_CompleteMsoProcessRequest", "") - verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", "") - verify(mockExecution).setVariable("UPDNETI_isSilentSuccess", false) - verify(mockExecution).setVariable("UPDNETI_isPONR", false) - - // AAI query Cloud Region - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest","") - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionReturnCode","") - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionResponse","") - verify(mockExecution).setVariable("UPDNETI_cloudRegionPo","") - verify(mockExecution).setVariable("UPDNETI_cloudRegionSdnc","") - verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", false) - - // AAI query Id - verify(mockExecution).setVariable("UPDNETI_queryIdAAIRequest","") - verify(mockExecution).setVariable("UPDNETI_queryIdAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiIdReturnCode", "") - - // AAI query vpn binding - verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIRequest","") - verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_vpnBindings", null) - verify(mockExecution).setVariable("UPDNETI_vpnCount", 0) - verify(mockExecution).setVariable("UPDNETI_routeCollection", "") - - // AAI query network policy - verify(mockExecution).setVariable("UPDNETI_queryNetworkPolicyAAIRequest","") - verify(mockExecution).setVariable("UPDNETI_queryNetworkPolicyAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_networkPolicyUriList", null) - verify(mockExecution).setVariable("UPDNETI_networkPolicyCount", 0) - verify(mockExecution).setVariable("UPDNETI_networkCollection", "") - - // AAI query route table reference - verify(mockExecution).setVariable("UPDNETI_queryNetworkTableRefAAIRequest","") - verify(mockExecution).setVariable("UPDNETI_queryNetworkTableRefAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_networkTableRefUriList", null) - verify(mockExecution).setVariable("UPDNETI_networkTableRefCount", 0) - verify(mockExecution).setVariable("UPDNETI_tableRefCollection", "") - - - // AAI requery Id - verify(mockExecution).setVariable("UPDNETI_requeryIdAAIRequest","") - verify(mockExecution).setVariable("UPDNETI_requeryIdAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiRequeryIdReturnCode", "") - - // AAI update contrail - verify(mockExecution).setVariable("UPDNETI_updateContrailAAIUrlRequest","") - verify(mockExecution).setVariable("UPDNETI_updateContrailAAIPayloadRequest","") - verify(mockExecution).setVariable("UPDNETI_updateContrailAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiUpdateContrailReturnCode", "") - - verify(mockExecution).setVariable("UPDNETI_updateNetworkRequest", "") - verify(mockExecution).setVariable("UPDNETI_updateNetworkResponse", "") - verify(mockExecution).setVariable("UPDNETI_rollbackNetworkRequest", "") - verify(mockExecution).setVariable("UPDNETI_rollbackNetworkResponse", "") - verify(mockExecution).setVariable("UPDNETI_networkReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_rollbackNetworkReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_isNetworkRollbackNeeded", false) - - verify(mockExecution).setVariable("UPDNETI_changeAssignSDNCRequest", "") - verify(mockExecution).setVariable("UPDNETI_changeAssignSDNCResponse", "") - verify(mockExecution).setVariable("UPDNETI_rollbackSDNCRequest", "") - verify(mockExecution).setVariable("UPDNETI_rollbackSDNCResponse", "") - verify(mockExecution).setVariable("UPDNETI_sdncReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_rollbackSDNCReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_isSdncRollbackNeeded", false) - verify(mockExecution).setVariable("UPDNETI_sdncResponseSuccess", false) - - verify(mockExecution).setVariable("UPDNETI_updateDBRequest", "") - verify(mockExecution).setVariable("UPDNETI_updateDBResponse", "") - verify(mockExecution).setVariable("UPDNETI_dbReturnCode", "") - - verify(mockExecution).setVariable("UPDNETI_isVnfBindingPresent", false) - verify(mockExecution).setVariable("UPDNETI_Success", false) - verify(mockExecution).setVariable("UPDNETI_serviceInstanceId", "") - verify(mockExecution).setVariable("GENGS_type", "service-instance") // Setting for Generic Sub Flow use - - - } - - @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("UPDNETI_messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.preProcessRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", "UPDNETI_") - - //verify variable initialization - initializeVariables(mockExecution) - - // Authentications - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - - verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", jsonIncomingRequest) - //verify(mockExecution).setVariable("UPDNETI_networkRequest", expectedNetworkRequest) - //verify(mockExecution).setVariable("UPDNETI_networkInputs", expectedNetworkInputs) - //verify(mockExecution, atLeast(3)).setVariable("UPDNETI_networkOutputs", "") - - //verify(mockExecution).setVariable("UPDNETI_requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution).setVariable("UPDNETI_source", "VID") - //verify(mockExecution).setVariable("UPDNETI_messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution, atLeast(1)).setVariable("GENGS_type", "service-instance") - - } - - - @Test - //@Ignore - public void preProcessRequest_MissingNetworkId() { - - println "************ preProcessRequest_MissingName() ************* " - - WorkflowException missingNameWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 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("UPDNETI_messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - try { - UpdateNetworkInstanceInfra.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", "UPDNETI_") - - //verify variable initialization - initializeVariables(mockExecution) - - // Authentications - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - - verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", jsonIncomingRequest) - //verify(mockExecution, atLeast(1)).setVariable("UPDNETI_networkOutputs", networkOutputs) - //verify(mockExecution).setVariable("UPDNETI_networkRequest", expectedNetworkRequestMissingNetworkId) - //verify(mockExecution).setVariable("UPDNETI_networkInputs", expectedNetworkInputs) - - //verify(mockExecution).setVariable("UPDNETI_requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution).setVariable("UPDNETI_source", "VID") - //verify(mockExecution).setVariable("UPDNETI_messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - - verify(mockExecution).setVariable(eq("WorkflowException"), refEq(missingNameWorkflowException)) - - } - - @Test - //@Ignore - public void preProcessRequest_MissingCloudRegion() { - - println "************ preProcessRequest_MissingCloudRegion() ************* " - - WorkflowException missingCloudRegionWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 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("UPDNETI_messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") - - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - try { - UpdateNetworkInstanceInfra.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", "UPDNETI_") - - //verify variable initialization - initializeVariables(mockExecution) - - verify(mockExecution).setVariable("UPDNETI_messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - // Authentications - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - - verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", jsonIncomingRequest_MissingCloudRegion) - //verify(mockExecution).setVariable("UPDNETI_networkRequest", "") - //verify(mockExecution).setVariable("UPDNETI_networkInputs", "") - //verify(mockExecution, atLeast(1)).setVariable("UPDNETI_networkOutputs", "") - - //verify(mockExecution).setVariable("UPDNETI_requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution).setVariable("UPDNETI_source", "VID") - - verify(mockExecution).setVariable(eq("WorkflowException"), refEq(missingCloudRegionWorkflowException)) - - } - - @Test - //@Ignore - public void sendSyncResponse() { - - println "************ sendSyncResponse ************* " - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) - when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - //when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.sendSyncResponse(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UpdateNetworkInstanceInfraResponseCode", "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") - - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.sendSyncError(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UpdateNetworkInstanceInfraResponseCode", "500") - - } - - - @Test - //@Ignore - public void prepareDBRequest() { - - println "************ prepareDBRequest ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn("") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("UPDNETI_orchestrationStatus")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareDBRequest(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_updateDBRequest", updateDBRequest) - - } - - @Test - //@Ignore - public void prepareDBRequestErro_ExceptionObject() { - - println "************ prepareDBRequest ************* " - - WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 500, "Received error from SDN-C: No availability zone available") - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn("") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn("") - when(mockExecution.getVariable("UPDNETI_orchestrationStatus")).thenReturn("") - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareDBRequestError(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_updateDBRequest", updateDBRequestError) - - } - - @Test - //@Ignore - public void prepareDBRequest_Outputs() { - - println "************ prepareDBRequest ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn(networkOutputs) - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("UPDNETI_orchestrationStatus")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareDBRequest(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_updateDBRequest", updateDBRequest_Outputs) - - } - - @Test - //@Ignore - public void prepareUpdateNetworkRequest() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") - //when(mockExecution.getVariable("UPDNETI_queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable("UPDNETI_routeCollection")).thenReturn("13979:10575713979:105757") - when(mockExecution.getVariable("UPDNETI_networkCollection")).thenReturn("GN_EVPN_Test") - when(mockExecution.getVariable("UPDNETI_tableRefCollection")).thenReturn("refFQDN1refFQDN2") - when(mockExecution.getVariable("UPDNETI_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("UPDNETI_rollbackEnabled")).thenReturn("true") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareUpdateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution).setVariable("prefix", "UPDNETI_") - - verify(mockExecution).setVariable("UPDNETI_updateNetworkRequest", updateNetworkRequest) - - } - - - @Test - //@Ignore - public void prepareUpdateNetworkRequest_NoPhysicalname() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(NetworkRequest_noPhysicalName) - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") - //when(mockExecution.getVariable("UPDNETI_queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable("UPDNETI_routeCollection")).thenReturn("13979:10575713979:105757") - when(mockExecution.getVariable("UPDNETI_networkCollection")).thenReturn("GN_EVPN_Test") - when(mockExecution.getVariable("UPDNETI_tableRefCollection")).thenReturn("") - when(mockExecution.getVariable("UPDNETI_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("UPDNETI_rollbackEnabled")).thenReturn("true") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareUpdateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution).setVariable("prefix", "UPDNETI_") - - verify(mockExecution).setVariable("UPDNETI_updateNetworkRequest", updateNetworkRequest_noPhysicalName) - - } - - @Test - //@Ignore - public void prepareSDNCRequest() { - - println "************ prepareSDNCRequest ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("UPDNETI_cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("UPDNETI_serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:28090/SDNCAdapterCallback") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") - - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareSDNCRequest(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_changeAssignSDNCRequest", changeAssignSDNCRequest) - - } - - @Test - //@Ignore - public void prepareSDNCRollbackRequest() { - - println "************ prepareSDNCRollbackRequest ************* " - - - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("UPDNETI_cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("UPDNETI_serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(assignResponse) - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:28090/SDNCAdapterCallback") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareSDNCRollbackRequest(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_rollbackSDNCRequest", sdncRollbackRequest) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkId_200() { - - println "************ callRESTQueryAAINetworkId ************* " - - WireMock.reset(); - - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkId(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_queryIdAAIRequest", "http://localhost:28090/aai/v8/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4") - verify(mockExecution).setVariable("UPDNETI_aaiIdReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion30_200() { - - println "************ callRESTQueryAAICloudRegion30_200 ************* " - - WireMock.reset(); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml") - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - when(mockExecution.getVariable("UPDNETI_networkInputs")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") - verify(mockExecution, atLeast(2)).setVariable("UPDNETI_queryCloudRegionReturnCode", "200") - verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion25_200() { - - println "************ callRESTQueryAAICloudRegion25_200 ************* " - - WireMock.reset(); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml") - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - when(mockExecution.getVariable("UPDNETI_networkInputs")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") - verify(mockExecution, atLeast(2)).setVariable("UPDNETI_queryCloudRegionReturnCode", "200") - verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion_NotFound() { - - println "************ callRESTQueryAAICloudRegionFake ************* " - - WireMock.reset(); - MockGetCloudRegion("MDTWNJ21", 404, "") - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - when(mockExecution.getVariable("UPDNETI_networkInputs")).thenReturn(vnfRequestFakeRegion) - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21") - verify(mockExecution, atLeast(1)).setVariable("UPDNETI_queryCloudRegionReturnCode", "404") - verify(mockExecution).setVariable("UPDNETI_cloudRegionPo", "MDTWNJ21") - verify(mockExecution).setVariable("UPDNETI_cloudRegionSdnc", "AAIAIC25") - verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_200() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200) - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") -// when(mockExecution.getVariable("URN_mso_workflow_UpdateNetworkInstanceInfra_aai_network_vpn-binding_uri")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_vpnCount", 2) - verify(mockExecution).setVariable("UPDNETI_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("UPDNETI_queryVpnBindingAAIRequest", "http://localhost:28090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017") - verify(mockExecution, atLeast(2)).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_TestScenario01_200() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200) - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponseTestScenario01) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") -// when(mockExecution.getVariable("URN_mso_workflow_UpdateNetworkInstanceInfra_aai_network_vpn-binding_uri")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_vpnCount", 1) - verify(mockExecution).setVariable("UPDNETI_vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIRequest", "http://localhost:28090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_200_URN_Uri() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200) - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_vpnCount", 2) - verify(mockExecution).setVariable("UPDNETI_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("UPDNETI_queryVpnBindingAAIRequest", "http://localhost:28090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017") - verify(mockExecution, atLeast(2)).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_NotPresent() { - - println "************ callRESTQueryAAINetworkVpnBinding_NotPresent ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200) - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponseVpnNotPresent) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") - verify(mockExecution).setVariable("UPDNETI_vpnCount", 0) - verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIResponse", aaiVpnResponseStub) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkTableRef_200() { - - println "************ callRESTQueryAAINetworkTableRef_200 ************* " - - WireMock.reset(); - MockGetNetworkRouteTable("refFQDN1", "CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200) - MockGetNetworkRouteTable("refFQDN2", "CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200) - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_route_table_reference_uri")).thenReturn("/aai/v8/network/route-table-references/route-table-reference") -// when(mockExecution.getVariable("URN_mso_workflow_CreateNetworkInstanceInfra_aai_network_table_reference_uri")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkTableRef(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_networkTableRefCount", 2) - verify(mockExecution).setVariable("UPDNETI_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("UPDNETI_queryNetworkTableRefAAIRequest", "http://localhost:28090/aai/v8/network/route-table-references/route-table-reference/refFQDN1") - verify(mockExecution, atLeast(2)).setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkPolicy_200() { - - println "************ callRESTQueryAAINetworkPolicy_200 ************* " - - WireMock.reset(); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200) - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn("/aai/v8/network/network-policies/network-policy") -// when(mockExecution.getVariable("URN_mso_workflow_UpdateNetworkInstanceInfra_aai_network_policy_uri")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkPolicy(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_networkPolicyCount", 1) - verify(mockExecution).setVariable("UPDNETI_networkPolicyUriList", ['/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable("UPDNETI_queryNetworkPolicyAAIRequest", "http://localhost:28090/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", "200") - - } - - - @Test - //@Ignore - public void callRESTReQueryAAINetworkId_200() { - - println "************ callRESTReQueryAAINetworkId ************* " - - WireMock.reset(); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200) - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTReQueryAAINetworkId(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_requeryIdAAIRequest", "http://localhost:28090/aai/v8/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4") - verify(mockExecution).setVariable("UPDNETI_aaiRequeryIdReturnCode", "200") - - } - - - @Test - @Ignore - public void callRESTUpdateContrailAAINetworkREST_200() { - - println "************ callRESTUpdateContrailAAINetwork ************* " - - WireMock.reset(); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml") - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_updateNetworkResponse")).thenReturn(updateNetworkResponseREST) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTUpdateContrailAAINetwork(mockExecution) - - // Capture the arguments to setVariable - ArgumentCaptor captor1 = ArgumentCaptor.forClass(String.class); - ArgumentCaptor captor2 = ArgumentCaptor.forClass(String.class); - - verify(mockExecution, times(6)).setVariable(captor1.capture(), captor2.capture()) - List arg2List = captor2.getAllValues() - String payloadResponseActual = arg2List.get(4) - - assertEquals(updateContrailAAIResponse.replaceAll("\\s+", ""), payloadResponseActual.replaceAll("\\s+", "")) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_updateContrailAAIUrlRequest", "http://localhost:28090/aai/v8/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4") - verify(mockExecution).setVariable("UPDNETI_updateContrailAAIPayloadRequest", updateContrailAAIPayloadRequest) - verify(mockExecution).setVariable("UPDNETI_aaiUpdateContrailReturnCode", "200") - verify(mockExecution).setVariable("UPDNETI_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("UPDNETI_updateNetworkResponse")).thenReturn(updateNetworkResponseREST) - when(mockExecution.getVariable("UPDNETI_networkReturnCode")).thenReturn('200') - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateUpdateNetworkResponse(mockExecution) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_updateNetworkResponse", updateNetworkResponseREST) - verify(mockExecution).setVariable("UPDNETI_isNetworkRollbackNeeded", true) - verify(mockExecution).setVariable("UPDNETI_rollbackNetworkRequest", updateRollbackNetworkRequest) - - } - - @Test - //@Ignore - public void validateUpdateNetworkResponseREST_Error() { - - println "************ validateNetworkResponse ************* " - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 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("UPDNETI_updateNetworkResponse")).thenReturn(networkException500) - when(mockExecution.getVariable("UPDNETI_networkReturnCode")).thenReturn('500') - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - try { - UpdateNetworkInstanceInfra.validateUpdateNetworkResponse(mockExecution) - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - 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("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_sdncReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_isResponseGood")).thenReturn(true) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - try { - UpdateNetworkInstanceInfra.validateSDNCResponse(mockExecution) - verify(mockExecution).setVariable("UPDNETI_isSdncRollbackNeeded", true) - verify(mockExecution).setVariable("UPDNETI_rollbackSDNCRequest", "") - - } catch (Exception ex) { - println " Graceful Exit - " + ex.getMessage() - } - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - //verify(mockExecution).setVariable("UPDNETI_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("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse_Error) - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(false) - when(mockExecution.getVariable("UPDNETI_sdncReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_isResponseGood")).thenReturn(true) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - try { - UpdateNetworkInstanceInfra.validateSDNCResponse(mockExecution) - } catch (Exception ex) { - println " Graceful Exit! - " + ex.getMessage() - } - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - // verify set prefix = "UPDNETI_" - //verify(mockExecution).setVariable("UPDNETI_sdncResponseSuccess", false) - - } - - - - @Test - //@Ignore - public void postProcessResponse() { - - println "************ postProcessResponse ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("PORTAL") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("UPDNETI_dbReturnCode")).thenReturn("200") - - // postProcessResponse(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.postProcessResponse(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_Success", true) - verify(mockExecution).setVariable("UPDNETI_CompleteMsoProcessRequest", completeMsoProcessRequest) - - } - - @Test - //@Ignore - public void validateRollbackResponses_Good() { - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SNDC rollback completed.") - - println "************ validateRollbackResponses_Good() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - - when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - - } - - @Test - //@Ignore - public void validateRollbackResponses_Failed() { - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SDNC rollback failed. ") - - println "************ validateRollbackResponses_Failed() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - - when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("404") - when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("BadResponse") - when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("500") - when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("BadResponse") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - - } - - @Test - //@Ignore - public void validateRollbackResponses_NetworkFailed() { - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowExceptionFailed = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SNDC rollback completed.") - - println "************ validateRollbackResponses_NetworkFailed() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - - when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("404") - when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("BadResponse") - when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(expectedWorkflowExceptionFailed , any(WorkflowException.class))) - - } - - @Test - //@Ignore - public void validateRollbackResponses_SdncFailed() { - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SDNC rollback failed. ") - - println "************ validateRollbackResponses_SdncFailed() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - - when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("400") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException , any(WorkflowException.class))) - - } - - @Test - //@Ignore - public void validateRollbackResponses_NoRollbacks() { - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, " AAI Update Contrail Failed. Error 404") - WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, " AAI Update Contrail Failed. Error 404") - - println "************ validateRollbackResponses_NoRollbacks() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - - when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(false) - when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(false) - when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - //verify(mockExecution, atLeast(1)).setVariable("WorkflowException", any(expectedWorkflowException)) - verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - - } - - - @Test - //@Ignore - public void buildErrorResponse() { - - println "************ buildErrorResponse ************* " - - - WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 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("UPDNETI_requestId")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("PORTAL") - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - - // buildErrorResponse(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.buildErrorResponse(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_Success", false) - verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequest) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - } - - @Test - //@Ignore - public void buildErrorResponse_WorkflowExceptionObject() { - - println "************ buildErrorResponse ************* " - - WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 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("UPDNETI_requestId")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - - // buildErrorResponse(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.buildErrorResponse(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_Success", false) - verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequestObject) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - } - - @Test - //@Ignore - public void buildErrorResponse_Scenario01() { - - WorkflowException aaiWorkflowException_Secnario01 = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "Unexpected Response from AAI - 400") - - println "************ buildErrorResponse ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") - when(mockExecution.getVariable("WorkflowException")).thenReturn(aaiWorkflowException_Secnario01) - when(mockExecution.getVariable("UPDNETI_dbReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_updateDBResponse")).thenReturn("") - - when(mockExecution.getVariable("UPDNETI_aaiRequeryIdReturnCode")).thenReturn("400") - - // buildErrorResponse(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.buildErrorResponse(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_Success", false) - verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequest_Scenario01) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - } - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("UpdateNetworkInstanceInfra") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateNetworkInstanceInfra") - 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("UpdateNetworkInstanceInfra") - when(mockExecution.getProcessInstanceId()).thenReturn("UpdateNetworkInstanceInfra") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java index 4f987f0d48..dd7497c279 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java @@ -20,26 +20,18 @@ package org.openecomp.mso.bpmn.infrastructure; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCloudRegion; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicyfqdn; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetwork; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPost; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSDNCAdapterVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockVNFAdapterRestVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.UUID; - +import org.junit.Ignore; import org.camunda.bpm.engine.test.Deployment; import org.junit.Test; import org.openecomp.mso.bpmn.common.WorkflowTest; @@ -66,7 +58,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { /** - * Sunny day VID scenario. + * Sunny day VID scenario with preloads. * * @throws Exception */ @@ -74,7 +66,9 @@ public class CreateVfModuleInfraTest extends WorkflowTest { @Deployment(resources = { "process/CreateVfModuleInfra.bpmn", "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenericGetVnf.bpmn", "subprocess/SDNCAdapterV1.bpmn", + "subprocess/GenericNotificationService.bpmn", "subprocess/VnfAdapterRestV1.bpmn", "subprocess/ConfirmVolumeGroupTenant.bpmn", "subprocess/ConfirmVolumeGroupName.bpmn", @@ -84,28 +78,80 @@ public class CreateVfModuleInfraTest extends WorkflowTest { "subprocess/CompleteMsoProcess.bpmn", "subprocess/FalloutHandler.bpmn" }) - public void sunnyDayVID() throws Exception { + public void sunnyDayVIDWithPreloads() throws Exception { logStart(); - MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); - MockGetGenericVnfByIdWithPriority("skask", ".*", 200, "VfModularity/VfModule-new.xml", 5); - MockGetGenericVnfById("skask", "VfModularity/GenericVnf.xml", 200); - MockPutVfModuleIdNoResponse("skask", "PCRF", ".*"); - MockPutNetwork(".*", "VfModularity/AddNetworkPolicy_AAIResponse_Success.xml", 200); - MockPutGenericVnf("skask"); - mockVNFPost("", 202, "skask"); - mockSDNCAdapter("/SDNCAdapter", "vnf-type>STMTN", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + MockAAIVfModule(); MockPatchGenericVnf("skask"); MockPatchVfModuleId("skask", ".*"); + MockSDNCAdapterVfModule(); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); String businessKey = UUID.randomUUID().toString(); String createVfModuleRequest = FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"); - Map variables = setupVariablesSunnyDayVID(); + Map variables = setupVariablesSunnyDayVID(); + + TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVfModuleInfra", + "v1", businessKey, createVfModuleRequest, variables); + + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectSDNCCallbacks(callbacks, "assign, query"); + injectVNFRestCallbacks(callbacks, "vnfCreate"); + injectSDNCCallbacks(callbacks, "activate"); + + // TODO add appropriate assertions + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "CreateVfModuleSuccessIndicator", true); + + logEnd(); + } + + /** + * Sunny day VID scenario with no preloads. + * + * @throws Exception + */ + @Test + @Deployment(resources = { + "process/CreateVfModuleInfra.bpmn", + "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/GenericNotificationService.bpmn", + "subprocess/ConfirmVolumeGroupName.bpmn", + "subprocess/CreateAAIVfModule.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/FalloutHandler.bpmn" + }) + public void sunnyDayVIDNoPreloads() throws Exception { + + logStart(); + + MockAAIVfModule(); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); + MockSDNCAdapterVfModule(); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); + + String businessKey = UUID.randomUUID().toString(); + String createVfModuleRequest = + FileUtil.readResourceFile("__files/CreateVfModule_VID_request_noPreloads.json"); + + Map variables = setupVariablesSunnyDayVID(); TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVfModuleInfra", "v1", businessKey, createVfModuleRequest, variables); @@ -131,7 +177,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { private Map setupVariablesSunnyDayVID() { Map variables = new HashMap(); //try { - // variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json")); + //variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json")); //} //catch (Exception e) { @@ -159,39 +205,35 @@ public class CreateVfModuleInfraTest extends WorkflowTest { * @throws Exception */ @Test + @Ignore @Deployment(resources = { "process/CreateVfModuleInfra.bpmn", "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenericGetVnf.bpmn", "subprocess/SDNCAdapterV1.bpmn", "subprocess/VnfAdapterRestV1.bpmn", "subprocess/ConfirmVolumeGroupTenant.bpmn", "subprocess/ConfirmVolumeGroupName.bpmn", "subprocess/CreateAAIVfModule.bpmn", "subprocess/CreateAAIVfModuleVolumeGroup.bpmn", + "subprocess/GenericNotificationService.bpmn", "subprocess/UpdateAAIVfModule.bpmn", "subprocess/UpdateAAIGenericVnf.bpmn", "subprocess/CompleteMsoProcess.bpmn", "subprocess/FalloutHandler.bpmn" }) + public void sunnyDayVIDWithVolumeGroupAttach() throws Exception { logStart(); - MockGetVolumeGroupById("AAIAIC25", "78987", "VfModularity/VolumeGroup.xml"); - MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); - MockGetCloudRegion("MDTWNJ21", 200, "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml"); - MockGetVolumeGroupById("RDM2WAGPLCP", "78987", "DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); - MockPutVfModuleIdNoResponse("skask", "PCRF", ".*"); - mockVNFPost("", 202, "skask"); - MockGetNetworkPolicyfqdn(".*", "VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml", 200); - MockPutGenericVnf("skask"); - MockGetGenericVnfByIdWithPriority("skask", ".*", 200, "VfModularity/VfModule-new.xml", 5); - mockSDNCAdapter("/SDNCAdapter", "vnf-type>STMTN", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockVNFPost("", 202, "skask"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + MockAAIVfModule(); MockPatchGenericVnf("skask"); MockPatchVfModuleId("skask", ".*"); + MockSDNCAdapterVfModule(); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); String businessKey = UUID.randomUUID().toString(); String createVfModuleRequest = diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java deleted file mode 100644 index 9ef4c94cce..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java +++ /dev/null @@ -1,840 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeAsyncWorkflow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.getVariable; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCloudRegion; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetwork; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkRouteTable; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetwork; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockPutNetworkAdapter; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapterTopology; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.BPMNUtil; -import org.openecomp.mso.bpmn.common.SDNCAdapterCallbackRule; -import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.openecomp.mso.bpmn.common.WorkflowTestTransformer; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; -import org.openecomp.mso.bpmn.mock.SDNCAdapterNetworkTopologyMockTransformer; - -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; - -/** - * Unit test cases for UpdateNetworkInstanceInfra.bpmn - * - */ -public class UpdateNetworkInstanceInfraTest extends WorkflowTest { - @WorkflowTestTransformer - public static final ResponseTransformer sdncAdapterMockTransformer = - new SDNCAdapterNetworkTopologyMockTransformer(); - - @Rule - public final SDNCAdapterCallbackRule sdncAdapterCallbackRule = - new SDNCAdapterCallbackRule(processEngineRule); - - /** - * End-to-End flow - Unit test for UpdateNetworkInstanceInfra.bpmn - * - String input & String response - */ - - @Test - //@Ignore - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Success1() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success1 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - System.out.println("----------------------------------------------------------"); - System.out.println("- got workflow response -"); - System.out.println("----------------------------------------------------------"); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("true", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - String workflowResp = BPMNUtil.getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "WorkflowResponse"); - Assert.assertNotNull(workflowResp); - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success1 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - @Test - //@Ignore - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Success2() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success2 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables2(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("true", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - String completeMsoProcessRequest = - "" + '\n' - + " " + '\n' - + " testRequestId" + '\n' - + " UPDATE" + '\n' - + " VID" + '\n' - + " " + '\n' - + " BPMN Network action: UPDATE" + '\n' - + ""; - - Assert.assertEquals(completeMsoProcessRequest, getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success2 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_MissingNetworkId() throws Exception { - - System.out.println("--------------------------------------------------------------------"); - System.out.println(" Missing networkId - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("--------------------------------------------------------------------"); - - // setup simulators - - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariablesMissingNetworkId(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - String falloutHandlerActual = getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest"); - String falloutHandlerExpected = -"" + "\n" + -" " + "\n" + -" 88f65519-9a38-4c4b-8445-9eb4a5a5af56" + "\n" + -" UPDATE" + "\n" + -" VID" + "\n" + -" " + "\n" + -" " + "\n" + -" Variable 'network-id' value/element is missing." + "\n" + -" 2500" + "\n" + -" " + "\n" + -" "; - - assertEquals("Response", falloutHandlerExpected, falloutHandlerActual); - - System.out.println("------------------------------------------------------------------"); - System.out.println(" Missing networkId - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("------------------------------------------------------------------"); - - } - - /* NOT NEEDED - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback1() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback1 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockAAIResponse_queryId_UpdateNetwork_404V2(); // failure in queryId in AAI - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariablesSDNCRollback(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback1 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } */ - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback_Scenario01() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml", 200); // no 'payload' response from NetworkAdapter, version 2 - //MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); // let it fail (404) to see SDNC compensation - //MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); // let it fail (404) to see SDNC compensation - //MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariablesSDNCRollback(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Network_SDNC_Rollback() throws Exception { - - System.out.println("---------------------------------------------------------------"); - System.out.println(" Network and SDNC Rollback - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("---------------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockAAIResponse_updateContrail_CreateNetwork_SuccessV2(); // designed to fail in AAI Update - //mockUpdateRequestDB(500, "Database/DBUpdateResponse.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("---------------------------------------------------------------------"); - System.out.println(" Network and SCNC Rollback - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("---------------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Network_SDNC_Rollback_Failed() throws Exception { - - System.out.println("---------------------------------------------------------------"); - System.out.println(" Network and SDNC Rollback - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("---------------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySim500Response.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockAAIResponse_updateContrail_CreateNetwork_SuccessV2(); // designed to fail in AAI Update - //mockUpdateRequestDB(500, "Database/DBUpdateResponse.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("---------------------------------------------------------------------"); - System.out.println(" Network and SCNC Rollback - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("---------------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback2() throws Exception { - - System.out.println("----------------------------------------------------"); - System.out.println(" SDNCRollback2 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 500, "UpdateNetworkV2/updateNetworkResponse_500.xml"); // failure 500 in NetworkAdapter - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("------------------------------------------------------------"); - System.out.println(" SDNCRollback2 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback3() throws Exception { - - System.out.println("----------------------------------------------------"); - System.out.println(" SDNCRollback3 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 400, "UpdateNetworkV2/updateNetworkResponse_400.xml"); // failure 400 in NetworkAdapter - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("------------------------------------------------------------"); - System.out.println(" SDNCRollback3 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_PONR() throws Exception { - - System.out.println("--------------------------------------------------------------------"); - System.out.println(" PONR (Point-of-no-Return) - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("--------------------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(500, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - String falloutHandlerRequest = - "" + '\n' - + " " + '\n' - + " testRequestId" + '\n' - + " CREATE" + '\n' - + " VID" + '\n' - + " " + '\n' - + " " + '\n' - + " DB Update failed, code: 500" + '\n' - + " 2500" + '\n' - + " " + '\n' - + " "; - - System.out.println("Display UPDNETI_FalloutHandlerRequest - " + getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - //Assert.assertEquals(falloutHandlerRequest, getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("--------------------------------------------------------------------"); - System.out.println(" PONR (Point-of-no-Return) - UpdateNetworkInstanceInfra flow Completed! "); - System.out.println("--------------------------------------------------------------------"); - - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_sdncFailure() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" SNDC Failure - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - //MockSDNCAdapterBadAsynchronousResponse(); // 404 - mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 500, ""); // 500 - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables2(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" SNDC Failure - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - // ***************** - // Utility Section - // ***************** - - // Success Scenario - private Map setupVariables1() { - Map variables = new HashMap(); - variables.put("bpmnRequest", getCreateNetworkRequest1()); - variables.put("mso-request-id", "testRequestId"); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "CREATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequest1() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_1\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"backoutOnFailure\": true, " + '\n' + - " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - } - - // Success Scenario 2 - private Map setupVariables2() { - Map variables = new HashMap(); - variables.put("bpmnRequest", getCreateNetworkRequest2()); - variables.put("mso-request-id", "testRequestId"); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequest2() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"myOwn_Network\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"backoutOnFailure\": true, " + '\n' + - " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - - } - - /* Active Scenario - private Map setupVariablesActive() { - Map variables = new HashMap(); - variables.put("mso-request-id", "testRequestId"); - variables.put("bpmnRequest", getCreateNetworkRequestActive()); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequestActive() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_2\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - - } */ - - // Missing Name Scenario - private Map setupVariablesMissingNetworkId() { - Map variables = new HashMap(); - variables.put("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); - variables.put("bpmnRequest", getCreateNetworkRequestNetworkId()); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - //variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); // missing, ok - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - - return variables; - - } - - public String getCreateNetworkRequestNetworkId() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - - } - - // SDNC Rollback Scenario - private Map setupVariablesSDNCRollback() { - Map variables = new HashMap(); - variables.put("mso-request-id", "testRequestId"); - variables.put("bpmnRequest", getCreateNetworkRequestSDNCRollback()); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequestSDNCRollback() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_3\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - - return request; - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java index 34c0af43c4..6a5e241dc2 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java @@ -1,141 +1,143 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure; - -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockPutVNFVolumeGroup; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; -import org.openecomp.mso.bpmn.mock.FileUtil; - -/** - * Unit test cases for UpdateVfModuleVolume.bpmn - */ -public class UpdateVfModuleVolumeInfraV1Test extends WorkflowTest { - - private final CallbackSet callbacks = new CallbackSet(); - - public UpdateVfModuleVolumeInfraV1Test() throws IOException { - callbacks.put("volumeGroupUpdate", FileUtil.readResourceFile( - "__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml")); - } - - /** - * Happy path scenario. - * - * @throws Exception - */ - @Test - @Deployment(resources = { - "process/UpdateVfModuleVolumeInfraV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/FalloutHandler.bpmn" - }) - public void happyPath() throws Exception { - - logStart(); - - MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); - MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); - MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); - mockPutVNFVolumeGroup("78987", 202); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - - String businessKey = UUID.randomUUID().toString(); - String updaetVfModuleVolRequest = - FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json"); - - Map testVariables = new HashMap(); - testVariables.put("requestId", "TEST-REQUEST-ID-0123"); - testVariables.put("serviceInstanceId", "test-service-instance-id"); - testVariables.put("volumeGroupId", "78987"); - testVariables.put("vnfId", "TEST-VNF-ID-0123"); - TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); - WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); - - String responseBody = response.getResponse(); - System.out.println("Workflow (Synch) Response:\n" + responseBody); - - injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); - - waitForProcessEnd(businessKey, 10000); - checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); - - logEnd(); - } - - /** - * VF Module Personal model id does not match request model invariant id - * @throws Exception - */ - @Test - //@Ignore - @Deployment(resources = { - "process/UpdateVfModuleVolumeInfraV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/FalloutHandler.bpmn" - }) - public void testPersonaModelIdNotMatch() throws Exception { - - logStart(); - - MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); - MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); - MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); - mockPutVNFVolumeGroup("78987", 202); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - - String businessKey = UUID.randomUUID().toString(); - String updaetVfModuleVolRequest = - FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json"); - - Map testVariables = new HashMap(); - testVariables.put("requestId", "TEST-REQUEST-ID-0123"); - testVariables.put("serviceInstanceId", "test-service-instance-id"); - testVariables.put("volumeGroupId", "78987"); - testVariables.put("vnfId", "TEST-VNF-ID-0123"); - TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); - WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); - - String responseBody = response.getResponse(); - System.out.println("Workflow (Synch) Response:\n" + responseBody); - - injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); - - waitForProcessEnd(businessKey, 10000); - checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); - - logEnd(); - } -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.bpmn.infrastructure; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockPutVNFVolumeGroup; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit test cases for UpdateVfModuleVolume.bpmn + */ +public class UpdateVfModuleVolumeInfraV1Test extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + + public UpdateVfModuleVolumeInfraV1Test() throws IOException { + callbacks.put("volumeGroupUpdate", FileUtil.readResourceFile( + "__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml")); + } + + /** + * Happy path scenario. + * + * @throws Exception + */ + @Test + @Deployment(resources = { + "process/UpdateVfModuleVolumeInfraV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericNotificationService.bpmn", + "subprocess/FalloutHandler.bpmn" + }) + public void happyPath() throws Exception { + + logStart(); + + MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); + MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); + MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); + mockPutVNFVolumeGroup("78987", 202); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + String updaetVfModuleVolRequest = + FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json"); + + Map testVariables = new HashMap(); + testVariables.put("requestId", "TEST-REQUEST-ID-0123"); + testVariables.put("serviceInstanceId", "test-service-instance-id"); + testVariables.put("volumeGroupId", "78987"); + testVariables.put("vnfId", "TEST-VNF-ID-0123"); + TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); + + logEnd(); + } + + /** + * VF Module Personal model id does not match request model invariant id + * @throws Exception + */ + @Test + //@Ignore + @Deployment(resources = { + "process/UpdateVfModuleVolumeInfraV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericNotificationService.bpmn", + "subprocess/FalloutHandler.bpmn" + }) + public void testPersonaModelIdNotMatch() throws Exception { + + logStart(); + + MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); + MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); + MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); + mockPutVNFVolumeGroup("78987", 202); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + String updaetVfModuleVolRequest = + FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json"); + + Map testVariables = new HashMap(); + testVariables.put("requestId", "TEST-REQUEST-ID-0123"); + testVariables.put("serviceInstanceId", "test-service-instance-id"); + testVariables.put("volumeGroupId", "78987"); + testVariables.put("vnfId", "TEST-VNF-ID-0123"); + TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); + + logEnd(); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json new file mode 100644 index 0000000000..1b56dbddbc --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json @@ -0,0 +1,69 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "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", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12..base..module-0", +"modelVersion": "1" +} +} +}, +{ +"relatedInstance": { +"instanceId": "123456", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "skask", +"instanceName": "skask-test", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "vSAMP12 1" +} +} +} +], +"requestParameters": { +"usePreload": true, +"userParams": {} +} +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json new file mode 100644 index 0000000000..f8cac48f1f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json @@ -0,0 +1,79 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "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", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12..base..module-0", +"modelVersion": "1" +} +} +}, +{ +"relatedInstance": { +"instanceId": "123456", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "skask", +"instanceName": "skask-test", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml new file mode 100644 index 0000000000..110e4327df --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml new file mode 100644 index 0000000000..181473543f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml index b2560bcb47..85427e2fcc 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml @@ -1,38 +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 - - - - - - + + 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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml new file mode 100644 index 0000000000..f6314e55b3 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml new file mode 100644 index 0000000000..5fa58e9c03 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml new file mode 100644 index 0000000000..2b732f952d --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml new file mode 100644 index 0000000000..3e138775d4 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml new file mode 100644 index 0000000000..27cab6b422 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/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://msojra.infra.aic.att.net: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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml new file mode 100644 index 0000000000..be6f973260 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/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://mtanjv9moja01-eth1-0.aic.cip.att.com: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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml new file mode 100644 index 0000000000..3afcb3f21c --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml new file mode 100644 index 0000000000..2d3ebebccd --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml @@ -0,0 +1,16 @@ + + skask + supercool + slowburn + + + key1 + value1 + + + key2 + value2 + + + {{MESSAGE-ID}} + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml new file mode 100644 index 0000000000..af2bd7abfd --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml @@ -0,0 +1,15 @@ + + 78987 + slowburn + + + key1 + value1 + + + key2 + value2 + + + {{MESSAGE-ID}} + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml new file mode 100644 index 0000000000..8de2f95901 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml index a71441e916..e72d23d9d9 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml @@ -1,9 +1,9 @@ - - b37d96db-7d2c-47ce-bf61-a6c7b82fe161 - PCRF::module-0-2 - 00000000-0000-0000-0000-000000000000 - 1.0 - false - pending-create - 330-90 + + 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/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml index 1066b17b94..15a84aad05 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml @@ -1,27 +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 - - - + + 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/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties index ac340c79b6..b14d49511a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties @@ -10,7 +10,8 @@ mso.csi.usrname=mso mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7 mso.adapters.completemsoprocess.endpoint=http://localhost:28090/CompleteMsoProcess - +mso.workflow.message.endpoint=http://localhost:8080/mso/WorkflowMessage +mso.catalog.db.endpoint=http://localhost:8090 mso.adapters.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter mso.adapters.db.auth=757A94191D685FD2092AC1490730A4FC @@ -30,6 +31,7 @@ mso.sdnc.firewall.yang.model=http://com/openecomp/svc/mis/firewall-lite-gui mso.sdnc.firewall.yang.model.version=2015-05-15 mso.sdnc.password=3141634BF7E070AA289CF2892C986C0B mso.sdnc.timeout.firewall.minutes=20 +mso.callbackRetryAttempts=5 mso.sdnc.timeout=PT10S mso.sdnc.timeout.ucpe.async.hours=120 mso.sdnc.timeout.ucpe.async.minutes=5 @@ -56,7 +58,7 @@ aai.endpoint=http://localhost:28090 # Example to override default version for a resource: #mso.workflow.default.aai.vce.version=6 #mso.workflow.default.aai.v6.vce.uri=/aai/v6/network/vces/vce - +mso.workflow.global.default.aai.namespace=http://org.openecomp.aai.inventory/ mso.workflow.global.default.aai.version=8 mso.workflow.default.aai.cloud-region.version=9 mso.workflow.default.aai.generic-vnf.version=9 diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java index 07bde0accb..c4139c99cf 100644 --- a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java +++ b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java @@ -27,6 +27,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.containing; import static com.github.tomakehurst.wiremock.client.WireMock.delete; import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.post; 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; @@ -516,6 +517,129 @@ public class StubResponseAAI { .withStatus(200))); } + ///////////// + + public static void MockVNFAdapterRestVfModule() { + stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987")) + .willReturn(aResponse() + .withStatus(202) + .withHeader("Content-Type", "application/xml"))); + } + + public static void MockDBUpdateVfModule(){ + stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/DBUpdateResponse.xml"))); + } + + // start of mocks used locally and by other VF Module unit tests + public static void MockSDNCAdapterVfModule() { + // simplified the implementation to return "success" for all requests + stubFor(post(urlEqualTo("/SDNCAdapter")) +// .withRequestBody(containing("SvcInstanceId><")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml"))); + + } + + // start of mocks used locally and by other VF Module unit tests + public static void MockAAIVfModule() { + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool")) + .atPriority(1) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/VfModule-supercool.xml"))); + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm")) + .atPriority(2) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/VfModule-lukewarm.xml"))); + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*")) + .atPriority(5) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/VfModule-new.xml"))); + stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/GenericVnf.xml"))); + stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool")) +// .withRequestBody(containing("PCRF")) + .willReturn(aResponse() + .withStatus(200))); + stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*")) +// .withRequestBody(containing("PCRF")) + .willReturn(aResponse() + .withStatus(200))); + // HTTP PUT stub still used by CreateAAIvfModuleVolumeGroup + stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*")) + .withRequestBody(containing("PCRF")) + .willReturn(aResponse() + .withStatus(200))); + // HTTP PUT stub still used by DoCreateVfModuleTest + stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*")) + .withRequestBody(containing("MODULELABEL")) + .willReturn(aResponse() + .withStatus(200))); + stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml"))); + stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml"))); + stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21/volume-groups/volume-group/78987")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/VolumeGroup.xml"))); + stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group/78987")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/VolumeGroup.xml"))); + stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("DeleteCinderVolumeV1/DeleteVolumeId_AAIResponse_Success.xml"))); + stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VfModularity/AddNetworkPolicy_AAIResponse_Success.xml"))); + stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId")) + .withRequestBody(containing("NEWvBNGModuleId")) + .willReturn(aResponse() + .withStatus(200))); + } + + + + ////////////// /** * Cloud infrastructure below @@ -607,6 +731,12 @@ public class StubResponseAAI { .withStatus(returnCode))); } + public static void MockAAIVfModuleBadPatch(String endpoint, int statusCode) { + stubFor(patch(urlMatching(endpoint)) + .willReturn(aResponse() + .withStatus(statusCode))); + } + //// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones above //// @Deprecated public static void MockGetVceById(){ diff --git a/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/APIResponse.java b/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/APIResponse.java index e4eee6d695..ea9ca62bf5 100644 --- a/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/APIResponse.java +++ b/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/APIResponse.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,19 +25,18 @@ import java.util.Arrays; import org.apache.http.Header; import org.apache.http.HttpResponse; -import org.apache.http.message.BasicHeader; import org.apache.http.util.EntityUtils; /** * An immutable class that encapsulates an API response. - * + * * @version 1.0 * @since 1.0 */ public class APIResponse { private final int statusCode; private final byte[] responseBody; - private final BasicHeader[] headers; + private final HttpHeader[] headers; /** * Internal method used to create http headers using the specified @@ -46,17 +45,17 @@ public class APIResponse { * @param httpResponse used to create headers * @return http headers */ - private static BasicHeader[] buildHeaders(final HttpResponse httpResponse) { + private static HttpHeader[] buildHeaders(final HttpResponse httpResponse) { final Header[] headers = httpResponse.getAllHeaders(); - BasicHeader[] httpHeaders = new BasicHeader[headers.length]; + HttpHeader[] httpHeaders = new HttpHeader[headers.length]; for (int i = 0; i < headers.length; ++i) { final Header header = headers[i]; final String name = header.getName(); - final String value = header.getValue(); - final BasicHeader httpHeader = new BasicHeader(name, value); + final String value = header.getValue(); + final HttpHeader httpHeader = new HttpHeader(name, value); httpHeaders[i] = httpHeader; - } + } return httpHeaders; } @@ -90,7 +89,7 @@ public class APIResponse { /** * Gets the http status code returned by the api server. *

- * For example, status code 200 represents 'OK.' + * For example, status code 200 represents 'OK.' * * @return status code */ @@ -128,15 +127,15 @@ public class APIResponse { /** * Gets a list of all the headers returned by the API response. * - * @return an array of all the BasicHeaders + * @return an array of all the HttpHeaders */ - public BasicHeader[] getAllHeaders() { + public HttpHeader[] getAllHeaders() { // avoid exposing internals, create copy return Arrays.copyOf(this.headers, this.headers.length); } public String getFirstHeader(String name) { - for (BasicHeader header : headers) { + for (HttpHeader header : headers) { if (header.getName().equals(name)) { return header.getValue(); } diff --git a/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/HttpHeader.java b/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/HttpHeader.java new file mode 100644 index 0000000000..e0d6c3056d --- /dev/null +++ b/bpmn/MSORESTClient/src/main/java/org/openecomp/mso/rest/HttpHeader.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.rest; + +/** + * An immutable class used to wrap an http header. + * + * @version 1.0 + * @since 1.0 + */ +public class HttpHeader { + private final String name; + private final String value; + + /** + * Create an http header using the specified name and value + * + * @param name name of http header + * @param value value of http header + */ + public HttpHeader(final String name, final String value) { + if (name == null) { + throw new IllegalArgumentException("Name may not be null."); + } + + this.name = name; + this.value = value; + } + + /** + * Gets the header name. + * + * @return header name + */ + public String getName() { + return this.name; + } + + /** + * Gets the header value. + * + * @return header value + */ + public String getValue() { + return this.value; + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseESTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseESTest.java index 2bd4dbdca8..e44a44d118 100644 --- a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseESTest.java +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseESTest.java @@ -39,7 +39,6 @@ import org.apache.http.StatusLine; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.StringEntity; import org.apache.http.impl.EnglishReasonPhraseCatalog; -import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicHttpResponse; import org.apache.http.message.BasicStatusLine; import org.evosuite.runtime.EvoRunner; @@ -173,7 +172,7 @@ public class APIResponseESTest extends APIResponseESTestscaffolding { BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 0, ""); basicHttpResponse0.addHeader("", ""); APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); - BasicHeader[] httpHeaderArray0 = aPIResponse0.getAllHeaders(); + HttpHeader[] httpHeaderArray0 = aPIResponse0.getAllHeaders(); assertNotNull(httpHeaderArray0); } @@ -181,7 +180,7 @@ public class APIResponseESTest extends APIResponseESTestscaffolding { public void test11() throws Throwable { BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 1471, "0fVXWr>"); APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); - BasicHeader[] httpHeaderArray0 = aPIResponse0.getAllHeaders(); + HttpHeader[] httpHeaderArray0 = aPIResponse0.getAllHeaders(); assertNotNull(httpHeaderArray0); } @@ -212,11 +211,11 @@ public class APIResponseESTest extends APIResponseESTestscaffolding { aPIResponse0.getResponseBodyAsString(); basicHttpResponse0.getStatusLine(); aPIResponse0.getStatusCode(); - BasicHeader[] httpHeaderArray0 = new BasicHeader[2]; - BasicHeader httpHeader0 = mock(BasicHeader.class, new ViolatedAssumptionAnswer()); + HttpHeader[] httpHeaderArray0 = new HttpHeader[2]; + HttpHeader httpHeader0 = mock(HttpHeader.class, new ViolatedAssumptionAnswer()); doReturn((String) null).when(httpHeader0).getName(); httpHeaderArray0[0] = httpHeader0; - BasicHeader httpHeader1 = mock(BasicHeader.class, new ViolatedAssumptionAnswer()); + HttpHeader httpHeader1 = mock(HttpHeader.class, new ViolatedAssumptionAnswer()); httpHeaderArray0[1] = httpHeader1; PrivateAccess.setVariable((Class) APIResponse.class, aPIResponse0, "headers", (Object) httpHeaderArray0); // Undeclared exception! diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTest.java new file mode 100644 index 0000000000..f0aeee0f99 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTest.java @@ -0,0 +1,99 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:47:07 GMT 2016 + */ + +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.rest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class HttpHeaderESTest extends HttpHeaderESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("Fw", "WD#>QF/v6_|_A"); + String string0 = httpHeader0.getValue(); + assertEquals("WD#>QF/v6_|_A", string0); + assertEquals("Fw", httpHeader0.getName()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("", ""); + String string0 = httpHeader0.getValue(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("Nae may no be null.", "Nae may no be null."); + PrivateAccess.setVariable((Class) HttpHeader.class, httpHeader0, "name", (Object) null); + String string0 = httpHeader0.getName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("", "EIqJp"); + String string0 = httpHeader0.getName(); + assertEquals("EIqJp", httpHeader0.getValue()); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + HttpHeader httpHeader0 = null; + try { + httpHeader0 = new HttpHeader((String) null, (String) null); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Name may not be null. + // + verifyException("org.openecomp.mso.rest.HttpHeader", e); + } + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("Nae may no be null.", "Nae may no be null."); + String string0 = httpHeader0.getName(); + assertEquals("Nae may no be null.", string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("|SJ`pSz:BCB1o8~", (String) null); + String string0 = httpHeader0.getValue(); + assertNull(string0); + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTestscaffolding.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTestscaffolding.java new file mode 100644 index 0000000000..0438c1fba6 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTestscaffolding.java @@ -0,0 +1,98 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:47:07 GMT 2016 + */ + +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.rest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class HttpHeaderESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.rest.HttpHeader"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(HttpHeaderESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.rest.HttpHeader" + ); + } + + private static void resetClasses() { + } +} -- cgit 1.2.3-korg