-/*-\r
- * ============LICENSE_START=======================================================\r
- * OPENECOMP - MSO\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.mso.bpmn.infrastructure.scripts\r
-\r
-import org.camunda.bpm.engine.delegate.BpmnError\r
-import org.camunda.bpm.engine.runtime.Execution\r
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil\r
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
-import org.openecomp.mso.bpmn.common.scripts.NetworkUtils\r
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils\r
-import org.openecomp.mso.bpmn.common.scripts.VfModule\r
-import org.openecomp.mso.bpmn.common.scripts.VfModuleBase\r
-import org.openecomp.mso.bpmn.core.WorkflowException\r
-import org.openecomp.mso.bpmn.core.json.JsonUtils;\r
-import org.openecomp.mso.rest.APIResponse\r
-import org.springframework.web.util.UriUtils\r
-\r
-public class DoUpdateVfModule extends VfModuleBase {\r
-\r
- ExceptionUtil exceptionUtil = new ExceptionUtil()\r
- JsonUtils jsonUtil = new JsonUtils()\r
-\r
- /**\r
- * Initialize the flow's variables.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void initProcessVariables(Execution execution) {\r
- execution.setVariable('prefix', 'DOUPVfMod_')\r
- execution.setVariable('DOUPVfMod_requestInfo', null)\r
- execution.setVariable('DOUPVfMod_serviceInstanceId', null)\r
- execution.setVariable('DOUPVfMod_requestId', null)\r
- execution.setVariable('DOUPVfMod_vnfInputs', null)\r
- execution.setVariable('DOUPVfMod_vnfId', null)\r
- execution.setVariable('DOUPVfMod_vnfName', null)\r
- execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)\r
- execution.setVariable('DOUPVfMod_vfModuleName', null)\r
- execution.setVariable('DOUPVfMod_vfModuleId', null)\r
- execution.setVariable('DOUPVfMod_vnfType', null)\r
- execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)\r
- execution.setVariable('DOUPVfMod_vfModuleModelName', null)\r
- execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)\r
- execution.setVariable("DOUPVfMod_isBaseVfModule", "false")\r
- execution.setVariable('DOUPVfMod_serviceId', null)\r
- execution.setVariable('DOUPVfMod_aicCloudRegion', null)\r
- execution.setVariable('DOUPVfMod_tenantId', null)\r
- execution.setVariable('DOUPVfMod_volumeGroupId', null)\r
- execution.setVariable('DOUPVfMod_vfModule', null)\r
- execution.setVariable('DOUPVfMod_vnfParams', null)\r
- execution.setVariable("DOUPVfMod_baseVfModuleId", "")\r
- execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")\r
- execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)\r
- execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)\r
- execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)\r
- execution.setVariable('DOUPVfMod_sdncActivateRequest', null)\r
- execution.setVariable('DOUPVfMod_sdncActivateResponse', null)\r
- execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)\r
- execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)\r
- execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)\r
- execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)\r
- execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)\r
- execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)\r
- execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)\r
- }\r
-\r
- /**\r
- * Check for missing elements in the received request.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void preProcessRequest(Execution execution) {\r
- def method = getClass().getSimpleName() + '.preProcessRequest(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- initProcessVariables(execution)\r
- def xml = getVariable(execution, 'DoUpdateVfModuleRequest')\r
- utils.logAudit("DoUpdateVfModule request: " + xml)\r
- logDebug('Received request xml:\n' + xml, isDebugLogEnabled)\r
- \r
- if (xml == null || xml.isEmpty()) {\r
- // Building Block-type request\r
-\r
- String cloudConfiguration = execution.getVariable("cloudConfiguration")\r
- String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")\r
- \r
- def serviceModelInfo = execution.getVariable("serviceModelInfo")\r
- logDebug("serviceModelInfo: " + serviceModelInfo, isDebugLogEnabled)\r
- def vnfModelInfo = execution.getVariable("vnfModelInfo")\r
- \r
-\r
- //tenantId\r
- def tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId")\r
- execution.setVariable("DOUPVfMod_tenantId", tenantId)\r
- \r
- //volumeGroupId\r
- def volumeGroupId = execution.getVariable("volumeGroupId")\r
- execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)\r
- //volumeGroupName\r
- def volumeGroupName = execution.getVariable("volumeGroupName")\r
- execution.setVariable("DOUPVfMod_volumeGroupName", volumeGroupName)\r
- //cloudSiteId\r
- def cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId")\r
- execution.setVariable("DOUPVfMod_cloudSiteId", cloudSiteId)\r
- \r
- logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled)\r
- //vnfType\r
- def vnfType = execution.getVariable("vnfType")\r
- execution.setVariable("DOUPVfMod_vnfType", vnfType)\r
- \r
- logDebug("vnfType: " + vnfType, isDebugLogEnabled)\r
- //vnfName\r
- def vnfName = execution.getVariable("vnfName")\r
- execution.setVariable("DOUPVfMod_vnfName", vnfName)\r
- \r
- logDebug("vnfName: " + vnfName, isDebugLogEnabled)\r
- //vnfId\r
- def vnfId = execution.getVariable("vnfId")\r
- execution.setVariable("DOUPVfMod_vnfId", vnfId)\r
- \r
- logDebug("vnfId: " + vnfId, isDebugLogEnabled)\r
- //vfModuleName\r
- def vfModuleName = execution.getVariable("vfModuleName")\r
- execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)\r
- \r
- logDebug("vfModuleName: " + vfModuleName, isDebugLogEnabled)\r
- //vfModuleModelName\r
- def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")\r
- execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)\r
- \r
- logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled)\r
- //modelCustomizationUuid\r
- def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationId")\r
- execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)\r
- \r
- logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled)\r
- //vfModuleId\r
- def vfModuleId = execution.getVariable("vfModuleId")\r
- execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)\r
- logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled)\r
- def requestId = execution.getVariable("requestId")\r
- execution.setVariable("DOUPVfMod_requestId", requestId)\r
- logDebug("requestId: " + requestId, isDebugLogEnabled)\r
- // Set mso-request-id to request-id for VNF Adapter interface\r
- execution.setVariable("mso-request-id", requestId)\r
- //serviceId\r
- def serviceId = execution.getVariable("serviceId")\r
- execution.setVariable("DOUPVfMod_serviceId", serviceId)\r
- logDebug("serviceId: " + serviceId, isDebugLogEnabled)\r
- //serviceInstanceId\r
- def serviceInstanceId = execution.getVariable("serviceInstanceId")\r
- execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)\r
- \r
- logDebug("serviceInstanceId: " + serviceInstanceId, isDebugLogEnabled)\r
- //source - HARDCODED\r
- def source = "VID"\r
- execution.setVariable("DOUPVfMod_source", source)\r
- \r
- logDebug("source: " + source, isDebugLogEnabled)\r
- //backoutOnFailure\r
- def disableRollback = execution.getVariable("disableRollback")\r
- def backoutOnFailure = true\r
- if (disableRollback != null && disableRollback.equals("true")) {\r
- backoutOnFailure = false\r
- }\r
- execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)\r
- logDebug("backoutOnFailure: " + backoutOnFailure, isDebugLogEnabled)\r
- //isBaseVfModule\r
- def isBaseVfModule = execution.getVariable("isBaseVfModule")\r
- execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)\r
- logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled)\r
- //asdcServiceModelVersion\r
- def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")\r
- execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)\r
- logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled)\r
- //personaModelId\r
- execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantId"))\r
- //personaModelVersion\r
- execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))\r
- //Get or Generate UUID\r
- String uuid = execution.getVariable("DOUPVfMod_uuid")\r
- if(uuid == null){\r
- uuid = UUID.randomUUID()\r
- logDebug("Generated messageId (UUID) is: " + uuid, isDebugLogEnabled)\r
- }else{\r
- logDebug("Found messageId (UUID) is: " + uuid, isDebugLogEnabled)\r
- }\r
- //isVidRequest\r
- String isVidRequest = execution.getVariable("isVidRequest")\r
- // default to true\r
- if (isVidRequest == null || isVidRequest.isEmpty()) {\r
- execution.setVariable("isVidRequest", "true")\r
- }\r
- //globalSubscriberId\r
- String globalSubscriberId = execution.getVariable("globalSubscriberId")\r
- execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)\r
- logDebug("globalSubsrciberId: " + globalSubscriberId, isDebugLogEnabled)\r
- //vnfQueryPath\r
- String vnfQueryPath = execution.getVariable("vnfQueryPath")\r
- execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)\r
- logDebug("vnfQueryPath: " + vnfQueryPath, isDebugLogEnabled)\r
-\r
- String vnfParamsChildNodes = execution.getVariable("vfModuleInputParams")\r
- execution.setVariable('DOUPVfMod_vnfParams', vnfParamsChildNodes)\r
- }\r
- else {\r
-\r
- def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')\r
- execution.setVariable('DOUPVfMod_requestInfo', requestInfo)\r
- execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))\r
- def serviceInstanceId = execution.getVariable('mso-service-instance-id')\r
- if (serviceInstanceId == null) {\r
- serviceInstanceId = ''\r
- }\r
- execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)\r
- \r
- def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')\r
- execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)\r
- execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))\r
- execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))\r
- execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))\r
- execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))\r
- execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))\r
- execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))\r
- execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))\r
- execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))\r
- execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))\r
- execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))\r
- execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))\r
- //isBaseVfModule\r
- def isBaseVfModule = "false"\r
- if (utils.nodeExists(xml, "is-base-vf-module")) {\r
- isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")\r
- execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)\r
- }\r
- logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled)\r
- \r
- NetworkUtils networkUtils = new NetworkUtils()\r
- def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)\r
- execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)\r
- \r
- def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')\r
- execution.setVariable('DOUPVfMod_volumeGroupId', vgi)\r
- \r
- execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))\r
- }\r
-\r
- def sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')\r
- if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {\r
- def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'\r
- logError(msg)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)\r
- }\r
-\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())\r
- }\r
- }\r
-\r
- /**\r
- * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will\r
- * set the orchestration-status to 'pending-update'.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void prepPrepareUpdateAAIVfModule(Execution execution) {\r
- def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
- def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
- def orchestrationStatus = 'pending-update'\r
-\r
- String prepareUpdateAAIVfModuleRequest = """\r
- <PrepareUpdateAAIVfModuleRequest>\r
- <vnf-id>${vnfId}</vnf-id>\r
- <vf-module-id>${vfModuleId}</vf-module-id>\r
- <orchestration-status>${orchestrationStatus}</orchestration-status>\r
- </PrepareUpdateAAIVfModuleRequest>\r
- """\r
- prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)\r
- execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)\r
- utils.logAudit("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)\r
- logDebug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest, isDebugLogEnabled)\r
-\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())\r
- }\r
- }\r
-\r
- /**\r
- * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow. Currently,\r
- * there is really nothing to do, so we just log that we're passing through.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void prepConfirmVolumeGroupTenant(Execution execution) {\r
- def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- // Nothing to do - just log that we're passing through here\r
-\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepConfirmVolumeGroupTenant(): ' + e.getMessage())\r
- }\r
- }\r
-\r
- /**\r
- * Prepare a Request for invoking the SDNC Adapter subflow to perform\r
- * a VNF topology 'changeassign' operation.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void prepSDNCTopologyChg(Execution execution) {\r
- def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- def requestId = execution.getVariable('DOUPVfMod_requestId')\r
- def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')\r
- def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')\r
- def serviceId = execution.getVariable('DOUPVfMod_serviceId')\r
- def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
- def vnfType = execution.getVariable('DOUPVfMod_vnfType')\r
- def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
- def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')\r
- def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')\r
- def vfModuleName = vfModule.getElementText('vf-module-name')\r
- def tenantId = execution.getVariable('DOUPVfMod_tenantId')\r
- def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')\r
-\r
- // Retrieve vnf name from AAI response\r
- def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')\r
- execution.setVariable('DOUPVfMod_vnfName', vnfName)\r
-\r
- def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')\r
- def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)\r
-\r
- String sdncTopologyRequest = """\r
- <sdncadapterworkflow:SDNCAdapterWorkflowRequest\r
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"\r
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">\r
- <sdncadapter:RequestHeader>\r
- <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>\r
- <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>\r
- <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>\r
- <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>\r
- <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>\r
- </sdncadapter:RequestHeader>\r
- <sdncadapterworkflow:SDNCRequestData>\r
- <request-information>\r
- <request-id>${requestId}</request-id>\r
- <request-action>ChangeVNFActivateRequest</request-action>\r
- <source>PORTAL</source>\r
- <notification-url/>\r
- <order-number/>\r
- <order-version/>\r
- </request-information>\r
- <service-information>\r
- <service-type>${serviceId}</service-type>\r
- <service-instance-id>${vnfId}</service-instance-id>\r
- <subscriber-name>dontcare</subscriber-name>\r
- </service-information>\r
- <vnf-request-information>\r
- <vnf-id>${vfModuleId}</vnf-id>\r
- <vnf-type>${vfModuleModelName}</vnf-type>\r
- <vnf-name>${vfModuleName}</vnf-name>\r
- <generic-vnf-id>${vnfId}</generic-vnf-id>\r
- <generic-vnf-name>${vnfName}</generic-vnf-name>\r
- <generic-vnf-type>${vnfType}</generic-vnf-type>\r
- <tenant>${tenantId}</tenant>\r
- <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>\r
- ${vnfNetworks}\r
- </vnf-request-information>\r
- </sdncadapterworkflow:SDNCRequestData>\r
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>\r
- """\r
- sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)\r
- execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)\r
- utils.logAudit("sdncChangeAssignRequest : " + sdncTopologyRequest)\r
- logDebug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest, isDebugLogEnabled)\r
-\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())\r
- }\r
- }\r
-\r
- /**\r
- * Prepare a Request for invoking the SDNC Adapter subflow to perform\r
- * a VNF topology 'query' operation.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void prepSDNCTopologyQuery(Execution execution) {\r
- def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- def requestId = execution.getVariable('DOUPVfMod_requestId')\r
- def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')\r
- def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')\r
- def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
-\r
- def svcInstId = ""\r
- if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {\r
- svcInstId = vfModuleId\r
- }\r
- else {\r
- svcInstId = serviceInstanceId\r
- }\r
-\r
- //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE\r
- sleep(5000)\r
-\r
- String sdncTopologyRequest = """\r
- <sdncadapterworkflow:SDNCAdapterWorkflowRequest\r
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"\r
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">\r
- <sdncadapter:RequestHeader>\r
- <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>\r
- <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>\r
- <sdncadapter:SvcAction>query</sdncadapter:SvcAction>\r
- <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>\r
- <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>\r
- <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>\r
- </sdncadapter:RequestHeader>\r
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>\r
- """\r
- sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)\r
- execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)\r
- utils.logAudit("sdncTopologyRequest : " + sdncTopologyRequest)\r
- logDebug('Request for SDNCAdapter query:\n' + sdncTopologyRequest, isDebugLogEnabled)\r
-\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())\r
- }\r
- }\r
-\r
- /**\r
- * Prepare a Request for invoking the VnfAdapterRest subflow.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void prepVnfAdapterRest(Execution execution) {\r
- def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- def requestId = execution.getVariable('DOUPVfMod_requestId')\r
- def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')\r
- def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
- def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
- def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')\r
- def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')\r
- def tenantId = execution.getVariable('DOUPVfMod_tenantId')\r
- def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')\r
- def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')\r
- def heatStackId = vfModule.getElementText('heat-stack-id')\r
- def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')\r
- def vnfType = execution.getVariable('DOUPVfMod_vnfType')\r
- def vnfName = execution.getVariable('DOUPVfMod_vnfName')\r
- def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')\r
- def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")\r
- def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")\r
- def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')\r
- def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')\r
- def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")\r
-\r
- def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')\r
- def vfModuleParamsEntries = transformParamsToEntries(vnfParamsXml)\r
-\r
- def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()\r
- def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)\r
- def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")\r
- if ('true'.equals(useQualifiedHostName)) {\r
- notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)\r
- }\r
-\r
- String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')\r
-\r
- String vfModuleParams = buildVfModuleParams(vfModuleParamsEntries, sdncGetResponse, vnfId, vnfName,\r
- vfModuleId, vfModuleName, null)\r
-\r
-\r
- String vnfAdapterRestRequest = """\r
- <updateVfModuleRequest>\r
- <cloudSiteId>${cloudId}</cloudSiteId>\r
- <tenantId>${tenantId}</tenantId>\r
- <vnfId>${vnfId}</vnfId>\r
- <vfModuleId>${vfModuleId}</vfModuleId>\r
- <vfModuleStackId>${heatStackId}</vfModuleStackId>\r
- <vnfType>${vnfType}</vnfType>\r
- <vnfVersion>${asdcServiceModelVersion}</vnfVersion>\r
- <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>\r
- <vfModuleType>${vfModuleModelName}</vfModuleType>\r
- <volumeGroupId>${volumeGroupId}</volumeGroupId>\r
- <baseVfModuleId>${baseVfModuleId}</baseVfModuleId>\r
- <baseVfModuleStackId>${baseVfModuleStackId}</baseVfModuleStackId>\r
- <skipAAI>true</skipAAI>\r
- <backout>${backoutOnFailure}</backout>\r
- <failIfExists>false</failIfExists>\r
- <vfModuleParams>\r
- ${vfModuleParams}\r
- </vfModuleParams>\r
- <msoRequest>\r
- <requestId>${requestId}</requestId>\r
- <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>\r
- </msoRequest>\r
- <messageId>${messageId}</messageId>\r
- <notificationUrl>${notificationUrl}</notificationUrl>\r
- </updateVfModuleRequest>\r
- """\r
- vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)\r
- execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)\r
- utils.logAudit("vnfAdapterRestRequest : " + vnfAdapterRestRequest)\r
- logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled)\r
-\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())\r
- }\r
- }\r
-\r
- /**\r
- * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void prepUpdateAAIGenericVnf(Execution execution) {\r
- def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
- def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')\r
-\r
- def personaModelId = utils.getNodeText1(vnfInputs, 'vnf-persona-model-id')\r
- def personaModelVersion = utils.getNodeText1(vnfInputs, 'vnf-persona-model-version')\r
- if ((personaModelId == null) || (personaModelVersion == null)) {\r
- logDebug('Skipping update for Generic VNF ' + vnfId +\r
- ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent', isDebugLogEnabled)\r
- execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)\r
- } else {\r
- def personaModelIdElement = '<persona-model-id>' + personaModelId + '</persona-model-id>'\r
- def personaModelVersionElement = '<persona-model-version>' + personaModelVersion + '</persona-model-version>'\r
-\r
- String updateAAIGenericVnfRequest = """\r
- <UpdateAAIGenericVnfRequest>\r
- <vnf-id>${vnfId}</vnf-id>\r
- ${personaModelIdElement}\r
- ${personaModelVersionElement}\r
- </UpdateAAIGenericVnfRequest>\r
- """\r
- updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)\r
- execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)\r
- utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)\r
- logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)\r
- }\r
-\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())\r
- }\r
- }\r
-\r
- /**\r
- * Prepare a Request for invoking the UpdateAAIVfModule subflow.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void prepUpdateAAIVfModule(Execution execution) {\r
- def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
- def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
- def orchestrationStatus = 'updated'\r
- def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')\r
-\r
- def volumeGroupIdElement = ''\r
- def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')\r
- if (volumeGroupId != null) {\r
- volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'\r
- }\r
- def personaModelIdElement = ''\r
- def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id')\r
- if (personaModelId != null) {\r
- personaModelIdElement = '<persona-model-id>' + personaModelId + '</persona-model-id>'\r
- }\r
- def personaModelVersionElement = ''\r
- def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version')\r
- if (personaModelVersion != null) {\r
- personaModelVersionElement = '<persona-model-version>' + personaModelVersion + '</persona-model-version>'\r
- }\r
- def contrailServiceInstanceFqdnElement = ''\r
- def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn')\r
- if (contrailServiceInstanceFqdn != null) {\r
- contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'\r
- }\r
- def personaModelCustomizationIdElement = ''\r
- def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')\r
- if (modelCustomizationId != null) {\r
- personaModelCustomizationIdElement = '<persona-model-customization-id>' + modelCustomizationId + '</persona-model-customization-id>'\r
- }\r
-\r
- String updateAAIVfModuleRequest = """\r
- <UpdateAAIVfModuleRequest>\r
- <vnf-id>${vnfId}</vnf-id>\r
- <vf-module-id>${vfModuleId}</vf-module-id>\r
- <orchestration-status>${orchestrationStatus}</orchestration-status>\r
- ${volumeGroupIdElement}\r
- ${personaModelIdElement}\r
- ${personaModelVersionElement}\r
- ${contrailServiceInstanceFqdnElement}\r
- ${personaModelCustomizationIdElement}\r
- </UpdateAAIVfModuleRequest>\r
- """\r
- updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)\r
- execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)\r
- utils.logAudit("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)\r
- logDebug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest, isDebugLogEnabled)\r
-\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())\r
- }\r
- }\r
-\r
- /**\r
- * Prepare a Request for invoking the SDNC Adapter subflow to perform\r
- * a VNF topology 'activate' operation.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void prepSDNCTopologyAct(Execution execution) {\r
- def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- def requestId = execution.getVariable('DOUPVfMod_requestId')\r
- def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')\r
- def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')\r
- def serviceId = execution.getVariable('DOUPVfMod_serviceId')\r
- def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
- def vnfName = execution.getVariable('DOUPVfMod_vnfName')\r
- def vnfType = execution.getVariable('DOUPVfMod_vnfType')\r
- def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
- def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')\r
- def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')\r
- def vfModuleName = vfModule.getElementText('vf-module-name')\r
- def tenantId = execution.getVariable('DOUPVfMod_tenantId')\r
- def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')\r
-\r
- def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')\r
- def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)\r
-\r
- String sdncTopologyRequest = """\r
- <sdncadapterworkflow:SDNCAdapterWorkflowRequest\r
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"\r
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">\r
- <sdncadapter:RequestHeader>\r
- <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>\r
- <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>\r
- <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>\r
- <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>\r
- <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>\r
- </sdncadapter:RequestHeader>\r
- <sdncadapterworkflow:SDNCRequestData>\r
- <request-information>\r
- <request-id>${requestId}</request-id>\r
- <request-action>ChangeVNFActivateRequest</request-action>\r
- <source>PORTAL</source>\r
- <notification-url/>\r
- <order-number/>\r
- <order-version/>\r
- </request-information>\r
- <service-information>\r
- <service-type>${serviceId}</service-type>\r
- <service-instance-id>${vnfId}</service-instance-id>\r
- <subscriber-name>dontcare</subscriber-name>\r
- </service-information>\r
- <vnf-request-information>\r
- <vnf-id>${vfModuleId}</vnf-id>\r
- <vnf-type>${vfModuleModelName}</vnf-type>\r
- <vnf-name>${vfModuleName}</vnf-name>\r
- <generic-vnf-id>${vnfId}</generic-vnf-id>\r
- <generic-vnf-name>${vnfName}</generic-vnf-name>\r
- <generic-vnf-type>${vnfType}</generic-vnf-type>\r
- <tenant>${tenantId}</tenant>\r
- <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>\r
- </vnf-request-information>\r
- </sdncadapterworkflow:SDNCRequestData>\r
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>\r
- """\r
- sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)\r
- execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)\r
- utils.logAudit("sdncActivateRequest : " + sdncTopologyRequest)\r
- logDebug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest, isDebugLogEnabled)\r
-\r
-\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())\r
- }\r
- }\r
-\r
- /**\r
- * Log a WorkflowException that has been created.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void handleWorkflowException(Execution execution) {\r
- def method = getClass().getSimpleName() + '.handleWorkflowException(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')\r
- logError(method + ' caught WorkflowException: ' + workflowException.getErrorMessage())\r
-\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())\r
- }\r
- }\r
-\r
- public void validateSDNCResponse(Execution execution, String response, String method){\r
- def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")\r
- def prefix = execution.getVariable("prefix")\r
-\r
- logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)\r
-\r
- WorkflowException workflowException = execution.getVariable("WorkflowException")\r
- boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")\r
-\r
- utils.logAudit("workflowException: " + workflowException)\r
-\r
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)\r
- sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)\r
-\r
- utils.logAudit("SDNCResponse: " + response)\r
-\r
- String sdncResponse = response\r
- if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){\r
- logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled)\r
- }else{\r
- logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)\r
- throw new BpmnError("MSOWorkflowException")\r
- }\r
- logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)\r
- }\r
-\r
- /**\r
- * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.\r
- * A 200 response is expected with the VNF info in the response body. Will find out the base module info.\r
- *\r
- * @param execution The flow's execution instance.\r
- */\r
- public void queryAAIVfModule(Execution execution) {\r
- def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")\r
- def method = getClass().getSimpleName() + '.getVfModule(' +\r
- 'execution=' + execution.getId() +\r
- ')'\r
- logDebug('Entered ' + method, isDebugLogEnabled)\r
-\r
- try {\r
- def vnfId = execution.getVariable('DOUPVfMod_vnfId')\r
- def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')\r
-\r
- AaiUtil aaiUriUtil = new AaiUtil(this)\r
- String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)\r
- logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled)\r
-\r
- String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1"\r
- utils.logAudit("AAI endPoint: " + endPoint)\r
-\r
- try {\r
- def aaiRequestId = UUID.randomUUID().toString()\r
- logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled)\r
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)\r
- utils.logAudit("createVfModule - invoking httpGet() to AAI")\r
-\r
- def responseData = response.getResponseBodyAsString()\r
- if (responseData != null) {\r
- logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled)\r
-\r
- }\r
-\r
- utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData)\r
- utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())\r
-\r
- execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode())\r
- execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData)\r
- logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled)\r
- logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled)\r
- if (response.getStatusCode() == 200) {\r
- // Parse the VNF record from A&AI to find base module info\r
- logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled)\r
- if (responseData != null) {\r
- def vfModulesText = utils.getNodeXml(responseData, "vf-modules")\r
- def xmlVfModules= new XmlSlurper().parseText(vfModulesText)\r
- def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}\r
- int vfModulesSize = 0\r
- for (i in 0..vfModules.size()-1) {\r
- def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])\r
- def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")\r
-\r
- if (isBaseVfModule == "true") {\r
- String baseModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id")\r
- execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)\r
- logDebug('Received baseVfModuleId: ' + baseModuleId, isDebugLogEnabled)\r
- String baseModuleHeatStackId = utils.getNodeText1(vfModuleXml, "heat-stack-id")\r
- execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)\r
- logDebug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId, isDebugLogEnabled)\r
- }\r
- }\r
- }\r
- }\r
- } catch (Exception ex) {\r
- ex.printStackTrace()\r
- logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())\r
- }\r
- logDebug('Exited ' + method, isDebugLogEnabled)\r
- } catch (BpmnError e) {\r
- throw e;\r
- } catch (Exception e) {\r
- logError('Caught exception in ' + method, e)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())\r
- }\r
- }\r
-\r
-\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.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_volumeGroupStackId", "")
+ execution.setVariable('DOUPVfMod_vfModule', null)
+ execution.setVariable('DOUPVfMod_vnfParams', null)
+ execution.setVariable("DOUPVfMod_baseVfModuleId", "")
+ execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")
+ execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)
+ execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)
+ execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)
+ execution.setVariable('DOUPVfMod_sdncActivateRequest', null)
+ execution.setVariable('DOUPVfMod_sdncActivateResponse', null)
+ execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)
+ execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)
+ execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)
+ execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)
+ execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)
+ execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)
+ execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)
+ }
+
+ /**
+ * Check for missing elements in the received request.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void preProcessRequest(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 = execution.getVariable("tenantId")
+ execution.setVariable("DOUPVfMod_tenantId", tenantId)
+
+ //volumeGroupId
+ def volumeGroupId = execution.getVariable("volumeGroupId")
+ execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)
+
+ //cloudSiteId
+ def cloudSiteId = execution.getVariable("lcpCloudRegionId")
+ execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId)
+
+ 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, "modelCustomizationUuid")
+ if (modelCustomizationUuid == null) {
+ modelCustomizationUuid = ""
+ }
+ 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("msoRequestId")
+ 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, "modelInvariantUuid"))
+ //personaModelVersion
+ execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
+ //Get or Generate UUID
+ String uuid = execution.getVariable("DOUPVfMod_uuid")
+ if(uuid == null){
+ uuid = UUID.randomUUID()
+ 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")
+ }
+ //usePreload
+ def usePreload = execution.getVariable("usePreload")
+ execution.setVariable("DOUPVfMod_usePreload", usePreload)
+ logDebug("usePreload: " + usePreload, isDebugLogEnabled)
+ //globalSubscriberId
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
+ logDebug("globalSubsrciberId: " + globalSubscriberId, isDebugLogEnabled)
+ //vnfQueryPath
+ String vnfQueryPath = execution.getVariable("vnfQueryPath")
+ execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
+ logDebug("vnfQueryPath: " + vnfQueryPath, isDebugLogEnabled)
+
+ Map<String,String> 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 = """
+ <PrepareUpdateAAIVfModuleRequest>
+ <vnf-id>${vnfId}</vnf-id>
+ <vf-module-id>${vfModuleId}</vf-module-id>
+ <orchestration-status>${orchestrationStatus}</orchestration-status>
+ </PrepareUpdateAAIVfModuleRequest>
+ """
+ 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.
+ * Determine cloud region id for the volume group.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void prepConfirmVolumeGroupTenant(Execution execution) {
+ def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
+ 'execution=' + execution.getId() +
+ ')'
+
+ def prefix = execution.getVariable("prefix")
+ def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
+ logDebug('Entered ' + method, isDebugLogEnabled)
+
+ try {
+ String cloudRegion = execution.getVariable(prefix + "aicCloudRegion")
+
+ // Prepare AA&I url
+ String aai_endpoint = execution.getVariable("URN_aai_endpoint")
+ AaiUtil aaiUtil = new AaiUtil(this)
+ String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
+ String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
+ utils.logAudit("CloudRegion Request: " + queryCloudRegionRequest)
+
+ execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
+ utils.log("DEBUG", prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugLogEnabled)
+
+ cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
+
+ if ((cloudRegion != "ERROR")) {
+ if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){
+ execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25")
+ }else{
+ execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion)
+ }
+ execution.setVariable(prefix + "isCloudRegionGood", true)
+ } else {
+ String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode")
+ utils.log("DEBUG", errorMessage, isDebugLogEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
+ execution.setVariable(prefix + "isCloudRegionGood", false)
+ }
+ utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"), isDebugLogEnabled)
+
+ } catch(BpmnError b){
+ utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugLogEnabled)
+ throw b
+ }catch (Exception e) {
+ // try error
+ String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage()
+ utils.log("ERROR", " AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, isDebugLogEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage())
+ }
+ logDebug('Exited ' + method, isDebugLogEnabled)
+
+ }
+
+ /**
+ * Prepare a Request for invoking the SDNC Adapter subflow to perform
+ * a VNF topology 'changeassign' operation.
+ *
+ * @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')
+ String uuid = execution.getVariable('testReqId') // for junits
+ if(uuid==null){
+ uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
+ }
+ def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
+ def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
+ def serviceId = execution.getVariable('DOUPVfMod_serviceId')
+ def vnfId = execution.getVariable('DOUPVfMod_vnfId')
+ def vnfType = execution.getVariable('DOUPVfMod_vnfType')
+ def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
+ def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
+ def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
+ def vfModuleName = vfModule.getElementText('vf-module-name')
+ def tenantId = execution.getVariable('DOUPVfMod_tenantId')
+ def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
+ boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
+ String usePreloadToSDNC = usePreload ? "Y" : "N"
+ def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
+ def modelCustomizationUuidString = ""
+ if (!usePreload) {
+ modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
+ }
+
+ // Retrieve vnf name from AAI response
+ def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
+ execution.setVariable('DOUPVfMod_vnfName', vnfName)
+
+ def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
+ def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
+
+ String sdncTopologyRequest = """
+ <sdncadapterworkflow:SDNCAdapterWorkflowRequest
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${requestId}</request-id>
+ <request-action>ChangeVNFActivateRequest</request-action>
+ <source>PORTAL</source>
+ <notification-url/>
+ <order-number/>
+ <order-version/>
+ </request-information>
+ <service-information>
+ <service-type>${serviceId}</service-type>
+ <service-instance-id>${vnfId}</service-instance-id>
+ <subscriber-name>dontcare</subscriber-name>
+ </service-information>
+ <vnf-request-information>
+ <vnf-id>${vfModuleId}</vnf-id>
+ <vnf-type>${vfModuleModelName}</vnf-type>
+ <vnf-name>${vfModuleName}</vnf-name>
+ <generic-vnf-id>${vnfId}</generic-vnf-id>
+ <generic-vnf-name>${vnfName}</generic-vnf-name>
+ <generic-vnf-type>${vnfType}</generic-vnf-type>
+ <tenant>${tenantId}</tenant>
+ <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
+ ${modelCustomizationUuidString}
+ <use-preload>${usePreloadToSDNC}</use-preload>
+ ${vnfNetworks}
+ </vnf-request-information>
+ </sdncadapterworkflow:SDNCRequestData>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
+ """
+ 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 {
+ String uuid = execution.getVariable('testReqId') // for junits
+ if(uuid==null){
+ uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
+ }
+ def requestId = execution.getVariable('DOUPVfMod_requestId')
+ def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
+ def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
+ 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 = """
+ <sdncadapterworkflow:SDNCAdapterWorkflowRequest
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
+ """
+ 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 volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
+ def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
+ def heatStackId = vfModule.getElementText('heat-stack-id')
+ def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
+ def vnfType = execution.getVariable('DOUPVfMod_vnfType')
+ def vnfName = execution.getVariable('DOUPVfMod_vnfName')
+ def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
+ def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
+ def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
+ def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
+ def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
+ def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
+
+ def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
+ def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
+ def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
+ if ('true'.equals(useQualifiedHostName)) {
+ notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
+ }
+
+ Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
+
+ String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
+
+ String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
+ vfModuleId, vfModuleName, null)
+
+
+ String vnfAdapterRestRequest = """
+ <updateVfModuleRequest>
+ <cloudSiteId>${cloudId}</cloudSiteId>
+ <tenantId>${tenantId}</tenantId>
+ <vnfId>${vnfId}</vnfId>
+ <vfModuleId>${vfModuleId}</vfModuleId>
+ <vfModuleStackId>${heatStackId}</vfModuleStackId>
+ <vnfType>${vnfType}</vnfType>
+ <vnfVersion>${asdcServiceModelVersion}</vnfVersion>
+ <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>
+ <vfModuleType>${vfModuleModelName}</vfModuleType>
+ <volumeGroupId>${volumeGroupId}</volumeGroupId>
+ <volumeGroupStackId>${volumeGroupStackId}</volumeGroupStackId>
+ <baseVfModuleId>${baseVfModuleId}</baseVfModuleId>
+ <baseVfModuleStackId>${baseVfModuleStackId}</baseVfModuleStackId>
+ <skipAAI>true</skipAAI>
+ <backout>${backoutOnFailure}</backout>
+ <failIfExists>false</failIfExists>
+ <vfModuleParams>
+ ${vfModuleParams}
+ </vfModuleParams>
+ <msoRequest>
+ <requestId>${requestId}</requestId>
+ <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
+ </msoRequest>
+ <messageId>${messageId}</messageId>
+ <notificationUrl>${notificationUrl}</notificationUrl>
+ </updateVfModuleRequest>
+ """
+ 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 = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
+ def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
+
+ String updateAAIGenericVnfRequest = """
+ <UpdateAAIGenericVnfRequest>
+ <vnf-id>${vnfId}</vnf-id>
+ ${personaModelIdElement}
+ ${personaModelVersionElement}
+ </UpdateAAIGenericVnfRequest>
+ """
+ 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 = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
+ }
+ def personaModelIdElement = ''
+ def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id')
+ if (personaModelId != null) {
+ personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
+ }
+ def personaModelVersionElement = ''
+ def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version')
+ if (personaModelVersion != null) {
+ personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
+ }
+ def contrailServiceInstanceFqdnElement = ''
+ def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn')
+ if (contrailServiceInstanceFqdn != null) {
+ contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
+ }
+ def personaModelCustomizationIdElement = ''
+ def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
+ if (modelCustomizationId != null) {
+ personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
+ }
+
+ String updateAAIVfModuleRequest = """
+ <UpdateAAIVfModuleRequest>
+ <vnf-id>${vnfId}</vnf-id>
+ <vf-module-id>${vfModuleId}</vf-module-id>
+ <orchestration-status>${orchestrationStatus}</orchestration-status>
+ ${volumeGroupIdElement}
+ ${personaModelIdElement}
+ ${personaModelVersionElement}
+ ${contrailServiceInstanceFqdnElement}
+ ${personaModelCustomizationIdElement}
+ </UpdateAAIVfModuleRequest>
+ """
+
+ 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 {
+ String uuid = execution.getVariable('testReqId') // for junits
+ if(uuid==null){
+ uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
+ }
+ def requestId = execution.getVariable('DOUPVfMod_requestId')
+ def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
+ def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
+ def serviceId = execution.getVariable('DOUPVfMod_serviceId')
+ def vnfId = execution.getVariable('DOUPVfMod_vnfId')
+ def vnfName = execution.getVariable('DOUPVfMod_vnfName')
+ def vnfType = execution.getVariable('DOUPVfMod_vnfType')
+ def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
+ def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
+ def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
+ def vfModuleName = vfModule.getElementText('vf-module-name')
+ def tenantId = execution.getVariable('DOUPVfMod_tenantId')
+ def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
+
+ boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
+ String usePreloadToSDNC = usePreload ? "Y" : "N"
+ def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
+ def modelCustomizationUuidString = ""
+ if (!usePreload) {
+ modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
+ }
+
+ def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
+ def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
+
+ String sdncTopologyRequest = """
+ <sdncadapterworkflow:SDNCAdapterWorkflowRequest
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${requestId}</request-id>
+ <request-action>ChangeVNFActivateRequest</request-action>
+ <source>PORTAL</source>
+ <notification-url/>
+ <order-number/>
+ <order-version/>
+ </request-information>
+ <service-information>
+ <service-type>${serviceId}</service-type>
+ <service-instance-id>${vnfId}</service-instance-id>
+ <subscriber-name>dontcare</subscriber-name>
+ </service-information>
+ <vnf-request-information>
+ <vnf-id>${vfModuleId}</vnf-id>
+ <vnf-type>${vfModuleModelName}</vnf-type>
+ <vnf-name>${vfModuleName}</vnf-name>
+ <generic-vnf-id>${vnfId}</generic-vnf-id>
+ <generic-vnf-name>${vnfName}</generic-vnf-name>
+ <generic-vnf-type>${vnfType}</generic-vnf-type>
+ <tenant>${tenantId}</tenant>
+ <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
+ ${modelCustomizationUuidString}
+ <use-preload>${usePreloadToSDNC}</use-preload>
+ </vnf-request-information>
+ </sdncadapterworkflow:SDNCRequestData>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
+ """
+ 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())
+ }
+ }
+
+
+}