diff options
author | Steve Smokowski <ss835w@att.com> | 2020-03-30 12:43:56 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-03-30 12:43:56 +0000 |
commit | df5f83eef26b23a5381e134ff50f89b340376596 (patch) | |
tree | 21473521be2aa0c8e7860772b091c7fb148402d6 /bpmn/so-bpmn-infrastructure-common | |
parent | 8d23a63762dcd0d435463fa25c64f146d52dc981 (diff) | |
parent | cd4e5b408603a13dabc58f832e4aae4194e81995 (diff) |
Merge "convert openstack to external tasks"
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common')
3 files changed, 1339 insertions, 1344 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy index a77f6f0628..a505aa1a34 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -50,164 +50,164 @@ import javax.ws.rs.NotFoundException public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger( DoCreateVfModuleRollback.class); - def Prefix="DCVFMR_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - } - - // parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids - // and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest - public void preProcessRequest(DelegateExecution execution) { - - - initProcessVariables(execution) - - try { - - execution.setVariable("rolledBack", null) - execution.setVariable("rollbackError", null) - - def rollbackData = execution.getVariable("rollbackData") - logger.debug("RollbackData:" + rollbackData) - - if (rollbackData != null) { - String vnfId = rollbackData.get("VFMODULE", "vnfid") - execution.setVariable("DCVFMR_vnfId", vnfId) - String vfModuleId = rollbackData.get("VFMODULE", "vfmoduleid") - execution.setVariable("DCVFMR_vfModuleId", vfModuleId) - String source = rollbackData.get("VFMODULE", "source") - execution.setVariable("DCVFMR_source", source) - String serviceInstanceId = rollbackData.get("VFMODULE", "serviceInstanceId") - execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) - String serviceId = rollbackData.get("VFMODULE", "service-id") - execution.setVariable("DCVFMR_serviceId", serviceId) - String vnfType = rollbackData.get("VFMODULE", "vnftype") - execution.setVariable("DCVFMR_vnfType", vnfType) - String vnfName = rollbackData.get("VFMODULE", "vnfname") - execution.setVariable("DCVFMR_vnfName", vnfName) - String tenantId = rollbackData.get("VFMODULE", "tenantid") - execution.setVariable("DCVFMR_tenantId", tenantId) - String vfModuleName = rollbackData.get("VFMODULE", "vfmodulename") - execution.setVariable("DCVFMR_vfModuleName", vfModuleName) - String vfModuleModelName = rollbackData.get("VFMODULE", "vfmodulemodelname") - execution.setVariable("DCVFMR_vfModuleModelName", vfModuleModelName) - String cloudSiteId = rollbackData.get("VFMODULE", "aiccloudregion") - execution.setVariable("DCVFMR_cloudSiteId", cloudSiteId) - String cloudOwner = rollbackData.get("VFMODULE", "cloudowner") - execution.setVariable("DCVFMR_cloudOwner", cloudOwner) - String heatStackId = rollbackData.get("VFMODULE", "heatstackid") - execution.setVariable("DCVFMR_heatStackId", heatStackId) - String requestId = rollbackData.get("VFMODULE", "msorequestid") - execution.setVariable("DCVFMR_requestId", requestId) - // Set mso-request-id to request-id for VNF Adapter interface - execution.setVariable("mso-request-id", requestId) - List createdNetworkPolicyFqdnList = [] - int i = 0 - while (i < 100) { - String fqdn = rollbackData.get("VFMODULE", "contrailNetworkPolicyFqdn" + i) - if (fqdn == null) { - break - } - createdNetworkPolicyFqdnList.add(fqdn) - logger.debug("got fqdn # " + i + ": " + fqdn) - i = i + 1 - - } - - execution.setVariable("DCVFMR_createdNetworkPolicyFqdnList", createdNetworkPolicyFqdnList) - String oamManagementV4Address = rollbackData.get("VFMODULE", "oamManagementV4Address") - execution.setVariable("DCVFMR_oamManagementV4Address", oamManagementV4Address) - String oamManagementV6Address = rollbackData.get("VFMODULE", "oamManagementV6Address") - execution.setVariable("DCVFMR_oamManagementV6Address", oamManagementV6Address) - //String serviceInstanceId = rollbackData.get("VFMODULE", "msoserviceinstanceid") - //execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) - execution.setVariable("DCVFMR_rollbackPrepareUpdateVfModule", rollbackData.get("VFMODULE", "rollbackPrepareUpdateVfModule")) - execution.setVariable("DCVFMR_rollbackUpdateAAIVfModule", rollbackData.get("VFMODULE", "rollbackUpdateAAIVfModule")) - execution.setVariable("DCVFMR_rollbackVnfAdapterCreate", rollbackData.get("VFMODULE", "rollbackVnfAdapterCreate")) - execution.setVariable("DCVFMR_rollbackSDNCRequestAssign", rollbackData.get("VFMODULE", "rollbackSDNCRequestAssign")) - execution.setVariable("DCVFMR_rollbackSDNCRequestActivate", rollbackData.get("VFMODULE", "rollbackSDNCRequestActivate")) - execution.setVariable("DCVFMR_rollbackCreateAAIVfModule", rollbackData.get("VFMODULE", "rollbackCreateAAIVfModule")) - execution.setVariable("DCVFMR_rollbackCreateNetworkPoliciesAAI", rollbackData.get("VFMODULE", "rollbackCreateNetworkPoliciesAAI")) - execution.setVariable("DCVFMR_rollbackUpdateVnfAAI", rollbackData.get("VFMODULE", "rollbackUpdateVnfAAI")) - - // formulate the request for PrepareUpdateAAIVfModule - String request = """<PrepareUpdateAAIVfModuleRequest> + def Prefix="DCVFMR_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + } + + // parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids + // and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest + public void preProcessRequest(DelegateExecution execution) { + + + initProcessVariables(execution) + + try { + + execution.setVariable("rolledBack", null) + execution.setVariable("rollbackError", null) + + def rollbackData = execution.getVariable("rollbackData") + logger.debug("RollbackData:" + rollbackData) + + if (rollbackData != null) { + String vnfId = rollbackData.get("VFMODULE", "vnfid") + execution.setVariable("DCVFMR_vnfId", vnfId) + String vfModuleId = rollbackData.get("VFMODULE", "vfmoduleid") + execution.setVariable("DCVFMR_vfModuleId", vfModuleId) + String source = rollbackData.get("VFMODULE", "source") + execution.setVariable("DCVFMR_source", source) + String serviceInstanceId = rollbackData.get("VFMODULE", "serviceInstanceId") + execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) + String serviceId = rollbackData.get("VFMODULE", "service-id") + execution.setVariable("DCVFMR_serviceId", serviceId) + String vnfType = rollbackData.get("VFMODULE", "vnftype") + execution.setVariable("DCVFMR_vnfType", vnfType) + String vnfName = rollbackData.get("VFMODULE", "vnfname") + execution.setVariable("DCVFMR_vnfName", vnfName) + String tenantId = rollbackData.get("VFMODULE", "tenantid") + execution.setVariable("DCVFMR_tenantId", tenantId) + String vfModuleName = rollbackData.get("VFMODULE", "vfmodulename") + execution.setVariable("DCVFMR_vfModuleName", vfModuleName) + String vfModuleModelName = rollbackData.get("VFMODULE", "vfmodulemodelname") + execution.setVariable("DCVFMR_vfModuleModelName", vfModuleModelName) + String cloudSiteId = rollbackData.get("VFMODULE", "aiccloudregion") + execution.setVariable("DCVFMR_cloudSiteId", cloudSiteId) + String cloudOwner = rollbackData.get("VFMODULE", "cloudowner") + execution.setVariable("DCVFMR_cloudOwner", cloudOwner) + String heatStackId = rollbackData.get("VFMODULE", "heatstackid") + execution.setVariable("DCVFMR_heatStackId", heatStackId) + String requestId = rollbackData.get("VFMODULE", "msorequestid") + execution.setVariable("DCVFMR_requestId", requestId) + // Set mso-request-id to request-id for VNF Adapter interface + execution.setVariable("mso-request-id", requestId) + List createdNetworkPolicyFqdnList = [] + int i = 0 + while (i < 100) { + String fqdn = rollbackData.get("VFMODULE", "contrailNetworkPolicyFqdn" + i) + if (fqdn == null) { + break + } + createdNetworkPolicyFqdnList.add(fqdn) + logger.debug("got fqdn # " + i + ": " + fqdn) + i = i + 1 + + } + + execution.setVariable("DCVFMR_createdNetworkPolicyFqdnList", createdNetworkPolicyFqdnList) + String oamManagementV4Address = rollbackData.get("VFMODULE", "oamManagementV4Address") + execution.setVariable("DCVFMR_oamManagementV4Address", oamManagementV4Address) + String oamManagementV6Address = rollbackData.get("VFMODULE", "oamManagementV6Address") + execution.setVariable("DCVFMR_oamManagementV6Address", oamManagementV6Address) + //String serviceInstanceId = rollbackData.get("VFMODULE", "msoserviceinstanceid") + //execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) + execution.setVariable("DCVFMR_rollbackPrepareUpdateVfModule", rollbackData.get("VFMODULE", "rollbackPrepareUpdateVfModule")) + execution.setVariable("DCVFMR_rollbackUpdateAAIVfModule", rollbackData.get("VFMODULE", "rollbackUpdateAAIVfModule")) + execution.setVariable("DCVFMR_rollbackVnfAdapterCreate", rollbackData.get("VFMODULE", "rollbackVnfAdapterCreate")) + execution.setVariable("DCVFMR_rollbackSDNCRequestAssign", rollbackData.get("VFMODULE", "rollbackSDNCRequestAssign")) + execution.setVariable("DCVFMR_rollbackSDNCRequestActivate", rollbackData.get("VFMODULE", "rollbackSDNCRequestActivate")) + execution.setVariable("DCVFMR_rollbackCreateAAIVfModule", rollbackData.get("VFMODULE", "rollbackCreateAAIVfModule")) + execution.setVariable("DCVFMR_rollbackCreateNetworkPoliciesAAI", rollbackData.get("VFMODULE", "rollbackCreateNetworkPoliciesAAI")) + execution.setVariable("DCVFMR_rollbackUpdateVnfAAI", rollbackData.get("VFMODULE", "rollbackUpdateVnfAAI")) + + // formulate the request for PrepareUpdateAAIVfModule + String request = """<PrepareUpdateAAIVfModuleRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> <orchestration-status>pending-delete</orchestration-status> </PrepareUpdateAAIVfModuleRequest>""" as String - logger.debug("PrepareUpdateAAIVfModuleRequest :" + request) - execution.setVariable("PrepareUpdateAAIVfModuleRequest", request) - } else { - execution.setVariable("skipRollback", true) - } - - if (execution.getVariable("disableRollback").equals("true" )) { - execution.setVariable("skipRollback", true) - } - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - def msg = "Exception in DoCreateVfModuleRollback preProcessRequest " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } - - // build a SDNC vnf-topology-operation request for the specified action - // (note: the action passed is expected to be 'changedelete' or 'delete') - public void prepSDNCAdapterRequest(DelegateExecution execution) { - - String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId") - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis() - } - - def callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - - String source = execution.getVariable("DCVFMR_source") - String serviceId = execution.getVariable("DCVFMR_serviceId") - String vnfId = execution.getVariable("DCVFMR_vnfId") - String vnfType = execution.getVariable("DCVFMR_vnfType") - String vnfName = execution.getVariable("DCVFMR_vnfName") - String tenantId = execution.getVariable("DCVFMR_tenantId") - String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - String vfModuleName = execution.getVariable("DCVFMR_vfModuleName") - String vfModuleModelName = execution.getVariable("DCVFMR_vfModuleModelName") - String cloudSiteId = execution.getVariable("DCVFMR_cloudSiteId") - String requestId = execution.getVariable("DCVFMR_requestId") - - String serviceInstanceIdToSdnc = "" - if (srvInstId != null && !srvInstId.isEmpty()) { - serviceInstanceIdToSdnc = srvInstId - } else { - serviceInstanceIdToSdnc = vfModuleId - } - - def doSDNCActivateRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestActivate") - def doSDNCAssignRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestAssign") - - def action = "" - def requestAction = "" - - if (doSDNCActivateRollback.equals("true")) { - action = "delete" - requestAction = "DisconnectVNFRequest" - } - else if (doSDNCAssignRollback.equals("true")) { - action = "rollback" - requestAction = "VNFActivateRequest" - } - else - return - - - String request = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" + logger.debug("PrepareUpdateAAIVfModuleRequest :" + request) + execution.setVariable("PrepareUpdateAAIVfModuleRequest", request) + } else { + execution.setVariable("skipRollback", true) + } + + if (execution.getVariable("disableRollback").equals("true" )) { + execution.setVariable("skipRollback", true) + } + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + def msg = "Exception in DoCreateVfModuleRollback preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + // build a SDNC vnf-topology-operation request for the specified action + // (note: the action passed is expected to be 'changedelete' or 'delete') + public void prepSDNCAdapterRequest(DelegateExecution execution) { + + String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId") + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis() + } + + def callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + + String source = execution.getVariable("DCVFMR_source") + String serviceId = execution.getVariable("DCVFMR_serviceId") + String vnfId = execution.getVariable("DCVFMR_vnfId") + String vnfType = execution.getVariable("DCVFMR_vnfType") + String vnfName = execution.getVariable("DCVFMR_vnfName") + String tenantId = execution.getVariable("DCVFMR_tenantId") + String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + String vfModuleName = execution.getVariable("DCVFMR_vfModuleName") + String vfModuleModelName = execution.getVariable("DCVFMR_vfModuleModelName") + String cloudSiteId = execution.getVariable("DCVFMR_cloudSiteId") + String requestId = execution.getVariable("DCVFMR_requestId") + + String serviceInstanceIdToSdnc = "" + if (srvInstId != null && !srvInstId.isEmpty()) { + serviceInstanceIdToSdnc = srvInstId + } else { + serviceInstanceIdToSdnc = vfModuleId + } + + def doSDNCActivateRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestActivate") + def doSDNCAssignRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestAssign") + + def action = "" + def requestAction = "" + + if (doSDNCActivateRollback.equals("true")) { + action = "delete" + requestAction = "DisconnectVNFRequest" + } + else if (doSDNCAssignRollback.equals("true")) { + action = "rollback" + requestAction = "VNFActivateRequest" + } + else + return + + + String request = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1"> <sdncadapter:RequestHeader> @@ -245,76 +245,76 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ </sdncadapterworkflow:SDNCRequestData> </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - logger.debug("sdncAdapterWorkflowRequest: " + request) - execution.setVariable("sdncAdapterWorkflowRequest", request) - } - - public void preProcessSDNCDeactivateRequest(DelegateExecution execution){ - - execution.setVariable("prefix", Prefix) - logger.trace("STARTED preProcessSDNCDeactivateRequest") - - def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") - - try{ - //Build SDNC Request - - String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") - - deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) - execution.setVariable("DCVFMR_deactivateSDNCRequest", deactivateSDNCRequest) - logger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) - - }catch(Exception e){ - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "Exception Occured Processing preProcessSDNCDeactivateRequest.", "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) - } - logger.trace("COMPLETED preProcessSDNCDeactivateRequest") - } - - public void preProcessSDNCUnassignRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logger.trace('Entered ' + method) - execution.setVariable("prefix", Prefix) - logger.trace("STARTED preProcessSDNCUnassignRequest Process") - try{ - String serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") - - String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") - - execution.setVariable("DCVFMR_unassignSDNCRequest", unassignSDNCRequest) - logger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) - - }catch(Exception e){ - logger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) - } - logger.trace("COMPLETED preProcessSDNCUnassignRequest Process") - } - - public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis() - } - def callbackURL = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - def requestId = execution.getVariable("DCVFMR_requestId") - def serviceId = execution.getVariable("DCVFMR_serviceId") - def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") - def vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - def source = execution.getVariable("DCVFMR_source") - def vnfId = execution.getVariable("DCVFMR_vnfId") - - def sdncVersion = execution.getVariable("sdncVersion") - - String sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" + logger.debug("sdncAdapterWorkflowRequest: " + request) + execution.setVariable("sdncAdapterWorkflowRequest", request) + } + + public void preProcessSDNCDeactivateRequest(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + logger.trace("STARTED preProcessSDNCDeactivateRequest") + + def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") + + try{ + //Build SDNC Request + + String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") + + deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) + execution.setVariable("DCVFMR_deactivateSDNCRequest", deactivateSDNCRequest) + logger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + + }catch(Exception e){ + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "Exception Occured Processing preProcessSDNCDeactivateRequest.", "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preProcessSDNCDeactivateRequest") + } + + public void preProcessSDNCUnassignRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + logger.trace("STARTED preProcessSDNCUnassignRequest Process") + try{ + String serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") + + String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") + + execution.setVariable("DCVFMR_unassignSDNCRequest", unassignSDNCRequest) + logger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + + }catch(Exception e){ + logger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preProcessSDNCUnassignRequest Process") + } + + public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis() + } + def callbackURL = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + def requestId = execution.getVariable("DCVFMR_requestId") + def serviceId = execution.getVariable("DCVFMR_serviceId") + def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") + def vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + def source = execution.getVariable("DCVFMR_source") + def vnfId = execution.getVariable("DCVFMR_vnfId") + + def sdncVersion = execution.getVariable("sdncVersion") + + String sdncRequest = + """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"> <sdncadapter:RequestHeader> @@ -351,32 +351,32 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ </sdncadapterworkflow:SDNCRequestData> </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - logger.debug("sdncRequest: " + sdncRequest) - return sdncRequest - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing VnfAdapterDeleteV1 request - public void prepVNFAdapterRequest(DelegateExecution execution) { - - String requestId = UUID.randomUUID().toString() - String origRequestId = execution.getVariable("DCVFMR_requestId") - String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId") - String aicCloudRegion = execution.getVariable("DCVFMR_cloudSiteId") - String cloudOwner = execution.getVariable("DCVFMR_cloudOwner") - String vnfId = execution.getVariable("DCVFMR_vnfId") - String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - String vfModuleStackId = execution.getVariable("DCVFMR_heatStackId") - String tenantId = execution.getVariable("DCVFMR_tenantId") - def messageId = execution.getVariable('mso-request-id') + '-' + - System.currentTimeMillis() - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) - def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) - if ('true'.equals(useQualifiedHostName)) { - notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) - } - - String request = """ + logger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing VnfAdapterDeleteV1 request + public void prepVNFAdapterRequest(DelegateExecution execution) { + + String requestId = UUID.randomUUID().toString() + String origRequestId = execution.getVariable("DCVFMR_requestId") + String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId") + String aicCloudRegion = execution.getVariable("DCVFMR_cloudSiteId") + String cloudOwner = execution.getVariable("DCVFMR_cloudOwner") + String vnfId = execution.getVariable("DCVFMR_vnfId") + String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + String vfModuleStackId = execution.getVariable("DCVFMR_heatStackId") + String tenantId = execution.getVariable("DCVFMR_tenantId") + def messageId = execution.getVariable('mso-request-id') + '-' + + System.currentTimeMillis() + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String request = """ <deleteVfModuleRequest> <cloudSiteId>${MsoUtils.xmlEscape(aicCloudRegion)}</cloudSiteId> <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> @@ -394,117 +394,116 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ </deleteVfModuleRequest> """ as String - logger.debug("vnfAdapterRestV1Request: " + request) - execution.setVariable("vnfAdapterRestV1Request", request) - } + execution.setVariable("vnfAdapterTaskRequest", request) + } - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing UpdateAAIVfModuleRequest request - public void prepUpdateAAIVfModule(DelegateExecution execution) { + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing UpdateAAIVfModuleRequest request + public void prepUpdateAAIVfModule(DelegateExecution execution) { - String vnfId = execution.getVariable("DCVFMR_vnfId") - String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<UpdateAAIVfModuleRequest> + String vnfId = execution.getVariable("DCVFMR_vnfId") + String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """<UpdateAAIVfModuleRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> <heat-stack-id>DELETE</heat-stack-id> <orchestration-status>deleted</orchestration-status> </UpdateAAIVfModuleRequest>""" as String - logger.debug("UpdateAAIVfModuleRequest :" + request) - execution.setVariable("UpdateAAIVfModuleRequest", request) - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing UpdateAAIVfModuleRequest request - public void prepUpdateAAIVfModuleToAssigned(DelegateExecution execution) { - - String vnfId = execution.getVariable("DCVFMR_vnfId") - String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<UpdateAAIVfModuleRequest> + logger.debug("UpdateAAIVfModuleRequest :" + request) + execution.setVariable("UpdateAAIVfModuleRequest", request) + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing UpdateAAIVfModuleRequest request + public void prepUpdateAAIVfModuleToAssigned(DelegateExecution execution) { + + String vnfId = execution.getVariable("DCVFMR_vnfId") + String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """<UpdateAAIVfModuleRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> <heat-stack-id></heat-stack-id> <orchestration-status>Assigned</orchestration-status> </UpdateAAIVfModuleRequest>""" as String - logger.debug("UpdateAAIVfModuleRequest :" + request) - execution.setVariable("UpdateAAIVfModuleRequest", request) - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing DeleteAAIVfModuleRequest request - public void prepDeleteAAIVfModule(DelegateExecution execution) { - - String vnfId = execution.getVariable("DCVFMR_vnfId") - String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<DeleteAAIVfModuleRequest> + logger.debug("UpdateAAIVfModuleRequest :" + request) + execution.setVariable("UpdateAAIVfModuleRequest", request) + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing DeleteAAIVfModuleRequest request + public void prepDeleteAAIVfModule(DelegateExecution execution) { + + String vnfId = execution.getVariable("DCVFMR_vnfId") + String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """<DeleteAAIVfModuleRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> </DeleteAAIVfModuleRequest>""" as String - logger.debug("DeleteAAIVfModuleRequest :" + request) - execution.setVariable("DeleteAAIVfModuleRequest", request) - } + logger.debug("DeleteAAIVfModuleRequest :" + request) + execution.setVariable("DeleteAAIVfModuleRequest", request) + } - // generates a WorkflowException if - // - - public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { + // generates a WorkflowException if + // - + public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "AAI error occurred deleting the Generic Vnf" + execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), - "BPMN", ErrorCode.UnknownError.getValue()); - String processKey = getProcessKey(execution); - exceptionUtil.buildWorkflowException(execution, 5000, "Failure in DoDeleteVfModule") + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "AAI error occurred deleting the Generic Vnf" + execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), + "BPMN", ErrorCode.UnknownError.getValue()); + String processKey = getProcessKey(execution); + exceptionUtil.buildWorkflowException(execution, 5000, "Failure in DoDeleteVfModule") - } + } - public void sdncValidateResponse(DelegateExecution execution, String response){ + public void sdncValidateResponse(DelegateExecution execution, String response){ - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",Prefix) - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - logger.debug("Successfully Validated SDNC Response") - }else{ - throw new BpmnError("MSOWorkflowException") - } - } + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + logger.debug("Successfully Validated SDNC Response") + }else{ + throw new BpmnError("MSOWorkflowException") + } + } - public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logger.trace('Entered ' + method) - execution.setVariable("prefix", Prefix) - logger.trace("STARTED deleteNetworkPoliciesFromAAI") + public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + logger.trace("STARTED deleteNetworkPoliciesFromAAI") - try { - // get variables - List fqdnList = execution.getVariable(Prefix + "createdNetworkPolicyFqdnList") - if (fqdnList == null) { - logger.debug("No network policies to delete") - return - } - int fqdnCount = fqdnList.size() + try { + // get variables + List fqdnList = execution.getVariable(Prefix + "createdNetworkPolicyFqdnList") + if (fqdnList == null) { + logger.debug("No network policies to delete") + return + } + int fqdnCount = fqdnList.size() - execution.setVariable(Prefix + "networkPolicyFqdnCount", fqdnCount) - logger.debug("networkPolicyFqdnCount - " + fqdnCount) + execution.setVariable(Prefix + "networkPolicyFqdnCount", fqdnCount) + logger.debug("networkPolicyFqdnCount - " + fqdnCount) - AaiUtil aaiUriUtil = new AaiUtil(this) + AaiUtil aaiUriUtil = new AaiUtil(this) - if (fqdnCount > 0) { - // AII loop call over contrail network policy fqdn list - for (i in 0..fqdnCount-1) { + if (fqdnCount > 0) { + // AII loop call over contrail network policy fqdn list + for (i in 0..fqdnCount-1) { - int counting = i+1 - String fqdn = fqdnList[i] + int counting = i+1 + String fqdn = fqdnList[i] try { // Query AAI for this network policy FQDN @@ -517,10 +516,10 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ NetworkPolicy networkPolicy = networkPolicies.get().getNetworkPolicy().get(0) try{ - AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId()) - getAAIClient().delete(delUri) - execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", 200) - logger.debug("AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + 200) + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId()) + getAAIClient().delete(delUri) + execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", 200) + logger.debug("AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + 200) logger.debug("The return code from deleting network policy is: " + 200) // This network policy was deleted from AAI successfully logger.debug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ") @@ -548,113 +547,113 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ logger.debug(dataErrorMessage) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) } - } // end loop + } // end loop - } else { - logger.debug("No contrail network policies to query/create") + } else { + logger.debug("No contrail network policies to query/create") - } + } - } catch (BpmnError e) { - throw e; + } catch (BpmnError e) { + throw e; - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateVfModuleRollback flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoCreateVfModuleRollback flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } - } + } - /** - * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. - * - * @param execution The flow's execution instance. - */ - public void preProcessUpdateAAIGenericVnf(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessUpdateAAIGenericVnf((' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logger.trace('Entered ' + method) + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void preProcessUpdateAAIGenericVnf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessUpdateAAIGenericVnf((' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) - try { - def vnfId = execution.getVariable('DCVFMR_vnfId') - def oamManagementV4Address = execution.getVariable(Prefix + 'oamManagementV4Address') - def oamManagementV6Address = execution.getVariable(Prefix + 'oamManagementV6Address') - def ipv4OamAddressElement = '' - def managementV6AddressElement = '' + try { + def vnfId = execution.getVariable('DCVFMR_vnfId') + def oamManagementV4Address = execution.getVariable(Prefix + 'oamManagementV4Address') + def oamManagementV6Address = execution.getVariable(Prefix + 'oamManagementV6Address') + def ipv4OamAddressElement = '' + def managementV6AddressElement = '' - if (oamManagementV4Address != null) { - ipv4OamAddressElement = '<ipv4-oam-address>' + 'DELETE' + '</ipv4-oam-address>' - } + if (oamManagementV4Address != null) { + ipv4OamAddressElement = '<ipv4-oam-address>' + 'DELETE' + '</ipv4-oam-address>' + } - if (oamManagementV6Address != null) { - managementV6AddressElement = '<management-v6-address>' + 'DELETE' + '</management-v6-address>' - } + if (oamManagementV6Address != null) { + managementV6AddressElement = '<management-v6-address>' + 'DELETE' + '</management-v6-address>' + } - String updateAAIGenericVnfRequest = """ + String updateAAIGenericVnfRequest = """ <UpdateAAIGenericVnfRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> ${ipv4OamAddressElement} ${managementV6AddressElement} </UpdateAAIGenericVnfRequest> """ - updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) - execution.setVariable(Prefix + 'updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) - logger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest) - - - logger.trace('Exited ' + method) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - 'Caught exception in ' + method, "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessUpdateAAIGenericVnf((): ' + e.getMessage()) - } - } - - public void setSuccessfulRollbackStatus (DelegateExecution execution){ - - execution.setVariable("prefix", Prefix) - logger.trace("STARTED setSuccessfulRollbackStatus") - - try{ - // Set rolledBack to true, rollbackError to null - execution.setVariable("rolledBack", true) - execution.setVariable("rollbackError", null) - - }catch(Exception e){ - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "Exception Occured Processing setSuccessfulRollbackStatus.", "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage()) - } - logger.trace("COMPLETED setSuccessfulRollbackStatus") - } - - public void setFailedRollbackStatus (DelegateExecution execution){ - - execution.setVariable("prefix", Prefix) - logger.trace("STARTED setFailedRollbackStatus") - - try{ - // Set rolledBack to false, rollbackError to actual value, rollbackData to null - execution.setVariable("rolledBack", false) - execution.setVariable("rollbackError", 'Caught exception in DoCreateVfModuleRollback') - execution.setVariable("rollbackData", null) - - }catch(Exception e){ - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "Exception Occured Processing setFailedRollbackStatus.", "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage()) - } - logger.trace("COMPLETED setFailedRollbackStatus") - } + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable(Prefix + 'updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + logger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest) + + + logger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + 'Caught exception in ' + method, "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessUpdateAAIGenericVnf((): ' + e.getMessage()) + } + } + + public void setSuccessfulRollbackStatus (DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + logger.trace("STARTED setSuccessfulRollbackStatus") + + try{ + // Set rolledBack to true, rollbackError to null + execution.setVariable("rolledBack", true) + execution.setVariable("rollbackError", null) + + }catch(Exception e){ + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "Exception Occured Processing setSuccessfulRollbackStatus.", "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED setSuccessfulRollbackStatus") + } + + public void setFailedRollbackStatus (DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + logger.trace("STARTED setFailedRollbackStatus") + + try{ + // Set rolledBack to false, rollbackError to actual value, rollbackData to null + execution.setVariable("rolledBack", false) + execution.setVariable("rollbackError", 'Caught exception in DoCreateVfModuleRollback') + execution.setVariable("rollbackData", null) + + }catch(Exception e){ + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "Exception Occured Processing setFailedRollbackStatus.", "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED setFailedRollbackStatus") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy index 002e283790..e776eaf422 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy @@ -55,187 +55,185 @@ import org.xml.sax.InputSource /* Subflow for Delete VF Module. When no DoDeleteVfModuleRequest is specified on input, * functions as a building block subflow - -* Inputs for building block interface: -* @param - requestId -* @param - isDebugLogEnabled -* @param - vnfId -* @param - vfModuleId -* @param - serviceInstanceId -* @param - vfModuleName O -* @param - vfModuleModelInfo -* @param - cloudConfiguration* -* @param - sdncVersion ("1610") -* @param - retainResources -* @param - aLaCarte -* -* Outputs: -* @param - WorkflowException -* -*/ + * Inputs for building block interface: + * @param - requestId + * @param - isDebugLogEnabled + * @param - vnfId + * @param - vfModuleId + * @param - serviceInstanceId + * @param - vfModuleName O + * @param - vfModuleModelInfo + * @param - cloudConfiguration* + * @param - sdncVersion ("1610") + * @param - retainResources + * @param - aLaCarte + * + * Outputs: + * @param - WorkflowException + * + */ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger( DoDeleteVfModule.class); - def Prefix="DoDVfMod_" - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - execution.setVariable("DoDVfMod_contrailNetworkPolicyFqdnList", null) - execution.setVariable("DoDVfMod_oamManagementV4Address", null) - execution.setVariable("DoDVfMod_oamManagementV6Address", null) - - } - - // parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids - // and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest - public void preProcessRequest(DelegateExecution execution) { - - initProcessVariables(execution) - - try { - def xml = execution.getVariable("DoDeleteVfModuleRequest") - String vnfId = "" - String vfModuleId = "" - - if (xml == null || xml.isEmpty()) { - // Building Block-type request - - // Set mso-request-id to request-id for VNF Adapter interface - String requestId = execution.getVariable("requestId") - execution.setVariable("mso-request-id", requestId) - - String cloudConfiguration = execution.getVariable("cloudConfiguration") - String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") - String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId") - execution.setVariable("tenantId", tenantId) - String cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") - execution.setVariable("cloudSiteId", cloudSiteId) - String cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudOwner") - execution.setVariable("cloudOwner", cloudOwner) - // Source is HARDCODED - String source = "VID" - execution.setVariable("source", source) - // SrvInstId is hardcoded to empty - execution.setVariable("srvInstId", "") - // ServiceId is hardcoded to empty - execution.setVariable("serviceId", "") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - vnfId = execution.getVariable("vnfId") - vfModuleId = execution.getVariable("vfModuleId") - if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { - execution.setVariable(Prefix + "serviceInstanceIdToSdnc", vfModuleId) - } - else { - execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceId) - } - //vfModuleModelName - def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") - execution.setVariable("vfModuleModelName", vfModuleModelName) - // retainResources - def retainResources = execution.getVariable("retainResources") - if (retainResources == null) { - retainResources = false - } - execution.setVariable("retainResources", retainResources) - } - else { - - logger.debug("DoDeleteVfModule Request: " + xml) - - logger.debug("input request xml: " + xml) - - vnfId = utils.getNodeText(xml,"vnf-id") - execution.setVariable("vnfId", vnfId) - vfModuleId = utils.getNodeText(xml,"vf-module-id") - execution.setVariable("vfModuleId", vfModuleId) - def srvInstId = execution.getVariable("mso-service-instance-id") - execution.setVariable("srvInstId", srvInstId) - String requestId = "" - try { - requestId = execution.getVariable("mso-request-id") - } catch (Exception ex) { - requestId = utils.getNodeText(xml, "request-id") - } - execution.setVariable("requestId", requestId) - String source = utils.getNodeText(xml, "source") - execution.setVariable("source", source) - String serviceId = utils.getNodeText(xml, "service-id") - execution.setVariable("serviceId", serviceId) - String tenantId = utils.getNodeText(xml, "tenant-id") - execution.setVariable("tenantId", tenantId) - - String serviceInstanceIdToSdnc = "" - if (xml.contains("service-instance-id")) { - serviceInstanceIdToSdnc = utils.getNodeText(xml, "service-instance-id") - } else { - serviceInstanceIdToSdnc = vfModuleId - } - execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceIdToSdnc) - String vfModuleName = utils.getNodeText(xml, "vf-module-name") - execution.setVariable("vfModuleName", vfModuleName) - String vfModuleModelName = utils.getNodeText(xml, "vf-module-model-name") - execution.setVariable("vfModuleModelName", vfModuleModelName) - String cloudSiteId = utils.getNodeText(xml, "aic-cloud-region") - execution.setVariable("cloudSiteId", cloudSiteId) - String cloudOwner = utils.getNodeText(xml, "cloud-owner") - execution.setVariable("cloudOwner", cloudOwner) - } - - // formulate the request for PrepareUpdateAAIVfModule - String request = """<PrepareUpdateAAIVfModuleRequest> + def Prefix="DoDVfMod_" + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + execution.setVariable("DoDVfMod_contrailNetworkPolicyFqdnList", null) + execution.setVariable("DoDVfMod_oamManagementV4Address", null) + execution.setVariable("DoDVfMod_oamManagementV6Address", null) + } + + // parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids + // and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest + public void preProcessRequest(DelegateExecution execution) { + + initProcessVariables(execution) + + try { + def xml = execution.getVariable("DoDeleteVfModuleRequest") + String vnfId = "" + String vfModuleId = "" + + if (xml == null || xml.isEmpty()) { + // Building Block-type request + + // Set mso-request-id to request-id for VNF Adapter interface + String requestId = execution.getVariable("requestId") + execution.setVariable("mso-request-id", requestId) + + String cloudConfiguration = execution.getVariable("cloudConfiguration") + String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") + String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId") + execution.setVariable("tenantId", tenantId) + String cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") + execution.setVariable("cloudSiteId", cloudSiteId) + String cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudOwner") + execution.setVariable("cloudOwner", cloudOwner) + // Source is HARDCODED + String source = "VID" + execution.setVariable("source", source) + // SrvInstId is hardcoded to empty + execution.setVariable("srvInstId", "") + // ServiceId is hardcoded to empty + execution.setVariable("serviceId", "") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + vnfId = execution.getVariable("vnfId") + vfModuleId = execution.getVariable("vfModuleId") + if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { + execution.setVariable(Prefix + "serviceInstanceIdToSdnc", vfModuleId) + } + else { + execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceId) + } + //vfModuleModelName + def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") + execution.setVariable("vfModuleModelName", vfModuleModelName) + // retainResources + def retainResources = execution.getVariable("retainResources") + if (retainResources == null) { + retainResources = false + } + execution.setVariable("retainResources", retainResources) + } + else { + + logger.debug("DoDeleteVfModule Request: " + xml) + + logger.debug("input request xml: " + xml) + + vnfId = utils.getNodeText(xml,"vnf-id") + execution.setVariable("vnfId", vnfId) + vfModuleId = utils.getNodeText(xml,"vf-module-id") + execution.setVariable("vfModuleId", vfModuleId) + def srvInstId = execution.getVariable("mso-service-instance-id") + execution.setVariable("srvInstId", srvInstId) + String requestId = "" + try { + requestId = execution.getVariable("mso-request-id") + } catch (Exception ex) { + requestId = utils.getNodeText(xml, "request-id") + } + execution.setVariable("requestId", requestId) + String source = utils.getNodeText(xml, "source") + execution.setVariable("source", source) + String serviceId = utils.getNodeText(xml, "service-id") + execution.setVariable("serviceId", serviceId) + String tenantId = utils.getNodeText(xml, "tenant-id") + execution.setVariable("tenantId", tenantId) + + String serviceInstanceIdToSdnc = "" + if (xml.contains("service-instance-id")) { + serviceInstanceIdToSdnc = utils.getNodeText(xml, "service-instance-id") + } else { + serviceInstanceIdToSdnc = vfModuleId + } + execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceIdToSdnc) + String vfModuleName = utils.getNodeText(xml, "vf-module-name") + execution.setVariable("vfModuleName", vfModuleName) + String vfModuleModelName = utils.getNodeText(xml, "vf-module-model-name") + execution.setVariable("vfModuleModelName", vfModuleModelName) + String cloudSiteId = utils.getNodeText(xml, "aic-cloud-region") + execution.setVariable("cloudSiteId", cloudSiteId) + String cloudOwner = utils.getNodeText(xml, "cloud-owner") + execution.setVariable("cloudOwner", cloudOwner) + } + + // formulate the request for PrepareUpdateAAIVfModule + String request = """<PrepareUpdateAAIVfModuleRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> <orchestration-status>pending-delete</orchestration-status> </PrepareUpdateAAIVfModuleRequest>""" as String - logger.debug("PrepareUpdateAAIVfModuleRequest :" + request) - logger.debug("UpdateAAIVfModule Request: " + request) - execution.setVariable("PrepareUpdateAAIVfModuleRequest", request) - execution.setVariable("vfModuleFromAAI", null) - }catch(BpmnError b){ - throw b - }catch(Exception e){ - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") - } - } - - // build a SDNC vnf-topology-operation request for the specified action - // (note: the action passed is expected to be 'changedelete' or 'delete') - public void prepSDNCAdapterRequest(DelegateExecution execution, String action) { - - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("requestId") + "-" + System.currentTimeMillis() - } - - def srvInstId = execution.getVariable("srvInstId") - def callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - String requestId = execution.getVariable("requestId") - String source = execution.getVariable("source") - String serviceId = execution.getVariable("serviceId") - String vnfId = execution.getVariable("vnfId") - String tenantId = execution.getVariable("tenantId") - String vfModuleId = execution.getVariable("vfModuleId") - String serviceInstanceIdToSdnc = execution.getVariable(Prefix + "serviceInstanceIdToSdnc") - String vfModuleName = execution.getVariable("vfModuleName") - // Get vfModuleName from AAI response if it was not specified on the request - if (vfModuleName == null || vfModuleName.isEmpty()) { - if (execution.getVariable("vfModuleFromAAI") != null) { - org.onap.aai.domain.yang.VfModule vfModuleFromAAI = execution.getVariable("vfModuleFromAAI") - vfModuleName = vfModuleFromAAI.getVfModuleName() - } - } - String vfModuleModelName = execution.getVariable("vfModuleModelName") - String cloudSiteId = execution.getVariable("cloudSiteId") - boolean retainResources = execution.getVariable("retainResources") - String requestSubActionString = "" - if (retainResources) { - requestSubActionString = "<request-sub-action>RetainResource</request-sub-action>" - } - String request = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" + logger.debug("PrepareUpdateAAIVfModuleRequest :" + request) + logger.debug("UpdateAAIVfModule Request: " + request) + execution.setVariable("PrepareUpdateAAIVfModuleRequest", request) + execution.setVariable("vfModuleFromAAI", null) + }catch(BpmnError b){ + throw b + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") + } + } + + // build a SDNC vnf-topology-operation request for the specified action + // (note: the action passed is expected to be 'changedelete' or 'delete') + public void prepSDNCAdapterRequest(DelegateExecution execution, String action) { + + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("requestId") + "-" + System.currentTimeMillis() + } + + def srvInstId = execution.getVariable("srvInstId") + def callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + String requestId = execution.getVariable("requestId") + String source = execution.getVariable("source") + String serviceId = execution.getVariable("serviceId") + String vnfId = execution.getVariable("vnfId") + String tenantId = execution.getVariable("tenantId") + String vfModuleId = execution.getVariable("vfModuleId") + String serviceInstanceIdToSdnc = execution.getVariable(Prefix + "serviceInstanceIdToSdnc") + String vfModuleName = execution.getVariable("vfModuleName") + // Get vfModuleName from AAI response if it was not specified on the request + if (vfModuleName == null || vfModuleName.isEmpty()) { + if (execution.getVariable("vfModuleFromAAI") != null) { + org.onap.aai.domain.yang.VfModule vfModuleFromAAI = execution.getVariable("vfModuleFromAAI") + vfModuleName = vfModuleFromAAI.getVfModuleName() + } + } + String vfModuleModelName = execution.getVariable("vfModuleModelName") + String cloudSiteId = execution.getVariable("cloudSiteId") + boolean retainResources = execution.getVariable("retainResources") + String requestSubActionString = "" + if (retainResources) { + requestSubActionString = "<request-sub-action>RetainResource</request-sub-action>" + } + String request = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1"> <sdncadapter:RequestHeader> @@ -274,33 +272,33 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ </sdncadapterworkflow:SDNCRequestData> </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - logger.debug("sdncAdapterWorkflowRequest: " + request) - logger.debug("DoDeleteVfModule - SDNCAdapterWorkflowRequest: " + request) - execution.setVariable("sdncAdapterWorkflowRequest", request) - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing VnfAdapterDeleteV1 request - public void prepVNFAdapterRequest(DelegateExecution execution) { - - def requestId = UUID.randomUUID().toString() - def origRequestId = execution.getVariable('requestId') - def srvInstId = execution.getVariable("serviceInstanceId") - def aicCloudRegion = execution.getVariable("cloudSiteId") - def cloudOwner = execution.getVariable("cloudOwner") - def vnfId = execution.getVariable("vnfId") - def vfModuleId = execution.getVariable("vfModuleId") - def vfModuleStackId = execution.getVariable('DoDVfMod_heatStackId') - def tenantId = execution.getVariable("tenantId") - def messageId = execution.getVariable('requestId') + '-' + - System.currentTimeMillis() - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) - def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) - if ('true'.equals(useQualifiedHostName)) { - notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) - } - - String request = """ + logger.debug("sdncAdapterWorkflowRequest: " + request) + logger.debug("DoDeleteVfModule - SDNCAdapterWorkflowRequest: " + request) + execution.setVariable("sdncAdapterWorkflowRequest", request) + } + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing VnfAdapterDeleteV1 request + public void prepVNFAdapterRequest(DelegateExecution execution) { + + def requestId = UUID.randomUUID().toString() + def origRequestId = execution.getVariable('requestId') + def srvInstId = execution.getVariable("serviceInstanceId") + def aicCloudRegion = execution.getVariable("cloudSiteId") + def cloudOwner = execution.getVariable("cloudOwner") + def vnfId = execution.getVariable("vnfId") + def vfModuleId = execution.getVariable("vfModuleId") + def vfModuleStackId = execution.getVariable('DoDVfMod_heatStackId') + def tenantId = execution.getVariable("tenantId") + def messageId = execution.getVariable('requestId') + '-' + + System.currentTimeMillis() + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String request = """ <deleteVfModuleRequest> <cloudSiteId>${MsoUtils.xmlEscape(aicCloudRegion)}</cloudSiteId> <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> @@ -318,303 +316,301 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ </deleteVfModuleRequest> """ as String - logger.debug("vnfAdapterRestV1Request: " + request) - logger.debug("deleteVfModuleRequest: " + request) - execution.setVariable("vnfAdapterRestV1Request", request) - } + logger.debug("deleteVfModuleRequest: " + request) + execution.setVariable("vnfAdapterTaskRequest", request) + } - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing UpdateAAIVfModuleRequest request - public void prepUpdateAAIVfModule(DelegateExecution execution) { + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing UpdateAAIVfModuleRequest request + public void prepUpdateAAIVfModule(DelegateExecution execution) { - def vnfId = execution.getVariable("vnfId") - def vfModuleId = execution.getVariable("vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<UpdateAAIVfModuleRequest> + def vnfId = execution.getVariable("vnfId") + def vfModuleId = execution.getVariable("vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """<UpdateAAIVfModuleRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> <heat-stack-id>DELETE</heat-stack-id> <orchestration-status>deleted</orchestration-status> </UpdateAAIVfModuleRequest>""" as String - logger.debug("UpdateAAIVfModuleRequest :" + request) - logger.debug("UpdateAAIVfModuleRequest: " + request) - execution.setVariable("UpdateAAIVfModuleRequest", request) - } + logger.debug("UpdateAAIVfModuleRequest: " + request) + execution.setVariable("UpdateAAIVfModuleRequest", request) + } - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing DeleteAAIVfModuleRequest request - public void prepDeleteAAIVfModule(DelegateExecution execution) { + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing DeleteAAIVfModuleRequest request + public void prepDeleteAAIVfModule(DelegateExecution execution) { - def vnfId = execution.getVariable("vnfId") - def vfModuleId = execution.getVariable("vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<DeleteAAIVfModuleRequest> + def vnfId = execution.getVariable("vnfId") + def vfModuleId = execution.getVariable("vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """<DeleteAAIVfModuleRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> </DeleteAAIVfModuleRequest>""" as String - logger.debug("DeleteAAIVfModuleRequest :" + request) - logger.debug("DeleteAAIVfModuleRequest: " + request) - execution.setVariable("DeleteAAIVfModuleRequest", request) - } - - // generates a WorkflowException if - // - - public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "AAI error occurred deleting the Generic Vnf: " + execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), - "BPMN", ErrorCode.UnknownError.getValue(), "Exception"); - String processKey = getProcessKey(execution); - WorkflowException exception = new WorkflowException(processKey, 5000, - execution.getVariable("DoDVfMod_deleteGenericVnfResponse")) - execution.setVariable("WorkflowException", exception) - } - - public void sdncValidateResponse(DelegateExecution execution, String response){ - - execution.setVariable("prefix",Prefix) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - logger.debug("Successfully Validated SDNC Response") - }else{ - throw new BpmnError("MSOWorkflowException") - } - } - - public void postProcessVNFAdapterRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + - 'execution=' + execution.getId() + - ')' - - logger.trace('Entered ' + method) - execution.setVariable("prefix",Prefix) - try{ - logger.trace("STARTED postProcessVNFAdapterRequest Process") - - String vnfResponse = execution.getVariable("DoDVfMod_doDeleteVfModuleResponse") - logger.debug("VNF Adapter Response is: " + vnfResponse) - logger.debug("deleteVnfAResponse is: \n" + vnfResponse) - - if(vnfResponse != null){ - - if(vnfResponse.contains("deleteVfModuleResponse")){ - logger.debug("Received a Good Response from VNF Adapter for DELETE_VF_MODULE Call.") - execution.setVariable("DoDVfMod_vnfVfModuleDeleteCompleted", true) - - // Parse vnfOutputs for contrail network polcy FQDNs - if (vnfResponse.contains("vfModuleOutputs")) { - def vfModuleOutputsXml = utils.getNodeXml(vnfResponse, "vfModuleOutputs") - InputSource source = new InputSource(new StringReader(vfModuleOutputsXml)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setNamespaceAware(true) - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document outputsXml = docBuilder.parse(source) - - NodeList entries = outputsXml.getElementsByTagNameNS("*", "entry") - List contrailNetworkPolicyFqdnList = [] - for (int i = 0; i< entries.getLength(); i++) { - Node node = entries.item(i) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node - String key = element.getElementsByTagNameNS("*", "key").item(0).getTextContent() - if (key.endsWith("contrail_network_policy_fqdn")) { - String contrailNetworkPolicyFqdn = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() - logger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn) - contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn) - } - else if (key.equals("oam_management_v4_address")) { - String oamManagementV4Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() - logger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address) - execution.setVariable(Prefix + "oamManagementV4Address", oamManagementV4Address) - } - else if (key.equals("oam_management_v6_address")) { - String oamManagementV6Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() - logger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address) - execution.setVariable(Prefix + "oamManagementV6Address", oamManagementV6Address) - } - - } - } - if (!contrailNetworkPolicyFqdnList.isEmpty()) { - logger.debug("Setting the fqdn list") - execution.setVariable("DoDVfMod_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList) - } - } - }else{ - logger.debug("Received a BAD Response from VNF Adapter for DELETE_VF_MODULE Call.") - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") - } - }else{ - logger.debug("Response from VNF Adapter is Null for DELETE_VF_MODULE Call.") - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter") - } - - }catch(BpmnError b){ - throw b - }catch(Exception e){ - logger.debug("Internal Error Occured in PostProcess Method") - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method") - } - logger.trace("COMPLETED postProcessVnfAdapterResponse Process") - } - - public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + - 'execution=' + execution.getId() + - ')' - - logger.trace('Entered ' + method) - execution.setVariable("prefix", Prefix) - logger.trace("STARTED deleteNetworkPoliciesFromAAI ") - - try { - // get variables - List fqdnList = execution.getVariable("DoDVfMod_contrailNetworkPolicyFqdnList") - if (fqdnList == null) { - logger.debug("No network policies to delete") - return - } - int fqdnCount = fqdnList.size() - - execution.setVariable("DoDVfMod_networkPolicyFqdnCount", fqdnCount) - logger.debug("DoDVfMod_networkPolicyFqdnCount - " + fqdnCount) - - if (fqdnCount > 0) { - // AII loop call over contrail network policy fqdn list - for (i in 0..fqdnCount-1) { - String fqdn = fqdnList[i] - // Query AAI for this network policy FQDN + logger.debug("DeleteAAIVfModuleRequest :" + request) + logger.debug("DeleteAAIVfModuleRequest: " + request) + execution.setVariable("DeleteAAIVfModuleRequest", request) + } + + // generates a WorkflowException if + // - + public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "AAI error occurred deleting the Generic Vnf: " + execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), + "BPMN", ErrorCode.UnknownError.getValue(), "Exception"); + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable("DoDVfMod_deleteGenericVnfResponse")) + execution.setVariable("WorkflowException", exception) + } + + public void sdncValidateResponse(DelegateExecution execution, String response){ + + execution.setVariable("prefix",Prefix) + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + logger.debug("Successfully Validated SDNC Response") + }else{ + throw new BpmnError("MSOWorkflowException") + } + } + + public void postProcessVNFAdapterRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + + 'execution=' + execution.getId() + + ')' + + logger.trace('Entered ' + method) + execution.setVariable("prefix",Prefix) + try{ + logger.trace("STARTED postProcessVNFAdapterRequest Process") + + String vnfResponse = execution.getVariable("DoDVfMod_doDeleteVfModuleResponse") + logger.debug("VNF Adapter Response is: " + vnfResponse) + logger.debug("deleteVnfAResponse is: \n" + vnfResponse) + + if(vnfResponse != null){ + + if(vnfResponse.contains("deleteVfModuleResponse")){ + logger.debug("Received a Good Response from VNF Adapter for DELETE_VF_MODULE Call.") + execution.setVariable("DoDVfMod_vnfVfModuleDeleteCompleted", true) + + // Parse vnfOutputs for contrail network polcy FQDNs + if (vnfResponse.contains("vfModuleOutputs")) { + def vfModuleOutputsXml = utils.getNodeXml(vnfResponse, "vfModuleOutputs") + InputSource source = new InputSource(new StringReader(vfModuleOutputsXml)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document outputsXml = docBuilder.parse(source) + + NodeList entries = outputsXml.getElementsByTagNameNS("*", "entry") + List contrailNetworkPolicyFqdnList = [] + for (int i = 0; i< entries.getLength(); i++) { + Node node = entries.item(i) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) node + String key = element.getElementsByTagNameNS("*", "key").item(0).getTextContent() + if (key.endsWith("contrail_network_policy_fqdn")) { + String contrailNetworkPolicyFqdn = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + logger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn) + contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn) + } + else if (key.equals("oam_management_v4_address")) { + String oamManagementV4Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + logger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address) + execution.setVariable(Prefix + "oamManagementV4Address", oamManagementV4Address) + } + else if (key.equals("oam_management_v6_address")) { + String oamManagementV6Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() + logger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address) + execution.setVariable(Prefix + "oamManagementV6Address", oamManagementV6Address) + } + + } + } + if (!contrailNetworkPolicyFqdnList.isEmpty()) { + logger.debug("Setting the fqdn list") + execution.setVariable("DoDVfMod_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList) + } + } + }else{ + logger.debug("Received a BAD Response from VNF Adapter for DELETE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") + } + }else{ + logger.debug("Response from VNF Adapter is Null for DELETE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter") + } + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + logger.debug("Internal Error Occured in PostProcess Method") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method") + } + logger.trace("COMPLETED postProcessVnfAdapterResponse Process") + } + + public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + + 'execution=' + execution.getId() + + ')' + + logger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + logger.trace("STARTED deleteNetworkPoliciesFromAAI ") + + try { + // get variables + List fqdnList = execution.getVariable("DoDVfMod_contrailNetworkPolicyFqdnList") + if (fqdnList == null) { + logger.debug("No network policies to delete") + return + } + int fqdnCount = fqdnList.size() + + execution.setVariable("DoDVfMod_networkPolicyFqdnCount", fqdnCount) + logger.debug("DoDVfMod_networkPolicyFqdnCount - " + fqdnCount) + + if (fqdnCount > 0) { + // AII loop call over contrail network policy fqdn list + for (i in 0..fqdnCount-1) { + String fqdn = fqdnList[i] + // Query AAI for this network policy FQDN AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) - uri.queryParam("network-policy-fqdn", fqdn) - try { - Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri) - if (networkPolicies.isPresent() && !networkPolicies.get().getNetworkPolicy().isEmpty()) { - // This network policy FQDN exists in AAI - need to delete it now - NetworkPolicy networkPolicy = networkPolicies.get().getNetworkPolicy().get(0) - execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200) - // Retrieve the network policy id for this FQDN - def networkPolicyId = networkPolicy.getNetworkPolicyId() - logger.debug("Deleting network-policy with network-policy-id " + networkPolicyId) - try { - AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) - getAAIClient().delete(delUri) - execution.setVariable("DoDVfMod_aaiDeleteNetworkPolicyReturnCode", 200) - } catch (Exception e) { - execution.setVariable("DoDVfMod_aaiDeleteNetworkPolicyReturnCode", 500) - String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + e.getMessage() - logger.debug(delErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage) - } - } else { - execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 404) - // This network policy FQDN is not in AAI. No need to delete. - logger.debug("The return code is: " + 404) - logger.debug("This network policy FQDN is not in AAI: " + fqdn) - logger.debug("Network policy FQDN is not in AAI") - } - }catch(Exception e ) { - // aai all errors - String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + e.getMessage() - logger.debug(dataErrorMessage) - } - } // end loop - } else { - logger.debug("No contrail network policies to query/create") - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoDeletVfModule flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - } - - /** - * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateAAIGenericVnf(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + - 'execution=' + execution.getId() + - ')' - - logger.trace('Entered ' + method) - - try { - def vnfId = execution.getVariable('vnfId') - def oamManagementV4Address = execution.getVariable(Prefix + 'oamManagementV4Address') - def oamManagementV6Address = execution.getVariable(Prefix + 'oamManagementV6Address') - def ipv4OamAddressElement = '' - def managementV6AddressElement = '' - - if (oamManagementV4Address != null) { - ipv4OamAddressElement = '<ipv4-oam-address>' + 'DELETE' + '</ipv4-oam-address>' - } - - if (oamManagementV6Address != null) { - managementV6AddressElement = '<management-v6-address>' + 'DELETE' + '</management-v6-address>' - } - - - String updateAAIGenericVnfRequest = """ + uri.queryParam("network-policy-fqdn", fqdn) + try { + Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri) + if (networkPolicies.isPresent() && !networkPolicies.get().getNetworkPolicy().isEmpty()) { + // This network policy FQDN exists in AAI - need to delete it now + NetworkPolicy networkPolicy = networkPolicies.get().getNetworkPolicy().get(0) + execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200) + // Retrieve the network policy id for this FQDN + def networkPolicyId = networkPolicy.getNetworkPolicyId() + logger.debug("Deleting network-policy with network-policy-id " + networkPolicyId) + try { + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + getAAIClient().delete(delUri) + execution.setVariable("DoDVfMod_aaiDeleteNetworkPolicyReturnCode", 200) + } catch (Exception e) { + execution.setVariable("DoDVfMod_aaiDeleteNetworkPolicyReturnCode", 500) + String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + e.getMessage() + logger.debug(delErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage) + } + } else { + execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 404) + // This network policy FQDN is not in AAI. No need to delete. + logger.debug("The return code is: " + 404) + logger.debug("This network policy FQDN is not in AAI: " + fqdn) + logger.debug("Network policy FQDN is not in AAI") + } + }catch(Exception e ) { + // aai all errors + String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + e.getMessage() + logger.debug(dataErrorMessage) + } + } // end loop + } else { + logger.debug("No contrail network policies to query/create") + } + } catch (BpmnError e) { + throw e; + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoDeletVfModule flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + } + + /** + * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. + * + * @param execution The flow's execution instance. + */ + public void prepUpdateAAIGenericVnf(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + + 'execution=' + execution.getId() + + ')' + + logger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('vnfId') + def oamManagementV4Address = execution.getVariable(Prefix + 'oamManagementV4Address') + def oamManagementV6Address = execution.getVariable(Prefix + 'oamManagementV6Address') + def ipv4OamAddressElement = '' + def managementV6AddressElement = '' + + if (oamManagementV4Address != null) { + ipv4OamAddressElement = '<ipv4-oam-address>' + 'DELETE' + '</ipv4-oam-address>' + } + + if (oamManagementV6Address != null) { + managementV6AddressElement = '<management-v6-address>' + 'DELETE' + '</management-v6-address>' + } + + + String updateAAIGenericVnfRequest = """ <UpdateAAIGenericVnfRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> ${ipv4OamAddressElement} ${managementV6AddressElement} </UpdateAAIGenericVnfRequest> """ - updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) - execution.setVariable(Prefix + 'updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) - logger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) - logger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest) - - - logger.trace('Exited ' + method) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - 'Caught exception in ' + method, "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) - } - } - - /** - * Using the vnfId and vfModuleId provided in the inputs, - * query AAI to get the corresponding VF Module info. - * A 200 response is expected with the VF Module info in the response body, - * Will determine VF Module's orchestration status if one exists - * - * @param execution The flow's execution instance. - */ - public void queryAAIVfModuleForStatus(DelegateExecution execution) { - - def method = getClass().getSimpleName() + '.queryAAIVfModuleForStatus(' + - 'execution=' + execution.getId() + - ')' - logger.trace('Entered ' + method) - - execution.setVariable(Prefix + 'orchestrationStatus', '') - - try { - def vnfId = execution.getVariable('vnfId') - def vfModuleId = execution.getVariable('vfModuleId') - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) - - try { + updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) + execution.setVariable(Prefix + 'updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) + logger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) + logger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest) + + + logger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + 'Caught exception in ' + method, "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) + } + } + + /** + * Using the vnfId and vfModuleId provided in the inputs, + * query AAI to get the corresponding VF Module info. + * A 200 response is expected with the VF Module info in the response body, + * Will determine VF Module's orchestration status if one exists + * + * @param execution The flow's execution instance. + */ + public void queryAAIVfModuleForStatus(DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.queryAAIVfModuleForStatus(' + + 'execution=' + execution.getId() + + ')' + logger.trace('Entered ' + method) + + execution.setVariable(Prefix + 'orchestrationStatus', '') + + try { + def vnfId = execution.getVariable('vnfId') + def vfModuleId = execution.getVariable('vfModuleId') + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + + try { Optional<org.onap.aai.domain.yang.VfModule> vfModule = getAAIClient().get(org.onap.aai.domain.yang.VfModule.class, uri); - // Retrieve VF Module info and its orchestration status; if not found, do nothing + // Retrieve VF Module info and its orchestration status; if not found, do nothing if (vfModule.isPresent()) { execution.setVariable(Prefix + 'queryAAIVfModuleForStatusResponseCode', 200) execution.setVariable(Prefix + 'queryAAIVfModuleForStatusResponse', vfModule.get()) @@ -622,20 +618,20 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus) logger.debug("Received orchestration status from A&AI: " + orchestrationStatus) } - } catch (Exception ex) { - logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) - } - logger.trace('Exited ' + method) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - 'Caught exception in ' + method, "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage()) - } - } + } catch (Exception ex) { + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) + } + logger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + 'Caught exception in ' + method, "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage()) + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy index 34a210364a..350de4a03d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy @@ -9,9 +9,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. @@ -53,244 +53,244 @@ import org.slf4j.LoggerFactory public class DoDeleteVfModuleFromVnf extends VfModuleBase { private static final Logger logger = LoggerFactory.getLogger( DoDeleteVfModuleFromVnf.class); - def Prefix="DDVFMV_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - execution.setVariable("DDVFMV_contrailNetworkPolicyFqdnList", null) - } - - // parse the incoming request - public void preProcessRequest(DelegateExecution execution) { - - initProcessVariables(execution) - - try { - - // Building Block-type request - - // Set mso-request-id to request-id for VNF Adapter interface - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("mso-request-id", requestId) - execution.setVariable("requestId", requestId) - logger.debug("msoRequestId: " + requestId) - String tenantId = execution.getVariable("tenantId") - logger.debug("tenantId: " + tenantId) - String cloudSiteId = execution.getVariable("lcpCloudRegionId") - execution.setVariable("cloudSiteId", cloudSiteId) - logger.debug("cloudSiteId: " + cloudSiteId) - String cloudOwner = execution.getVariable("cloudOwner") - execution.setVariable("cloudOwner", cloudOwner) - logger.debug("cloudOwner: " + cloudOwner) - // Source is HARDCODED - String source = "VID" - execution.setVariable("source", source) - // isVidRequest is hardcoded to "true" - execution.setVariable("isVidRequest", "true") - // SrvInstId is hardcoded to empty - execution.setVariable("srvInstId", "") - // ServiceId is hardcoded to empty - execution.setVariable("serviceId", "") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - logger.debug("serviceInstanceId: " + serviceInstanceId) - String vnfId = execution.getVariable("vnfId") - logger.debug("vnfId: " + vnfId) - String vfModuleId = execution.getVariable("vfModuleId") - logger.debug("vfModuleId: " + vfModuleId) - if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { - execution.setVariable(Prefix + "serviceInstanceIdToSdnc", vfModuleId) - } - else { - execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceId) - } - - String sdncVersion = execution.getVariable("sdncVersion") - if (sdncVersion == null) { - sdncVersion = "1707" - } - execution.setVariable(Prefix + "sdncVersion", sdncVersion) - logger.debug("Incoming Sdnc Version is: " + sdncVersion) - - String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) - if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { - def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), "Exception"); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - logger.debug("SDNC Callback URL: " + sdncCallbackUrl) - logger.debug("SDNC Callback URL is: " + sdncCallbackUrl) - - }catch(BpmnError b){ - throw b - }catch(Exception e){ - logger.debug("Exception is: " + e.getMessage()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") - } - } - - public void queryAAIForVfModule(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.queryAAIForVfModule(' + - 'execution=' + execution.getId() + - ')' - - logger.trace('Entered ' + method) - - try { - def vnfId = execution.getVariable('vnfId') - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) - try { - Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri) - - if(genericVnf.isPresent()){ - execution.setVariable('DDVMFV_getVnfResponseCode', 200) - execution.setVariable('DDVMFV_getVnfResponse', genericVnf.get()) - }else{ - execution.setVariable('DDVMFV_getVnfResponseCode', 404) - execution.setVariable('DDVMFV_getVnfResponse', "Generic Vnf not found!") - } - } catch (Exception ex) { - logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) - execution.setVariable('DDVMFV_getVnfResponseCode', 500) - execution.setVariable('DDVFMV_getVnfResponse', 'AAI GET Failed:' + ex.getMessage()) - } - logger.trace('Exited ' + method) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - 'Caught exception in ' + method, "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVfModule(): ' + e.getMessage()) - } - } - - /** - * Validate the VF Module. That is, confirm that a VF Module with the input VF Module ID - * exists in the retrieved Generic VNF. Then, check to make sure that if that VF Module - * is the base VF Module and it's not the only VF Module for this Generic VNF, that we're not - * attempting to delete it. - * - * @param execution The flow's execution instance. - */ - public void validateVfModule(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.validateVfModule(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logger.trace('Entered ' + method) - - try { - GenericVnf genericVnf = execution.getVariable('DDVMFV_getVnfResponse') - def vnfId = execution.getVariable('_vnfId') - def vfModuleId = execution.getVariable('vfModuleId') + def Prefix="DDVFMV_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + execution.setVariable("DDVFMV_contrailNetworkPolicyFqdnList", null) + } + + // parse the incoming request + public void preProcessRequest(DelegateExecution execution) { + + initProcessVariables(execution) + + try { + + // Building Block-type request + + // Set mso-request-id to request-id for VNF Adapter interface + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("mso-request-id", requestId) + execution.setVariable("requestId", requestId) + logger.debug("msoRequestId: " + requestId) + String tenantId = execution.getVariable("tenantId") + logger.debug("tenantId: " + tenantId) + String cloudSiteId = execution.getVariable("lcpCloudRegionId") + execution.setVariable("cloudSiteId", cloudSiteId) + logger.debug("cloudSiteId: " + cloudSiteId) + String cloudOwner = execution.getVariable("cloudOwner") + execution.setVariable("cloudOwner", cloudOwner) + logger.debug("cloudOwner: " + cloudOwner) + // Source is HARDCODED + String source = "VID" + execution.setVariable("source", source) + // isVidRequest is hardcoded to "true" + execution.setVariable("isVidRequest", "true") + // SrvInstId is hardcoded to empty + execution.setVariable("srvInstId", "") + // ServiceId is hardcoded to empty + execution.setVariable("serviceId", "") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + logger.debug("serviceInstanceId: " + serviceInstanceId) + String vnfId = execution.getVariable("vnfId") + logger.debug("vnfId: " + vnfId) + String vfModuleId = execution.getVariable("vfModuleId") + logger.debug("vfModuleId: " + vfModuleId) + if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { + execution.setVariable(Prefix + "serviceInstanceIdToSdnc", vfModuleId) + } + else { + execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceId) + } + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null) { + sdncVersion = "1707" + } + execution.setVariable(Prefix + "sdncVersion", sdncVersion) + logger.debug("Incoming Sdnc Version is: " + sdncVersion) + + String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) + if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { + def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue(), "Exception"); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) + logger.debug("SDNC Callback URL: " + sdncCallbackUrl) + logger.debug("SDNC Callback URL is: " + sdncCallbackUrl) + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + logger.debug("Exception is: " + e.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") + } + } + + public void queryAAIForVfModule(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.queryAAIForVfModule(' + + 'execution=' + execution.getId() + + ')' + + logger.trace('Entered ' + method) + + try { + def vnfId = execution.getVariable('vnfId') + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + try { + Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri) + + if(genericVnf.isPresent()){ + execution.setVariable('DDVMFV_getVnfResponseCode', 200) + execution.setVariable('DDVMFV_getVnfResponse', genericVnf.get()) + }else{ + execution.setVariable('DDVMFV_getVnfResponseCode', 404) + execution.setVariable('DDVMFV_getVnfResponse', "Generic Vnf not found!") + } + } catch (Exception ex) { + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) + execution.setVariable('DDVMFV_getVnfResponseCode', 500) + execution.setVariable('DDVFMV_getVnfResponse', 'AAI GET Failed:' + ex.getMessage()) + } + logger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + 'Caught exception in ' + method, "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVfModule(): ' + e.getMessage()) + } + } + + /** + * Validate the VF Module. That is, confirm that a VF Module with the input VF Module ID + * exists in the retrieved Generic VNF. Then, check to make sure that if that VF Module + * is the base VF Module and it's not the only VF Module for this Generic VNF, that we're not + * attempting to delete it. + * + * @param execution The flow's execution instance. + */ + public void validateVfModule(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.validateVfModule(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logger.trace('Entered ' + method) + + try { + GenericVnf genericVnf = execution.getVariable('DDVMFV_getVnfResponse') + def vnfId = execution.getVariable('_vnfId') + def vfModuleId = execution.getVariable('vfModuleId') Optional<VfModule> vfModule = Optional.empty() if(genericVnf.getVfModules()!=null && ! genericVnf.getVfModules().getVfModule().isEmpty()) { vfModule = genericVnf.getVfModules().getVfModule().stream().filter { v -> v.getVfModuleId().equals(vfModuleId) }.findFirst() } - if (!vfModule.isPresent()) { - String msg = 'VF Module \'' + vfModuleId + '\' does not exist in Generic VNF \'' + vnfId + '\'' - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, msg) - } else { + if (!vfModule.isPresent()) { + String msg = 'VF Module \'' + vfModuleId + '\' does not exist in Generic VNF \'' + vnfId + '\'' + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, msg) + } else { Boolean isOnlyVfModule = (genericVnf.getVfModules().getVfModule().size() == 1) - if (isDebugLogEnabled) { - logger.debug('VF Module \'' + vfModuleId + '\': isBaseVfModule=' + vfModule.get().isIsBaseVfModule() + ', isOnlyVfModule=' + isOnlyVfModule) - } - if (vfModule.get().isIsBaseVfModule() && !isOnlyVfModule) { + if (isDebugLogEnabled) { + logger.debug('VF Module \'' + vfModuleId + '\': isBaseVfModule=' + vfModule.get().isIsBaseVfModule() + ', isOnlyVfModule=' + isOnlyVfModule) + } + if (vfModule.get().isIsBaseVfModule() && !isOnlyVfModule) { String msg = 'Cannot delete VF Module \'' + vfModuleId + '\'since it is the base VF Module and it\'s not the only VF Module in Generic VNF \'' + vnfId + '\'' logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 1002,msg) - } - def heatStackId = vfModule.get().getHeatStackId() - execution.setVariable('DDVMFV_heatStackId', heatStackId) - logger.debug('VF Module heatStackId retrieved from AAI: ' + heatStackId) - } - logger.trace('Exited ' + method) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - 'Caught exception in ' + method, "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in validateVfModule(): ' + e.getMessage()) - } - } - - - public void preProcessSDNCDeactivateRequest(DelegateExecution execution){ - - execution.setVariable("prefix", Prefix) - logger.trace("STARTED preProcessSDNCDeactivateRequest ") - - def serviceInstanceId = execution.getVariable("serviceInstanceId") - - try{ - //Build SDNC Request - - String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") - - deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) - execution.setVariable("DDVMFV_deactivateSDNCRequest", deactivateSDNCRequest) - logger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) - - - }catch(Exception e){ - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) - } - logger.trace("COMPLETED preProcessSDNCDeactivateRequest ") - } - - public void preProcessSDNCUnassignRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + - 'execution=' + execution.getId() + - ')' - - logger.trace('Entered ' + method) - execution.setVariable("prefix", Prefix) - logger.trace("STARTED preProcessSDNCUnassignRequest Process ") - try{ - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") - - execution.setVariable("DDVMFV_unassignSDNCRequest", unassignSDNCRequest) - logger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) - - - }catch(Exception e){ - logger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) - } - logger.trace("COMPLETED preProcessSDNCUnassignRequest Process ") - } - - public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() - } - def callbackURL = execution.getVariable("sdncCallbackUrl") - def requestId = execution.getVariable("msoRequestId") - def serviceId = execution.getVariable("serviceId") - def serviceInstanceId = execution.getVariable("serviceInstanceId") - def vfModuleId = execution.getVariable("vfModuleId") - def source = execution.getVariable("source") - def vnfId = execution.getVariable("vnfId") - - def sdncVersion = execution.getVariable(Prefix + "sdncVersion") - - String sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" + } + def heatStackId = vfModule.get().getHeatStackId() + execution.setVariable('DDVMFV_heatStackId', heatStackId) + logger.debug('VF Module heatStackId retrieved from AAI: ' + heatStackId) + } + logger.trace('Exited ' + method) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + 'Caught exception in ' + method, "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in validateVfModule(): ' + e.getMessage()) + } + } + + + public void preProcessSDNCDeactivateRequest(DelegateExecution execution){ + + execution.setVariable("prefix", Prefix) + logger.trace("STARTED preProcessSDNCDeactivateRequest ") + + def serviceInstanceId = execution.getVariable("serviceInstanceId") + + try{ + //Build SDNC Request + + String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") + + deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) + execution.setVariable("DDVMFV_deactivateSDNCRequest", deactivateSDNCRequest) + logger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) + + + }catch(Exception e){ + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preProcessSDNCDeactivateRequest ") + } + + public void preProcessSDNCUnassignRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + + 'execution=' + execution.getId() + + ')' + + logger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + logger.trace("STARTED preProcessSDNCUnassignRequest Process ") + try{ + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") + + execution.setVariable("DDVMFV_unassignSDNCRequest", unassignSDNCRequest) + logger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) + + + }catch(Exception e){ + logger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) + } + logger.trace("COMPLETED preProcessSDNCUnassignRequest Process ") + } + + public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ + + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() + } + def callbackURL = execution.getVariable("sdncCallbackUrl") + def requestId = execution.getVariable("msoRequestId") + def serviceId = execution.getVariable("serviceId") + def serviceInstanceId = execution.getVariable("serviceInstanceId") + def vfModuleId = execution.getVariable("vfModuleId") + def source = execution.getVariable("source") + def vnfId = execution.getVariable("vnfId") + + def sdncVersion = execution.getVariable(Prefix + "sdncVersion") + + String sdncRequest = + """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"> <sdncadapter:RequestHeader> @@ -312,73 +312,73 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { </request-information> <service-information> <service-id/> - <subscription-service-type/> + <subscription-service-type/> <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> <global-customer-id/> </service-information> <vnf-information> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> - <vnf-type/> + <vnf-type/> </vnf-information> <vf-module-information> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> </vf-module-information> - <vf-module-request-input/> + <vf-module-request-input/> </sdncadapterworkflow:SDNCRequestData> </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - logger.debug("sdncRequest: " + sdncRequest) - return sdncRequest - } - - public void validateSDNCResponse(DelegateExecution execution, String response, String method){ - - execution.setVariable("prefix",Prefix) - logger.trace("STARTED ValidateSDNCResponse Process") - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - logger.debug("workflowException: " + workflowException) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - logger.debug("SDNCResponse: " + response) - - String sdncResponse = response - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) - }else{ - logger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") - throw new BpmnError("MSOWorkflowException") - } - logger.trace("COMPLETED ValidateSDNCResponse Process") - } - - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing VnfAdapterDeleteV1 request - public void prepVNFAdapterRequest(DelegateExecution execution) { - - def requestId = UUID.randomUUID().toString() - def origRequestId = execution.getVariable('requestId') - def srvInstId = execution.getVariable("serviceInstanceId") - def aicCloudRegion = execution.getVariable("cloudSiteId") - def cloudOwner = execution.getVariable("cloudOwner") - def vnfId = execution.getVariable("vnfId") - def vfModuleId = execution.getVariable("vfModuleId") - def vfModuleStackId = execution.getVariable('DDVMFV_heatStackId') - def tenantId = execution.getVariable("tenantId") - def messageId = execution.getVariable('requestId') + '-' + - System.currentTimeMillis() - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) - def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) - if ('true'.equals(useQualifiedHostName)) { - notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) - } - - String request = """ + + logger.debug("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(DelegateExecution execution, String response, String method){ + + execution.setVariable("prefix",Prefix) + logger.trace("STARTED ValidateSDNCResponse Process") + + WorkflowException workflowException = execution.getVariable("WorkflowException") + boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") + + logger.debug("workflowException: " + workflowException) + + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) + + logger.debug("SDNCResponse: " + response) + + String sdncResponse = response + if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ + logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse) + }else{ + logger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.") + throw new BpmnError("MSOWorkflowException") + } + logger.trace("COMPLETED ValidateSDNCResponse Process") + } + + + // parse the incoming DELETE_VF_MODULE request + // and formulate the outgoing VnfAdapterDeleteV1 request + public void prepVNFAdapterRequest(DelegateExecution execution) { + + def requestId = UUID.randomUUID().toString() + def origRequestId = execution.getVariable('requestId') + def srvInstId = execution.getVariable("serviceInstanceId") + def aicCloudRegion = execution.getVariable("cloudSiteId") + def cloudOwner = execution.getVariable("cloudOwner") + def vnfId = execution.getVariable("vnfId") + def vfModuleId = execution.getVariable("vfModuleId") + def vfModuleStackId = execution.getVariable('DDVMFV_heatStackId') + def tenantId = execution.getVariable("tenantId") + def messageId = execution.getVariable('requestId') + '-' + + System.currentTimeMillis() + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) + if ('true'.equals(useQualifiedHostName)) { + notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) + } + + String request = """ <deleteVfModuleRequest> <cloudSiteId>${MsoUtils.xmlEscape(aicCloudRegion)}</cloudSiteId> <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner> @@ -396,126 +396,126 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { </deleteVfModuleRequest> """ as String - logger.debug("vnfAdapterRestV1Request: " + request) - logger.debug("deleteVfModuleRequest: " + request) - execution.setVariable("vnfAdapterRestV1Request", request) - } - - - // generates a WorkflowException if - // - - public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "AAI error occurred deleting the Generic Vnf: " + execution.getVariable("DDVFMV_deleteGenericVnfResponse"), - "BPMN", ErrorCode.UnknownError.getValue(), "Exception"); - String processKey = getProcessKey(execution); - WorkflowException exception = new WorkflowException(processKey, 5000, - execution.getVariable("DDVFMV_deleteGenericVnfResponse")) - execution.setVariable("WorkflowException", exception) - } - - public void postProcessVNFAdapterRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + - 'execution=' + execution.getId() + - ')' - - logger.trace('Entered ' + method) - execution.setVariable("prefix",Prefix) - try{ - logger.trace("STARTED postProcessVNFAdapterRequest Process") - - String vnfResponse = execution.getVariable("DDVMFV_doDeleteVfModuleResponse") - logger.debug("VNF Adapter Response is: " + vnfResponse) - logger.debug("deleteVnfAResponse is: \n" + vnfResponse) - - if(vnfResponse != null){ - - if(vnfResponse.contains("deleteVfModuleResponse")){ - logger.debug("Received a Good Response from VNF Adapter for DELETE_VF_MODULE Call.") - execution.setVariable("DDVFMV_vnfVfModuleDeleteCompleted", true) - - // Parse vnfOutputs for contrail network polcy FQDNs - def vfModuleOutputsXml = utils.getNodeXml(vnfResponse, "vfModuleOutputs") - if(!isBlank(vfModuleOutputsXml)) { - vfModuleOutputsXml = utils.removeXmlNamespaces(vfModuleOutputsXml) - List contrailNetworkPolicyFqdnList = [] - for(Node node: utils.getMultNodeObjects(vfModuleOutputsXml, "entry")) { - String key = utils.getChildNodeText(node, "key") - if(key == null) { - - } else if (key.endsWith("contrail_network_policy_fqdn")) { - String contrailNetworkPolicyFqdn = utils.getChildNodeText(node, "value") - logger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn) - contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn) - } - else if (key.equals("oam_management_v4_address")) { - String oamManagementV4Address = utils.getChildNodeText(node, "value") - logger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address) - execution.setVariable(Prefix + "oamManagementV4Address", oamManagementV4Address) - } - else if (key.equals("oam_management_v6_address")) { - String oamManagementV6Address = utils.getChildNodeText(node, "value") - logger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address) - execution.setVariable(Prefix + "oamManagementV6Address", oamManagementV6Address) - } - } - if (!contrailNetworkPolicyFqdnList.isEmpty()) { - logger.debug("Setting the fqdn list") - execution.setVariable("DDVFMV_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList) - } - } - }else{ - logger.debug("Received a BAD Response from VNF Adapter for DELETE_VF_MODULE Call.") - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") - } - }else{ - logger.debug("Response from VNF Adapter is Null for DELETE_VF_MODULE Call.") - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter") - } - - }catch(BpmnError b){ - throw b - }catch(Exception e){ - logger.debug("Internal Error Occured in PostProcess Method") - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method") - } - logger.trace("COMPLETED postProcessVnfAdapterResponse Process") - } - - public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + - 'execution=' + execution.getId() + - ')' - - logger.trace('Entered ' + method) - execution.setVariable("prefix", Prefix) - logger.trace("STARTED deleteNetworkPoliciesFromAAI ") - - try { - // get variables - List fqdnList = execution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList") - if (fqdnList == null) { - logger.debug("No network policies to delete") - return - } - int fqdnCount = fqdnList.size() - - execution.setVariable("DDVFMV_networkPolicyFqdnCount", fqdnCount) - logger.debug("DDVFMV_networkPolicyFqdnCount - " + fqdnCount) - - AaiUtil aaiUriUtil = new AaiUtil(this) - - if (fqdnCount > 0) { - // AII loop call over contrail network policy fqdn list - for (i in 0..fqdnCount-1) { - - int counting = i+1 - String fqdn = fqdnList[i] - - // Query AAI for this network policy FQDN + + logger.debug("deleteVfModuleRequest: " + request) + execution.setVariable("vnfAdapterTaskRequest", request) + } + + + // generates a WorkflowException if + // - + public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "AAI error occurred deleting the Generic Vnf: " + execution.getVariable("DDVFMV_deleteGenericVnfResponse"), + "BPMN", ErrorCode.UnknownError.getValue(), "Exception"); + String processKey = getProcessKey(execution); + WorkflowException exception = new WorkflowException(processKey, 5000, + execution.getVariable("DDVFMV_deleteGenericVnfResponse")) + execution.setVariable("WorkflowException", exception) + } + + public void postProcessVNFAdapterRequest(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + + 'execution=' + execution.getId() + + ')' + + logger.trace('Entered ' + method) + execution.setVariable("prefix",Prefix) + try{ + logger.trace("STARTED postProcessVNFAdapterRequest Process") + + String vnfResponse = execution.getVariable("DDVMFV_doDeleteVfModuleResponse") + logger.debug("VNF Adapter Response is: " + vnfResponse) + logger.debug("deleteVnfAResponse is: \n" + vnfResponse) + + if(vnfResponse != null){ + + if(vnfResponse.contains("deleteVfModuleResponse")){ + logger.debug("Received a Good Response from VNF Adapter for DELETE_VF_MODULE Call.") + execution.setVariable("DDVFMV_vnfVfModuleDeleteCompleted", true) + + // Parse vnfOutputs for contrail network polcy FQDNs + def vfModuleOutputsXml = utils.getNodeXml(vnfResponse, "vfModuleOutputs") + if(!isBlank(vfModuleOutputsXml)) { + vfModuleOutputsXml = utils.removeXmlNamespaces(vfModuleOutputsXml) + List contrailNetworkPolicyFqdnList = [] + for(Node node: utils.getMultNodeObjects(vfModuleOutputsXml, "entry")) { + String key = utils.getChildNodeText(node, "key") + if(key == null) { + + } else if (key.endsWith("contrail_network_policy_fqdn")) { + String contrailNetworkPolicyFqdn = utils.getChildNodeText(node, "value") + logger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn) + contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn) + } + else if (key.equals("oam_management_v4_address")) { + String oamManagementV4Address = utils.getChildNodeText(node, "value") + logger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address) + execution.setVariable(Prefix + "oamManagementV4Address", oamManagementV4Address) + } + else if (key.equals("oam_management_v6_address")) { + String oamManagementV6Address = utils.getChildNodeText(node, "value") + logger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address) + execution.setVariable(Prefix + "oamManagementV6Address", oamManagementV6Address) + } + } + if (!contrailNetworkPolicyFqdnList.isEmpty()) { + logger.debug("Setting the fqdn list") + execution.setVariable("DDVFMV_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList) + } + } + }else{ + logger.debug("Received a BAD Response from VNF Adapter for DELETE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") + } + }else{ + logger.debug("Response from VNF Adapter is Null for DELETE_VF_MODULE Call.") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter") + } + + }catch(BpmnError b){ + throw b + }catch(Exception e){ + logger.debug("Internal Error Occured in PostProcess Method") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method") + } + logger.trace("COMPLETED postProcessVnfAdapterResponse Process") + } + + public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + + 'execution=' + execution.getId() + + ')' + + logger.trace('Entered ' + method) + execution.setVariable("prefix", Prefix) + logger.trace("STARTED deleteNetworkPoliciesFromAAI ") + + try { + // get variables + List fqdnList = execution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList") + if (fqdnList == null) { + logger.debug("No network policies to delete") + return + } + int fqdnCount = fqdnList.size() + + execution.setVariable("DDVFMV_networkPolicyFqdnCount", fqdnCount) + logger.debug("DDVFMV_networkPolicyFqdnCount - " + fqdnCount) + + AaiUtil aaiUriUtil = new AaiUtil(this) + + if (fqdnCount > 0) { + // AII loop call over contrail network policy fqdn list + for (i in 0..fqdnCount-1) { + + int counting = i+1 + String fqdn = fqdnList[i] + + // Query AAI for this network policy FQDN AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) - uri.queryParam("network-policy-fqdn", fqdn) + uri.queryParam("network-policy-fqdn", fqdn) try { Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri) @@ -555,35 +555,35 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) } } // end loop - } else { - logger.debug("No contrail network policies to query/create") + } else { + logger.debug("No contrail network policies to query/create") - } + } + + } catch (BpmnError e) { + throw e; - } catch (BpmnError e) { - throw e; + } catch (Exception ex) { + String exceptionMessage = "Bpmn error encountered in DoDeletVfModule flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoDeletVfModule flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() - logger.debug(exceptionMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } + } - } - - // and formulate the outgoing DeleteAAIVfModuleRequest request - public void prepDeleteAAIVfModule(DelegateExecution execution) { + // and formulate the outgoing DeleteAAIVfModuleRequest request + public void prepDeleteAAIVfModule(DelegateExecution execution) { - def vnfId = execution.getVariable("vnfId") - def vfModuleId = execution.getVariable("vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<DeleteAAIVfModuleRequest> + def vnfId = execution.getVariable("vnfId") + def vfModuleId = execution.getVariable("vfModuleId") + // formulate the request for UpdateAAIVfModule + String request = """<DeleteAAIVfModuleRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> </DeleteAAIVfModuleRequest>""" as String - logger.debug("DeleteAAIVfModuleRequest :" + request) - - execution.setVariable("DeleteAAIVfModuleRequest", request) - } + logger.debug("DeleteAAIVfModuleRequest :" + request) + + execution.setVariable("DeleteAAIVfModuleRequest", request) + } } |