diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main')
18 files changed, 677 insertions, 977 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy index 2f4e70c893..8a262251b1 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy @@ -26,6 +26,7 @@ import javax.ws.rs.core.UriBuilder import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.client.aai.AAIVersion import org.onap.so.client.aai.entities.uri.AAIUri @@ -516,10 +517,10 @@ class AaiUtil { * @return moduleIndex * */ - public int getLowestUnusedVfModuleIndexFromAAIVnfResponse(DelegateExecution execution, String aaiVnfResponse, String key, String value) { + public int getLowestUnusedVfModuleIndexFromAAIVnfResponse(DelegateExecution execution, GenericVnf aaiVnfResponse, String key, String value) { if (aaiVnfResponse != null) { String vfModulesText = taskProcessor.utils.getNodeXml(aaiVnfResponse, "vf-modules") - if (vfModulesText == null || vfModulesText.isEmpty()) { + if (aaiVnfResponse.getVfModules() == null || aaiVnfResponse.getVfModules().getVfModule().isEmpty()) { msoLogger.debug("There are no VF modules in this VNF yet") return 0 } @@ -549,4 +550,3 @@ class AaiUtil { } } } - diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy index e4bc5f8fa2..bb557a8285 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -20,22 +20,25 @@ package org.onap.so.bpmn.common.scripts -import static org.apache.commons.lang3.StringUtils.*; +import org.onap.so.client.aai.entities.AAIResultWrapper + +import static org.apache.commons.lang3.StringUtils.isBlank; import javax.ws.rs.NotFoundException +import javax.ws.rs.core.UriBuilder -import org.apache.commons.lang3.* +import org.apache.commons.lang.StringUtils import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.so.bpmn.core.UrnPropertiesReader +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.AllottedResource import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.PreconditionFailedException +import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger -import org.onap.so.rest.APIResponse; @@ -68,7 +71,6 @@ class AllottedResourceUtils { String arType = execution.getVariable("allottedResourceType") String arRole = execution.getVariable("allottedResourceRole") String siXml = execution.getVariable("CSI_service") - String ar = null String orchStatus = null XmlParser xmlParser = new XmlParser() msoLogger.debug("getAROrchStatus siXml:" + siXml) @@ -84,9 +86,8 @@ class AllottedResourceUtils { msoLogger.debug("getARORchStatus AR found") def groovy.util.Node relatedLink = utils.getChildNode(relationship, 'related-link') if (relatedLink != null){ - ar = getARbyLink(execution, relatedLink.text(), arRole) - if (!isBlank(ar)) - { + Optional<AllottedResource> ar = getARbyLink(execution, relatedLink.text(), arRole) + if (ar.isPresent()){ orchStatus = execution.getVariable("aaiAROrchStatus") break } @@ -106,16 +107,21 @@ class AllottedResourceUtils { // get Allotted Resource by AllottedResourceId // used on Delete - called from doDeleteAR // setsVariable aaiARGetResponse - public String getARbyId (DelegateExecution execution, String allottedResourceId) { - msoLogger.trace("getARbyId ") - AAIResourceUri arLink = getARLinkbyId(execution, allottedResourceId) - String ar = null - if (!isBlank(arLink)) - { - ar = getARbyLink(execution, arLink, "") + public boolean ifExistsAR(DelegateExecution execution, String allottedResourceId) { + msoLogger.trace("ifExistsAR ") + try { + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri) + Optional<AllottedResource> allottedResource = wrapper.asBean(AllottedResource.class) + if(allottedResource.isPresent()) { + setExecutionVariables(execution , allottedResource.get(),resourceUri) + return true + }else { + return false + } + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in ifExistsAR" + e.getMessage()) } - msoLogger.trace(" Exit GetARbyId - AR:" + ar) - return ar; } public String getPSIFmARLink(DelegateExecution execution, String arLink) @@ -128,141 +134,62 @@ class AllottedResourceUtils { msoLogger.trace(" Exit getARLinkbyId - parentServiceInstanceId:" + siId ) return siId } - - // get Allotted Resource Link by AllottedResourceId using Nodes Query - // used on Delete - called from getARbyId - public String getARLinkbyId (DelegateExecution execution, String allottedResourceId) { - msoLogger.trace("getARLinkbyId ") - String arLink = null - try { - AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) - AaiUtil aaiUtil = new AaiUtil() - arLink = aaiUtil.createAaiUri(uri) - } catch (NotFoundException e) { - msoLogger.debug("GET AR received a Not Found (404) Response") - } catch(Exception e){ - msoLogger.debug(" Error encountered within GetAaiAR" + e.getMessage()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetARbyId" + e.getMessage()) - } - msoLogger.debug(" ***** Exit GetARLinkbyId ***** Link:" + arLink) - return arLink - } - + // get Allotted resource using Link // used on Create called from getARORchStatus - // used on Delete called from getARbyId + // used on Delete called from ifExistsAR // setsVariable aaiARPath - used for Patch in create - public String getARbyLink (DelegateExecution execution, String link, String role) { + + public Optional<AllottedResource> getARbyLink (DelegateExecution execution, String link, String role) { msoLogger.trace("getARbyLink ") - String ar = null - String arUrl = null + Optional<AllottedResource> allottedResource = Optional.empty() try { - AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String arEndpoint = "" - - if(!isBlank(link)) { - msoLogger.debug("Incoming AR Resource Link is: " + link) - String[] split = link.split("/aai/") - arEndpoint = "/aai/" + split[1] - } - - arUrl = "${aai_endpoint}" + arEndpoint - - msoLogger.debug("GET AR Aai Path is: \n" + arUrl) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, arUrl) - int responseCode = response.getStatusCode() - msoLogger.debug(" GET AR response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - msoLogger.debug("GET AR:" + aaiResponse) - if(responseCode == 200 || responseCode == 202){ - msoLogger.debug("GET AR Received a Good Response Code") - if(utils.nodeExists(aaiResponse, "allotted-resource")){ - if (!isBlank(role)) - { - if (utils.nodeExists(aaiResponse, "role") && role.equals(utils.getNodeText(aaiResponse, "role"))) { - ar = aaiResponse - }else{ - msoLogger.debug("AAI AR does not match input role:" + role) - } - } - else - { - ar = aaiResponse + msoLogger.debug("GET AR Aai Path is: \n" + link) + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(link).build()) + allottedResource = getAAIClient().get(AllottedResource.class,uri); + if(allottedResource.isPresent()) { + if (!isBlank(role)) { + if (role == allottedResource.get().getRole()) { + setExecutionVariables(execution,allottedResource.get(),uri) + } else { + msoLogger.debug("AAI AR does not match input role:" + role) } + } else { + setExecutionVariables(execution,allottedResource.get(),uri) } - else - { - msoLogger.debug("GET AR Does NOT Contain Data" ) - } - }else if(responseCode == 404){ + }else{ msoLogger.debug("GET AR received a Not Found (404) Response") } - else{ - msoLogger.debug(" GET AR received a Bad Response: \n" + aaiResponse) - buildAAIErrorResponse(execution, aaiResponse, "Error retrieving AR from AAI") - } }catch(Exception e){ msoLogger.debug(" Error encountered within GetAaiAR" + e.getMessage()) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetAaiAR" + e.getMessage()) } - if (!isBlank(ar)) - { - execution.setVariable("aaiARGetResponse", ar) - execution.setVariable("aaiARPath", arUrl) - - String resourceVersion = null - if (utils.nodeExists(ar, "resource-version")) { - resourceVersion = utils.getNodeText(ar, "resource-version") - execution.setVariable("aaiARResourceVersion", resourceVersion) - } + return allottedResource + } - String orchStatus = null - if (utils.nodeExists(ar, "orchestration-status")) { - orchStatus= utils.getNodeText(ar, "orchestration-status") - } - else - { - orchStatus = " " - } - execution.setVariable("aaiAROrchStatus", orchStatus) + public void setExecutionVariables(DelegateExecution execution, AllottedResource ar, AAIResourceUri arUrl) { + execution.setVariable("aaiARGetResponse", ar) + execution.setVariable("aaiARPath", arUrl.build().toString()) + execution.setVariable("aaiARResourceVersion", ar.getResourceVersion()) + if (StringUtils.isNotEmpty(ar.getOrchestrationStatus())) { + execution.setVariable("aaiAROrchStatus", ar.getOrchestrationStatus()) + } + else + { + execution.setVariable("aaiAROrchStatus", " ") } - msoLogger.trace(" Exit GetARbyLink - AR:" + ar) - return ar } public void updateAROrchStatus(DelegateExecution execution, String status, String aaiARPath){ msoLogger.trace("updaAROrchStatus ") try{ - String updateReq = """ - { - "orchestration-status": "${status}" - } - """ - + AllottedResource allottedResource = new AllottedResource(); + allottedResource.setOrchestrationStatus(status) msoLogger.debug('AAI AR URI: ' + aaiARPath) - AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) - APIResponse apiResponse = aaiUriUtil.executeAAIPatchCall(execution, aaiARPath, updateReq) - def aaiResponse = apiResponse.getResponseBodyAsString() - def responseCode = apiResponse.getStatusCode() - - msoLogger.debug("AAI Response Code: " + responseCode) - msoLogger.debug("AAI Response: " + aaiResponse) - if(responseCode == 200){ - msoLogger.debug("UpdateAR Good REST Response is: " + "\n" + aaiResponse) - }else{ - msoLogger.debug("UpdateAROrchStatus Bad REST Response!") - buildAAIErrorResponse(execution, aaiResponse, "Error updating AR OrchStatus in AAI") - } - - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException ") - throw b + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(aaiARPath).build()) + getAAIClient().update(uri,allottedResource) }catch(Exception e){ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in updateAR.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.getMessage()); exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error in updateAROrchStatus.' + e.getMessage()) @@ -274,39 +201,20 @@ class AllottedResourceUtils { public void deleteAR(DelegateExecution execution, String aaiARPath){ msoLogger.trace(" deleteAR - aaiARPath:" + aaiARPath) try { - AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) - APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, aaiARPath) - int responseCode = response.getStatusCode() - execution.setVariable("deleteARResponseCode", responseCode) - - msoLogger.debug(" Delete AR response code:" + responseCode) - String aaiResponse = response.getResponseBodyAsString() - execution.setVariable("aaiARDeleteResponse", aaiResponse) - - msoLogger.debug("Delete AR Response:" + aaiResponse) - - //Process Response - if(responseCode == 204){ - msoLogger.debug(" Delete AR Received a Good Response") - execution.setVariable("wasDeleted", "true") - }else if(responseCode == 404){ - msoLogger.debug(" Delete AR Received a Not Found (404) Response") - }else if(responseCode == 412){ - msoLogger.debug("Delete AR Received a Resource Version Mismatch Error: \n" + aaiResponse) - exceptionUtil.buildAndThrowWorkflowException(execution, 412, "DeleteAR Received a resource-version Mismatch Error Response from AAI") - }else{ - msoLogger.debug("Delete AR Received a BAD REST Response: \n" + aaiResponse) - buildAAIErrorResponse(execution, aaiResponse, "Error deleting AR in AAI") - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - } - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b + AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(aaiARPath).build()) + getAAIClient().delete(uri); + }catch(NotFoundException ex){ + msoLogger.debug(" Delete AR Received a Not Found (404) Response") + }catch(PreconditionFailedException ex){ + msoLogger.debug("Delete AR Received a Resource Version Mismatch Error: \n") + exceptionUtil.buildAndThrowWorkflowException(execution, 412, "DeleteAR Received a resource-version Mismatch Error Response from AAI") }catch(Exception e){ msoLogger.debug(" Error encountered in deleteAR!" + e) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Delete AR") } + msoLogger.debug(" Delete AR Received a Good Response") + execution.setVariable("wasDeleted", "true") msoLogger.trace("Exit deleteAR ") } @@ -323,5 +231,9 @@ class AllottedResourceUtils { msoLogger.trace("Exit BuildAAIErrorResponse Process") throw new BpmnError("MSOWorkflowException") } + + public AAIResourcesClient getAAIClient(){ + return new AAIResourcesClient() + } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy index 13904c372d..47a4612672 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -20,27 +20,17 @@ package org.onap.so.bpmn.common.scripts -import org.onap.so.bpmn.core.UrnPropertiesReader - -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.rest.APIResponse -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.Node -import org.w3c.dom.NodeList -import org.xml.sax.InputSource -import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger +import org.onap.aai.domain.yang.VolumeGroup import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.Relationships import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger /** * Vnf Module Subflow for confirming the volume group belongs @@ -59,60 +49,26 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ public void preProcessRequest(DelegateExecution execution){ execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED Confirm Volume Group Tenant Subflow ") - String processKey = getProcessKey(execution); try{ msoLogger.trace("Started QueryAAIForVolumeGroup Process ") String volumeGroupId = execution.getVariable("volumeGroupId") String incomingGroupName = execution.getVariable("volumeGroupName") String incomingTenantId = execution.getVariable("tenantId") - def aicCloudRegion = execution.getVariable("aicCloudRegion") - - AaiUtil aaiUriUtil = new AaiUtil(this) + String aicCloudRegion = execution.getVariable("aicCloudRegion") AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) - String path = aaiUriUtil.createAaiUri(uri) - - APIResponse queryAAIForVolumeGroupResponse = aaiUriUtil.executeAAIGetCall(execution, path) - - def responseCode = queryAAIForVolumeGroupResponse.getStatusCode() - execution.setVariable("queryVolumeGroupResponseCode", responseCode) - String response = queryAAIForVolumeGroupResponse.getResponseBodyAsString() - - msoLogger.debug("ConfirmVolumeGroup Response: " + response) - msoLogger.debug("ConfirmVolumeGroup Response Code: " + responseCode) - - if(responseCode == 200 && response != null){ - execution.setVariable("queryAAIVolumeGroupResponse", response) - msoLogger.debug("QueryAAIForVolumeGroup Received a Good REST Response is: \n" + response) - + AAIResultWrapper wrapper = getAAIClient().get(uri); + Optional<VolumeGroup> volumeGroup = wrapper.asBean(VolumeGroup.class) + Optional<Relationships> relationships = wrapper.getRelationships() + if(volumeGroup.isPresent()){ + execution.setVariable("queryAAIVolumeGroupResponse", volumeGroup.get()) String volumeGroupTenantId = "" - InputSource source = new InputSource(new StringReader(response)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setNamespaceAware(true) - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document createVCERequestXml = docBuilder.parse(source) - NodeList nodeList = createVCERequestXml.getElementsByTagNameNS("*", "relationship") - for (int x = 0; x < nodeList.getLength(); x++) { - Node node = nodeList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String e = eElement.getElementsByTagNameNS("*", "related-to").item(0).getTextContent() - if(e.equals("tenant")){ - NodeList relationDataList = eElement.getElementsByTagNameNS("*", "relationship-data") - for (int d = 0; d < relationDataList.getLength(); d++) { - Node dataNode = relationDataList.item(d) - if (dataNode.getNodeType() == Node.ELEMENT_NODE) { - Element dElement = (Element) dataNode - String key = dElement.getElementsByTagNameNS("*", "relationship-key").item(0).getTextContent() - if(key.equals("tenant.tenant-id")){ - volumeGroupTenantId = dElement.getElementsByTagNameNS("*", "relationship-value").item(0).getTextContent() - } - } - } - } + if(relationships.isPresent()){ + List<AAIResourceUri> tenantUris = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT) + for (AAIResourceUri tenantURI: tenantUris){ + volumeGroupTenantId = tenantURI.getURIKeys().get("tenant-id") } } - //Determine if Tenant Ids match if(incomingTenantId.equals(volumeGroupTenantId)){ msoLogger.debug("Tenant Ids Match") @@ -123,7 +79,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ } //Determine if Volume Group Names match - String volumeGroupName = utils.getNodeText(response, "volume-group-name") + String volumeGroupName = volumeGroup.get().getVolumeGroupName() if(incomingGroupName == null || incomingGroupName.length() < 1){ msoLogger.debug("Incoming Volume Group Name is NOT Provided.") execution.setVariable("groupNamesMatch", true) @@ -145,7 +101,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ }catch(BpmnError b){ throw b }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing queryAAIForVolumeGroup.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing queryAAIForVolumeGroup.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.getMessage()); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in preProcessRequest.") } msoLogger.trace("COMPLETED queryAAIForVolumeGroup Process ") @@ -156,8 +112,8 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ try{ msoLogger.trace("Started assignVolumeHeatId Process ") - String response = execution.getVariable("queryAAIVolumeGroupResponse") - String heatStackId = utils.getNodeText(response, "heat-stack-id") + VolumeGroup volumeGroup = execution.getVariable("queryAAIVolumeGroupResponse") + String heatStackId = volumeGroup.getHeatStackId() execution.setVariable("volumeHeatStackId", heatStackId) execution.setVariable("ConfirmVolumeGroupTenantResponse", heatStackId) // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy index d4777e234c..48268464d8 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -20,22 +20,24 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.core.RollbackData +import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.db.catalog.beans.OrchestrationStatus import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger -import org.onap.so.rest.APIResponse public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateAAIVfModule.class); - def Prefix="CAAIVfMod_" + def prefix="CAAIVfMod_" ExceptionUtil exceptionUtil = new ExceptionUtil() public void initProcessVariables(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) + execution.setVariable("prefix",prefix) execution.setVariable("CAAIVfMod_vnfId",null) execution.setVariable("CAAIVfMod_vnfName",null) execution.setVariable("CAAIVfMod_vnfType",null) @@ -168,38 +170,26 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ // send a GET request to AA&I to retrieve the Generic VNF/VF Module information based on a Vnf Name // expect a 200 response with the information in the response body or a 404 if the Generic VNF does not exist public void queryAAIForGenericVnf(DelegateExecution execution) { - - AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri - def vnfId = execution.getVariable("CAAIVfMod_vnfId") def vnfName = execution.getVariable("CAAIVfMod_vnfName") - if (vnfId == null || vnfId.isEmpty()) { - uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "") + uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF) uri.queryParam("vnf-name", vnfName) } else { uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) } - uri.depth(Depth.ONE) - String endPoint = aaiUtil.createAaiUri(uri) - try { - msoLogger.debug("queryAAIForGenericVnf() endpoint-" + endPoint) - msoLogger.debug("invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint) - msoLogger.debug("CreateAAIVfModule sending GET call to AAI Endpoint: " + endPoint) - - APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) - def responseData = response.getResponseBodyAsString() - def statusCode = response.getStatusCode() - execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode", statusCode) - execution.setVariable("CAAIVfMod_queryGenericVnfResponse", responseData) - - msoLogger.debug("CreateAAIVfModule Response Code: " + statusCode) - msoLogger.debug("CreateAAIVfModule Response data: " + responseData) - msoLogger.debug("Response code:" + statusCode) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) + Optional<GenericVnf> genericVnfOp = getAAIClient().get(GenericVnf.class, uri) + if(genericVnfOp.isPresent()){ + execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode", 200) + execution.setVariable("CAAIVfMod_queryGenericVnfResponse", genericVnfOp.get()) + }else{ + execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode", 404) + execution.setVariable("CAAIVfMod_queryGenericVnfResponse", "Generic Vnf not Found!") + } } catch (Exception ex) { msoLogger.debug("Exception occurred while executing AAI GET:" + ex.getMessage()) exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in queryAAIForGenericVnf.") @@ -238,36 +228,20 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ def newVnfId = UUID.randomUUID().toString() execution.setVariable("CAAIVfMod_vnfId",newVnfId) - String payload = """<generic-vnf xmlns="${execution.getVariable("CAAIVfMod_aaiNamespace")}"> - <vnf-id>${MsoUtils.xmlEscape(newVnfId)}</vnf-id> - <vnf-name>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfName"))}</vnf-name> - <vnf-type>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfType"))}</vnf-type> - <service-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_serviceId"))}</service-id> - <orchestration-status>Active</orchestration-status> - <model-invariant-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfPersonaId"))}</model-invariant-id> - <model-version-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfPersonaVer"))}</model-version-id> - </generic-vnf>""" as String - execution.setVariable("CAAIVfMod_createGenericVnfPayload", payload) + GenericVnf genericVnf = new GenericVnf() + genericVnf.setVnfId(newVnfId) + genericVnf.setVnfName(execution.getVariable("CAAIVfMod_vnfName")) + genericVnf.setVnfType(execution.getVariable("CAAIVfMod_vnfType")) + genericVnf.setServiceId(execution.getVariable("CAAIVfMod_serviceId")) + genericVnf.setOrchestrationStatus(OrchestrationStatus.ACTIVE.toString()) + genericVnf.setModelInvariantId(execution.getVariable("CAAIVfMod_vnfPersonaId")) + genericVnf.setModelVersionId(execution.getVariable("CAAIVfMod_vnfPersonaVer")) try { - AaiUtil aaiUtil = new AaiUtil(this) AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, newVnfId) - String endPoint = aaiUtil.createAaiUri(uri) - - msoLogger.debug("createGenericVnf() endpoint-" + endPoint) - msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) - msoLogger.debug("Sending PUT call to AAI with Endpoint /n" + endPoint + " with payload /n" + payload) - - APIResponse response = aaiUtil.executeAAIPutCall(execution, endPoint, payload); - def responseData = response.getResponseBodyAsString() - def responseStatusCode = response.getStatusCode() - execution.setVariable("CAAIVfMod_createGenericVnfResponseCode", responseStatusCode) - execution.setVariable("CAAIVfMod_createGenericVnfResponse", responseData) - - msoLogger.debug("Response Code: " + responseStatusCode) - msoLogger.debug("Response Data: " + responseData) - msoLogger.debug("Response code:" + responseStatusCode) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) + getAAIClient().create(uri,genericVnf) + execution.setVariable("CAAIVfMod_createGenericVnfResponseCode", 201) + execution.setVariable("CAAIVfMod_createGenericVnfResponse", "Vnf Created") } catch (Exception ex) { ex.printStackTrace() msoLogger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage()) @@ -289,22 +263,8 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ int moduleIndex = 0 if (!isBaseModule) { - def aaiVnfResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") - AaiUtil aaiUtil = new AaiUtil(this) - def personaModelId = execution.getVariable("CAAIVfMod_personaId") - - // Check if the response includes model-invariant-id or persona-model-id - // note: getRequiredNodeText() throws an exception if the field is missing - // need to retun a null for the subsequent "either/or" logic to work properly -// def modelInvariantId = getRequiredNodeText(execution, aaiVnfResponse,'model-invariant-id') - def modelInvariantId = getNodeText(aaiVnfResponse,'model-invariant-id', null) - def fieldToCheck = 'model-invariant-id' - if (!modelInvariantId) { - fieldToCheck = 'persona-model-id' - } - - moduleIndex = aaiUtil.getLowestUnusedVfModuleIndexFromAAIVnfResponse(execution, aaiVnfResponse, - fieldToCheck, personaModelId) + GenericVnf aaiVnfResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") + moduleIndex = getLowestUnusedVfModuleIndexFromAAIVnfResponse(aaiVnfResponse,execution) } // if we get to this point, we may be about to create the Vf Module, @@ -318,38 +278,26 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ rollbackData.put("VFMODULE", "isBaseModule", isBaseModule.toString()) execution.setVariable("RollbackData", rollbackData) msoLogger.debug("RollbackData:" + rollbackData) - String payload = """<vf-module xmlns="${execution.getVariable("CAAIVfMod_aaiNamespace")}"> - <vf-module-id>${MsoUtils.xmlEscape(newModuleId)}</vf-module-id> - <vf-module-name>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_moduleName"))}</vf-module-name> - <model-invariant-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_personaId"))}</model-invariant-id> - <model-version-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_personaVer"))}</model-version-id> - <model-customization-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_modelCustomizationId"))}</model-customization-id> - <is-base-vf-module>${MsoUtils.xmlEscape(isBaseModule)}</is-base-vf-module> - <orchestration-status>PendingCreate</orchestration-status> - <module-index>${MsoUtils.xmlEscape(moduleIndex)}</module-index> - </vf-module>""" as String - execution.setVariable("CAAIVfMod_createVfModulePayload", payload) + + org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule() + vfModule.setVfModuleId(newModuleId) + vfModule.setVfModuleName(execution.getVariable("CAAIVfMod_moduleName")) + vfModule.setModelInvariantId(execution.getVariable("CAAIVfMod_personaId")) + vfModule.setModelVersionId(execution.getVariable("CAAIVfMod_personaVer")) + vfModule.setModelCustomizationId(execution.getVariable("CAAIVfMod_modelCustomizationId")) + vfModule.setIsBaseVfModule(isBaseModule) + vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_CREATE.toString()) + vfModule.setModuleIndex(moduleIndex) try { - - AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, newModuleId) - String endPoint = aaiUtil.createAaiUri(uri) - - msoLogger.debug("createVfModule() endpoint-" + endPoint) - msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) - msoLogger.debug("CreateAAIVfModule sending PUT call to AAI with endpoint /n" + endPoint + " with payload /n " + payload) - APIResponse response = aaiUtil.executeAAIPutCall(execution, endPoint, payload) - def responseData = response.getResponseBodyAsString() - def statusCode = response.getStatusCode() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, newModuleId) + getAAIClient().create(uri,vfModule) + def statusCode = 201 execution.setVariable("CAAIVfMod_createVfModuleResponseCode", statusCode) - execution.setVariable("CAAIVfMod_createVfModuleResponse", responseData) - - msoLogger.debug("Response code:" + statusCode) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) - msoLogger.debug("Response Code: " + statusCode) - msoLogger.debug("Response data: " + responseData) + execution.setVariable("CAAIVfMod_createVfModuleResponse", "Vf Module Created") + + // the base or add-on VF Module was successfully created, // add the module name to the rollback data and the response if (isOneOf(statusCode, 200, 201)) { @@ -384,26 +332,55 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ msoLogger.debug("CreateAAIVfModule Response /n " + responseOut) } } catch (Exception ex) { + execution.setVariable("CAAIVfMod_createVfModuleResponseCode", 500) + execution.setVariable("CAAIVfMod_createVfModuleResponse", ex.getMessage()) msoLogger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage()) exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in createVfModule.") } } - + + private int getLowestUnusedVfModuleIndexFromAAIVnfResponse(GenericVnf genericVnf,DelegateExecution execution){ + String personaModelId = execution.getVariable("CAAIVfMod_personaId") + if(genericVnf!=null && genericVnf.getVfModules()!= null && + !genericVnf.getVfModules().getVfModule().isEmpty()){ + Set<Integer> moduleIndices = new TreeSet<>() + for(org.onap.aai.domain.yang.VfModule vfModule in genericVnf.getVfModules().getVfModule()){ + if(genericVnf.getModelInvariantId()==null){ + if(vfModule.getPersonaModelVersion().equals(personaModelId) && vfModule.getModuleIndex()!=null) + moduleIndices.add(vfModule.getModuleIndex()) + }else{ + if(vfModule.getModelInvariantId().equals(personaModelId) && vfModule.getModuleIndex()!=null) + moduleIndices.add(vfModule.getModuleIndex()) + } + } + for(i in 0..moduleIndices.size()-1){ + if(moduleIndices.getAt(i) != i){ + return i; + } + } + return moduleIndices.size() + }else{ + return 0 + } + + } + // parses the output from the result from queryAAIForGenericVnf() to determine if the vf-module-name // requested for an Add-on VF Module does not already exist for the specified Generic VNF // also retrieves VNF name from AAI response for existing VNF public void parseForAddOnModule(DelegateExecution execution) { - def xml = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") - def vnfNameFromAAI = utils.getNodeText(xml, "vnf-name") + GenericVnf genericVnf = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") + def vnfNameFromAAI = genericVnf.getVnfName() execution.setVariable("CAAIVfMod_vnfNameFromAAI", vnfNameFromAAI) msoLogger.debug("Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI) def newModuleName = execution.getVariable("CAAIVfMod_moduleName") msoLogger.debug("VF Module to be added: " + newModuleName) - def qryModuleNameList = utils.getMultNodes(xml, "vf-module-name") execution.setVariable("CAAIVfMod_moduleExists", false) - if (qryModuleNameList != null) { - msoLogger.debug("Existing VF Module List: " + qryModuleNameList) - for (String qryModuleName : qryModuleNameList) { + if (genericVnf !=null && genericVnf.getVfModules()!=null && !genericVnf.getVfModules().getVfModule().isEmpty()) { + def qryModuleList = genericVnf.getVfModules().getVfModule() + msoLogger.debug("Existing VF Module List: " + qryModuleList) + for (org.onap.aai.domain.yang.VfModule qryModule : qryModuleList) { + def qryModuleName = qryModule.getVfModuleName() if (newModuleName.equals(qryModuleName)) { // a module with the requested name already exists - failure msoLogger.debug("VF Module " + qryModuleName + " already exists for Generic VNF " + vnfNameFromAAI) @@ -425,32 +402,32 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ // requested for an Add-on VF Module does not already exist for the specified Generic VNF; // also retrieves VNF name from AAI response for existing VNF public void parseForBaseModule(DelegateExecution execution) { - def xml = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") - def vnfNameFromAAI = utils.getNodeText(xml, "vnf-name") + GenericVnf genericVnf = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") + def vnfNameFromAAI = genericVnf.getVnfName() execution.setVariable("CAAIVfMod_vnfNameFromAAI", vnfNameFromAAI) msoLogger.debug("Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI) def newModuleName = execution.getVariable("CAAIVfMod_moduleName") msoLogger.debug("VF Module to be added: " + newModuleName) - def qryModuleNameList = utils.getMultNodes(xml, "vf-module-name") + def qryModuleList = genericVnf !=null ? genericVnf.getVfModules():null; execution.setVariable("CAAIVfMod_moduleExists", false) - if (qryModuleNameList != null) { - msoLogger.debug("Existing VF Module List: " + qryModuleNameList) - for (String qryModuleName : qryModuleNameList) { - if (newModuleName.equals(qryModuleName)) { + if (qryModuleList != null && !qryModuleList.getVfModule().isEmpty()) { + def qryModules = qryModuleList.getVfModule() + msoLogger.debug("Existing VF Module List: " + qryModules) + for (org.onap.aai.domain.yang.VfModule qryModule : qryModules) { + if (newModuleName.equals(qryModule.getVfModuleName())) { // a module with the requested name already exists - failure - msoLogger.debug("VF Module " + qryModuleName + " already exists for Generic VNF " + vnfNameFromAAI) + msoLogger.debug("VF Module " + qryModule.getVfModuleName() + " already exists for Generic VNF " + vnfNameFromAAI) execution.setVariable("CAAIVfMod_baseModuleConflict", true) execution.setVariable("CAAIVfMod_parseModuleResponse", - "VF Module " + qryModuleName + " already exists for Generic VNF " + vnfNameFromAAI) + "VF Module " + qryModule.getVfModuleName() + " already exists for Generic VNF " + vnfNameFromAAI) break } } } - def isBaseVfModuleList = utils.getMultNodes(xml, "is-base-vf-module") - if (isBaseVfModuleList != null && !execution.getVariable("CAAIVfMod_baseModuleConflict")) { - - for (String baseValue : isBaseVfModuleList) { - if (baseValue.equals("true")) { + if (qryModuleList != null && !qryModuleList.getVfModule().isEmpty() && !execution.getVariable("CAAIVfMod_baseModuleConflict")) { + def qryModules = qryModuleList.getVfModule() + for (org.onap.aai.domain.yang.VfModule qryModule : qryModules) { + if (qryModule.isBaseVfModule) { // a base module already exists in this VNF - failure msoLogger.debug("Base VF Module already exists for Generic VNF " + vnfNameFromAAI) execution.setVariable("CAAIVfMod_baseModuleConflict", true) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy index cc1be47029..075068513a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy @@ -22,12 +22,9 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.rest.APIResponse -import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { @@ -110,24 +107,17 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { try { def vnfId = execution.getVariable('CAAIVfModVG_vnfId') def vfModuleId = execution.getVariable('CAAIVfModVG_vfModuleId') - - AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) - String endPoint = aaiUtil.createAaiUri(uri) - try { - msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') - msoLogger.debug("aaiResponse GET TO AAI Endpoint: " + endPoint) - APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) - def responseData = response.getResponseBodyAsString() - execution.setVariable('CAAIVfModVG_getVfModuleResponseCode', response.getStatusCode()) - execution.setVariable('CAAIVfModVG_getVfModuleResponse', responseData) - - msoLogger.debug("CreateAAIVfModule Response Code: " + response.getStatusCode()) - msoLogger.debug("CreateAAIVfModule Response: " + response) - msoLogger.debug('Response code:' + response.getStatusCode()) - msoLogger.debug('Response:' + System.lineSeparator() + responseData) - } catch (Exception ex) { + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); + Optional<org.onap.aai.domain.yang.VfModule> vfModule = getAAIClient().get(org.onap.aai.domain.yang.VfModule.class, resourceUri) + if(vfModule.isPresent()){ + execution.setVariable('CAAIVfModVG_getVfModuleResponseCode', 200) + execution.setVariable('CAAIVfModVG_getVfModuleResponse', vfModule.get()) + }else{ + execution.setVariable('CAAIVfModVG_getVfModuleResponseCode', 404) + execution.setVariable('CAAIVfModVG_getVfModuleResponse', "VF-Module Not found!!") + } + }catch (Exception ex) { ex.printStackTrace() msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) execution.setVariable('CAAIVfModVG_getVfModuleResponseCode', 500) @@ -157,12 +147,10 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { try { def vnfId = execution.getVariable('CAAIVfModVG_vnfId') def vfModuleId = execution.getVariable('CAAIVfModVG_vfModuleId') - def vfModule = execution.getVariable('CAAIVfModVG_getVfModuleResponse') - def origRequest = execution.getVariable('CreateAAIVfModuleVolumeGroupRequest') - def Node vfModuleNode = xmlParser.parseText(vfModule) - + org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('CAAIVfModVG_getVfModuleResponse') + // Confirm resource-version is in retrieved VF Module - if (utils.getChildNode(vfModuleNode, 'resource-version') == null) { + if (vfModule.getResourceVersion() == null) { def msg = 'Can\'t update VF Module ' + vfModuleId + ' since \'resource-version\' is missing' msoLogger.error( msg); throw new Exception(msg) @@ -172,26 +160,16 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { def aicCloudRegion = execution.getVariable('CAAIVfModVG_aicCloudRegion') def cloudOwner = execution.getVariable('CAAIVfModVG_cloudOwner') def volumeGroupId = execution.getVariable('CAAIVfModVG_volumeGroupId') - def Node vgRelationshipNode = createVolumeGroupRelationshipNode(cloudOwner, aicCloudRegion, volumeGroupId) - insertVolumeGroupRelationshipNode(vfModuleNode, vgRelationshipNode) - def payload = utils.nodeToString(vfModuleNode) - AaiUtil aaiUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) - String endPoint = aaiUtil.createAaiUri(uri) - try { - msoLogger.debug("CreateAAIVfModuleVolume Sendind PUT to AAI Endpoint \n " + endPoint + " with payload \n " + payload) - msoLogger.debug('sending PUT to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload) - APIResponse response = aaiUtil.executeAAIPutCall(execution, endPoint, payload) - def responseData = response.getResponseBodyAsString() - execution.setVariable('CAAIVfModVG_updateVfModuleResponseCode', response.getStatusCode()) - execution.setVariable('CAAIVfModVG_updateVfModuleResponse', responseData) - - msoLogger.debug("CreateAAIVfModule Response code: " + response.getStatusCode()) - msoLogger.debug("CreateAAIVfModule Response: " + responseData) - msoLogger.debug('Response code:' + response.getStatusCode()) - msoLogger.debug('Response:' + System.lineSeparator() + responseData) + AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId,vfModuleId); + AAIResourceUri volumeGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, aicCloudRegion,volumeGroupId); + msoLogger.debug("Creating relationship between Vf Module: " + vfModuleUri.build().toString() + " and Volume Group: " + volumeGroupUri.build().toString()) + getAAIClient().connect(vfModuleUri,volumeGroupUri) + execution.setVariable('CAAIVfModVG_updateVfModuleResponseCode', 200) + execution.setVariable('CAAIVfModVG_updateVfModuleResponse', "Success") + msoLogger.debug("CreateAAIVfModule Response code: " + 200) + msoLogger.debug("CreateAAIVfModule Response: " + "Success") } catch (Exception ex) { ex.printStackTrace() msoLogger.debug('Exception occurred while executing AAI PUT:' + ex.getMessage()) @@ -206,72 +184,6 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage()) } } - - /** - * Construct a Volume Group relationship Node with the given AIC Cloud Region and - * Volume Group ID for insertion into a VF Module. - * - * @param aicCloudRegion Cloud Region ID to use in the Volume Group relationship - * @param volumeGroupId Volume Group ID to use in the Volume Group relationship - * @return a Node representing the new Volume Group relationship - */ - private Node createVolumeGroupRelationshipNode(String cloudOwner, String aicCloudRegion, String volumeGroupId) { - - def Node relatedTo = new Node(null, 'related-to', 'volume-group') - - def Node relationshipKeyCO = new Node(null, 'relationship-key', 'cloud-region.cloud-owner') - def Node relationshipValueCO = new Node(null, 'relationship-value', cloudOwner) - def Node relationshipDataCO = new Node(null, 'relationship-data') - relationshipDataCO.append(relationshipKeyCO) - relationshipDataCO.append(relationshipValueCO) - - def Node relationshipKeyCRI = new Node(null, 'relationship-key', 'cloud-region.cloud-region-id') - def Node relationshipValueCRI = new Node(null, 'relationship-value', aicCloudRegion) - def Node relationshipDataCRI = new Node(null, 'relationship-data') - relationshipDataCRI.append(relationshipKeyCRI) - relationshipDataCRI.append(relationshipValueCRI) - - def Node relationshipKeyVGI = new Node(null, 'relationship-key', 'volume-group.volume-group-id') - def Node relationshipValueVGI = new Node(null, 'relationship-value', volumeGroupId) - def Node relationshipDataVGI = new Node(null, 'relationship-data') - relationshipDataVGI.append(relationshipKeyVGI) - relationshipDataVGI.append(relationshipValueVGI) - - def Node volumeGroupRelationship = new Node(null, 'relationship') - volumeGroupRelationship.append(relatedTo) - volumeGroupRelationship.append(relationshipDataCO) - volumeGroupRelationship.append(relationshipDataCRI) - volumeGroupRelationship.append(relationshipDataVGI) - - return volumeGroupRelationship; - } - - /** - * Insert the given Volume Group relationship Node into the given VF Module. - * If the VF Module does NOT contain a relationship list: - * - Create a relationship list containing the Volume Group relationship and insert it into the VF Module - * If the VF Module contains a relationship list but not a Volume Group relationship: - * - Insert the the Volume Group relationship into the relationship lsit - * If the VF Module contains a relationship list and has a Volume Group relationship: - * - Replace the existing Volume Group relationship with the new one - * @param vfModuleNode - * @param volumeGroupRelationshipNode - */ - private void insertVolumeGroupRelationshipNode(Node vfModuleNode, Node volumeGroupRelationshipNode) { - def Node relationshipList = utils.getChildNode(vfModuleNode, 'relationship-list') - if (relationshipList == null) { - relationshipList = new Node(null, 'relationship-list') - relationshipList.append(volumeGroupRelationshipNode) - vfModuleNode.append(relationshipList) - } else { - def Node currVolumeGroupRelationshipNode = getCurrVolumeGroupRelationshipNode(relationshipList) - if (currVolumeGroupRelationshipNode == null) { - relationshipList.append(volumeGroupRelationshipNode) - } else { - currVolumeGroupRelationshipNode.replaceNode(volumeGroupRelationshipNode) - } - } - } /** * Find and return the value of the Volume Group ID for the specified VF Module. If diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy index 6da1f6d6ff..b8df241913 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy @@ -20,15 +20,11 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth -import org.onap.so.rest.APIResponse -import org.onap.so.rest.RESTClient; -import org.onap.so.rest.RESTConfig; import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger @@ -83,15 +79,16 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ AaiUtil aaiUriUtil = new AaiUtil(this) AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) uri.depth(Depth.ONE) - String endPoint = aaiUriUtil.createAaiUri(uri) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) - - msoLogger.debug('Response code:' + response.getStatusCode()) - msoLogger.debug('Response:' + response.getResponseBodyAsString()) + Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class, uri) + + if(genericVnf.isPresent()) { + execution.setVariable("DAAIVfMod_queryGenericVnfResponseCode", 200) + execution.setVariable("DAAIVfMod_queryGenericVnfResponse", genericVnf.get()) - execution.setVariable("DAAIVfMod_queryGenericVnfResponseCode", response.getStatusCode()) - execution.setVariable("DAAIVfMod_queryGenericVnfResponse", response.getResponseBodyAsString()) + }else{ + execution.setVariable("DAAIVfMod_queryGenericVnfResponseCode", 404) + execution.setVariable("DAAIVfMod_queryGenericVnfResponse", "Vnf Not Found!") + } } catch (Exception ex) { msoLogger.debug("Exception occurred while executing AAI GET:" + ex.getMessage()) @@ -106,20 +103,10 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ try { String vnfId = execution.getVariable("DAAIVfMod_vnfId") - String resourceVersion = execution.getVariable("DAAIVfMod_genVnfRsrcVer") - - AaiUtil aaiUriUtil = new AaiUtil(this) AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - uri.resourceVersion(resourceVersion) - String endPoint = aaiUriUtil.createAaiUri(uri) - - APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, endPoint) - - def responseData = response.getResponseBodyAsString() - execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", response.getStatusCode()) - execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", responseData) - msoLogger.debug("Response code:" + response.getStatusCode()) - msoLogger.debug("Response:" + System.lineSeparator() + responseData) + getAAIClient().delete(uri) + execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", 200) + execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", "Vnf Deleted") } catch (Exception ex) { ex.printStackTrace() msoLogger.debug("Exception occurred while executing AAI DELETE:" + ex.getMessage()) @@ -133,22 +120,12 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ try { String vnfId = execution.getVariable("DAAIVfMod_vnfId") String vfModuleId = execution.getVariable("DAAIVfMod_vfModuleId") - String resourceVersion = execution.getVariable("DAAIVfMod_vfModRsrcVer") - AaiUtil aaiUriUtil = new AaiUtil(this) AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) - uri.resourceVersion(resourceVersion) - String endPoint = aaiUriUtil.createAaiUri(uri) - - APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, endPoint) - - responseData = response.getResponseBodyAsString() - execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode", response.getStatusCode()) - execution.setVariable("DAAIVfMod_deleteVfModuleResponse", responseData) - msoLogger.debug("DeleteAAIVfModule - AAI Response" + responseData) - msoLogger.debug("Response code:" + response.getStatusCode()) - msoLogger.debug("Response:" + System.lineSeparator() + responseData) + getAAIClient().delete(uri) + execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode", 200) + execution.setVariable("DAAIVfMod_deleteVfModuleResponse", "Vf Module Deleted") } catch (Exception ex) { ex.printStackTrace() msoLogger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage()) @@ -160,88 +137,66 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // to be deleted exists for the specified Generic Vnf and if it is the Base Module, // there are no Add-on Modules present public void parseForVfModule(DelegateExecution execution) { - def xml = execution.getVariable("DAAIVfMod_queryGenericVnfResponse") - msoLogger.debug("DeleteAAIVfModule - queryGenericVnfResponse" + xml) + GenericVnf genericVnf = execution.getVariable("DAAIVfMod_queryGenericVnfResponse") def delModuleId = execution.getVariable("DAAIVfMod_vfModuleId") msoLogger.debug("Vf Module to be deleted: " + delModuleId) - List <String> qryModuleIdList = utils.getMultNodes(xml, "vf-module-id") - List <String> qryBaseModuleList = utils.getMultNodes(xml, "is-base-vf-module") - List <String> qryResourceVerList = utils.getMultNodes(xml, "resource-version") - execution.setVariable("DAAIVfMod_moduleExists", false) - execution.setVariable("DAAIVfMod_isBaseModule", false) - execution.setVariable("DAAIVfMod_isLastModule", false) - // - def isBaseVfModule = "false" - // loop through the Vf Module Ids looking for a match - if (qryModuleIdList != null && !qryModuleIdList.empty) { - msoLogger.debug("Existing Vf Module Id List: " + qryModuleIdList) - msoLogger.debug("Existing Vf Module Resource Version List: " + qryResourceVerList) - def moduleCntr = 0 - // the Generic Vnf resource-version in the 1st entry in the query response - execution.setVariable("DAAIVfMod_genVnfRsrcVer", qryResourceVerList[moduleCntr]) - for (String qryModuleId : qryModuleIdList) { - if (delModuleId.equals(qryModuleId)) { - // a Vf Module with the requested Id exists - execution.setVariable("DAAIVfMod_moduleExists", true) - // find the corresponding value for the is-base-vf-module field - isBaseVfModule = qryBaseModuleList[moduleCntr] - // find the corresponding value for the resource-version field - // note: the Generic Vnf entry also has a resource-version field, so - // add 1 to the index to get the corresponding Vf Module value - execution.setVariable("DAAIVfMod_vfModRsrcVer", qryResourceVerList[moduleCntr+1]) - msoLogger.debug("Match found for Vf Module Id " + qryModuleId + " for Generic Vnf Id " + execution.getVariable("DAAIVfMod_vnfId") + ", Base Module is " + isBaseVfModule + ", Resource Version is " + execution.getVariable("vfModRsrcVer")) - break - } - moduleCntr++ - } - } - - // determine if the module to be deleted is a Base Module and/or the Last Module - if (execution.getVariable("DAAIVfMod_moduleExists") == true) { - if (isBaseVfModule.equals("true") && qryModuleIdList.size() != 1) { - execution.setVariable("DAAIVfMod_parseModuleResponse", - "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + - execution.getVariable("DAAIVfMod_vnfId") + ": is Base Module, not Last Module") - execution.setVariable("DAAIVfMod_isBaseModule", true) - } else { - if (isBaseVfModule.equals("true") && qryModuleIdList.size() == 1) { - execution.setVariable("DAAIVfMod_parseModuleResponse", - "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + - execution.getVariable("DAAIVfMod_vnfId") + ": is Base Module and Last Module") - execution.setVariable("DAAIVfMod_isBaseModule", true) - execution.setVariable("DAAIVfMod_isLastModule", true) - } else { - if (qryModuleIdList.size() == 1) { - execution.setVariable("DAAIVfMod_parseModuleResponse", - "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + - execution.getVariable("DAAIVfMod_vnfId") + ": is Not Base Module, is Last Module") - execution.setVariable("DAAIVfMod_isLastModule", true) - } else { - execution.setVariable("DAAIVfMod_parseModuleResponse", - "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + - execution.getVariable("DAAIVfMod_vnfId") + ": is Not Base Module and Not Last Module") - } - } - } - msoLogger.debug(execution.getVariable("DAAIVfMod_parseModuleResponse")) - } else { // (execution.getVariable("DAAIVfMod_moduleExists") == false) - msoLogger.debug("Vf Module Id " + delModuleId + " does not exist for Generic Vnf Id " + execution.getVariable("DAAIVfMod_vnfId")) - execution.setVariable("DAAIVfMod_parseModuleResponse", - "Vf Module Id " + delModuleId + " does not exist for Generic Vnf Id " + - execution.getVariable("DAAIVfMod_vnfName")) - } + + execution.setVariable("DAAIVfMod_genVnfRsrcVer", genericVnf.getResourceVersion()) + + execution.setVariable("DAAIVfMod_moduleExists", false) + execution.setVariable("DAAIVfMod_isBaseModule", false) + execution.setVariable("DAAIVfMod_isLastModule", false) + if(genericVnf.getVfModules()!= null && !genericVnf.getVfModules().getVfModule().isEmpty()){ + Optional<org.onap.aai.domain.yang.VfModule> vfModule = genericVnf.getVfModules().getVfModule().stream(). + filter{ v -> v.getVfModuleId().equals(delModuleId)}.findFirst() + if(vfModule.isPresent()){ + execution.setVariable("DAAIVfMod_moduleExists", true) + execution.setVariable("DAAIVfMod_vfModRsrcVer", vfModule.get().getResourceVersion()) + + if (vfModule.get().isBaseVfModule && genericVnf.getVfModules().getVfModule().size() != 1) { + execution.setVariable("DAAIVfMod_parseModuleResponse", + "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfId") + ": is Base Module, not Last Module") + execution.setVariable("DAAIVfMod_isBaseModule", true) + } else { + if (vfModule.get().isBaseVfModule && genericVnf.getVfModules().getVfModule().size() == 1) { + execution.setVariable("DAAIVfMod_parseModuleResponse", + "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfId") + ": is Base Module and Last Module") + execution.setVariable("DAAIVfMod_isBaseModule", true) + execution.setVariable("DAAIVfMod_isLastModule", true) + } else { + if (genericVnf.getVfModules().getVfModule().size() == 1) { + execution.setVariable("DAAIVfMod_parseModuleResponse", + "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfId") + ": is Not Base Module, is Last Module") + execution.setVariable("DAAIVfMod_isLastModule", true) + } else { + execution.setVariable("DAAIVfMod_parseModuleResponse", + "Found Vf Module Id " + delModuleId + " for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfId") + ": is Not Base Module and Not Last Module") + } + } + } + msoLogger.debug(execution.getVariable("DAAIVfMod_parseModuleResponse")) + } + } + if (execution.getVariable("DAAIVfMod_moduleExists") == false) { // (execution.getVariable("DAAIVfMod_moduleExists") == false) + msoLogger.debug("Vf Module Id " + delModuleId + " does not exist for Generic Vnf Id " + execution.getVariable("DAAIVfMod_vnfId")) + execution.setVariable("DAAIVfMod_parseModuleResponse", + "Vf Module Id " + delModuleId + " does not exist for Generic Vnf Id " + + execution.getVariable("DAAIVfMod_vnfName")) + } } // parses the output from the result from queryAAIForGenericVnf() to determine if the Vf Module // to be deleted exists for the specified Generic Vnf and if it is the Base Module, // there are no Add-on Modules present public void parseForResourceVersion(DelegateExecution execution) { - def xml = execution.getVariable("DAAIVfMod_queryGenericVnfResponse") - msoLogger.debug("DeleteAAIVfModule - queryGenericVnfResponse" + xml) - String resourceVer = utils.getNodeText(xml, "resource-version") - execution.setVariable("DAAIVfMod_genVnfRsrcVer", resourceVer) - msoLogger.debug("Latest Generic VNF Resource Version: " + resourceVer) + GenericVnf genericVnf = execution.getVariable("DAAIVfMod_queryGenericVnfResponse") + execution.setVariable("DAAIVfMod_genVnfRsrcVer", genericVnf.getResourceVersion()) + msoLogger.debug("Latest Generic VNF Resource Version: " + genericVnf.getResourceVersion()) } @@ -303,4 +258,4 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "AAI error occurred deleting the Generic Vnf", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, execution.getVariable("DAAIVfMod_deleteGenericVnfResponse")); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, execution.getVariable("DAAIVfMod_deleteGenericVnfResponse")) } -}
\ No newline at end of file +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy index 1e8569c3e7..a1e63dc150 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy @@ -18,31 +18,24 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.scripts; +package org.onap.so.bpmn.common.scripts -import javax.ws.rs.core.UriBuilder -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory -import javax.xml.transform.Transformer -import javax.xml.transform.TransformerFactory -import javax.xml.transform.dom.DOMSource -import javax.xml.transform.stream.StreamResult - -import org.apache.commons.lang3.* +import groovy.xml.XmlUtil import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.client.aai.AAIObjectType -import org.onap.so.client.aai.entities.uri.AAIResourceUri -import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MsoLogger import org.w3c.dom.Document import org.w3c.dom.Element import org.w3c.dom.Node -import org.w3c.dom.NodeList; +import org.w3c.dom.NodeList import org.xml.sax.InputSource -import groovy.xml.XmlUtil - +import javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory +import javax.xml.transform.Transformer +import javax.xml.transform.TransformerFactory +import javax.xml.transform.dom.DOMSource +import javax.xml.transform.stream.StreamResult /** * This groovy class supports the any Network processes that need the methods defined here. @@ -318,46 +311,6 @@ class NetworkUtils { return requestPayload } - - def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudOwner, cloudRegion, namespace, modelCustomizationId) { - - String requestPayload = - """<volume-group xmlns="${namespace}"> - <volume-group-id>${MsoUtils.xmlEscape(groupId)}</volume-group-id> - <volume-group-name>${MsoUtils.xmlEscape(volumeName)}</volume-group-name> - <heat-stack-id></heat-stack-id> - <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> - <orchestration-status>Pending</orchestration-status> - <vf-module-model-customization-id>${MsoUtils.xmlEscape(modelCustomizationId)}</vf-module-model-customization-id> - <relationship-list> - <relationship> - <related-to>generic-vnf</related-to> - <relationship-data> - <relationship-key>generic-vnf.vnf-id</relationship-key> - <relationship-value>${MsoUtils.xmlEscape(vnfId)}</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>tenant</related-to> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>${MsoUtils.xmlEscape(tenantId)}</relationship-value> - </relationship-data> - <relationship-data> - <relationship-key>cloud-region.cloud-owner</relationship-key> - <relationship-value>${cloudOwner}</relationship-value> - </relationship-data> - <relationship-data> - <relationship-key>cloud-region.cloud-region-id</relationship-key> - <relationship-value>${MsoUtils.xmlEscape(cloudRegion)}</relationship-value> - </relationship-data> - </relationship> - </relationship-list> - </volume-group>""" - - return requestPayload - } - /** * This method returns the string for Update Volume Request payload @@ -783,68 +736,7 @@ class NetworkUtils { return rtn } - def isVfRelationshipExist(xmlInput) { - Boolean rtn = false - if (xmlInput!=null) { - def relationshipList = getListWithElements(xmlInput, 'relationship') - def relationshipListSize = relationshipList.size() - if (relationshipListSize > 0) { - for (i in 0..relationshipListSize-1) { - def relationshipXml = XmlUtil.serialize(relationshipList[i]) - if (utils.getNodeText(relationshipXml, 'related-to') == "vf-module") { - rtn = true - } - } - } - } - return rtn - - } - - def getCloudRegion(xmlInput) { - String lcpCloudRegion = "" - if (xmlInput!=null) { - def relationshipList = getListWithElements(xmlInput, 'relationship') - def relationshipListSize = relationshipList.size() - if (relationshipListSize > 0) { - for (i in 0..relationshipListSize-1) { - def relationshipXml = XmlUtil.serialize(relationshipList[i]) - if (utils.getNodeText(relationshipXml, 'related-to') == "cloud-region") { - def relatedLink = utils.getNodeText(relationshipXml, 'related-link') - if (relatedLink != null || relatedLink != "") { - AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.CLOUD_REGION, UriBuilder.fromUri(relatedLink).build()) - lcpCloudRegion = aaiUri.getURIKeys().getOrDefault("cloud-region", "") - } - } - } - } - } - return lcpCloudRegion - } - - def getTenantId(xmlInput) { - String tenantId = "" - if (xmlInput!=null) { - def relationshipList = getListWithElements(xmlInput, 'relationship') - def relationshipListSize = relationshipList.size() - if (relationshipListSize > 0) { - for (i in 0..relationshipListSize-1) { - def relationshipXml = XmlUtil.serialize(relationshipList[i]) - if (utils.getNodeText(relationshipXml, 'related-to') == "tenant") { - def relatedLink = utils.getNodeText(relationshipXml, 'related-link') - if (relatedLink != null || relatedLink != "") { - tenantId = relatedLink.substring(relatedLink.indexOf("/tenant/")+8, relatedLink.length()) - if (tenantId.contains('/')) { - tenantId = relatedLink.substring(relatedLink.indexOf("/tenant/")+8, relatedLink.length()-1) - } - } - } - } - } - } - return tenantId - } - + def isInstanceValueMatch(linkResource, globalSubscriberId, serviceType) { Boolean rtn = false try { diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy index 58c8f27de9..32d1ee74bf 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy @@ -20,9 +20,9 @@ package org.onap.so.bpmn.common.scripts; -import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.L3Network import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils; import org.springframework.web.util.UriUtils @@ -495,7 +495,7 @@ class SDNCAdapterUtils { * @param additionalData additional XML content to be inserted into the * RequestData element (may be null) */ - public String sdncTopologyRequestV2 (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String queryAAIResponse, String additionalData) { + public String sdncTopologyRequestV2 (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, L3Network queryAAIResponse, String additionalData) { def utils=new MsoUtils() // SNDC is expecting request Id for header as unique each call. @@ -526,7 +526,7 @@ class SDNCAdapterUtils { // Replace/Use the value of network-type from aai query (vs input) during Delete Network flows. if (queryAAIResponse != null) { - networkType = utils.getNodeText(queryAAIResponse, "network-type") + networkType = queryAAIResponse.getNetworkType() } String serviceId = "" @@ -536,7 +536,7 @@ class SDNCAdapterUtils { String networkName = "" // Replace/Use the value of network-name from aai query (vs input) if it was already set in AAI if (queryAAIResponse != null) { - networkName = utils.getNodeText(queryAAIResponse, "network-name") + networkName = queryAAIResponse.getNetworkName() } if (networkName.isEmpty() && utils.nodeExists(requestXML, "network-name")) { networkName = utils.getNodeText(requestXML, "network-name") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index 3e7c4f2d49..5eb72bb2f2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -22,14 +22,12 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth -import org.onap.so.rest.APIResponse -import org.springframework.web.util.UriUtils import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger @@ -37,7 +35,7 @@ import org.onap.so.logger.MsoLogger public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateAAIGenericVnf.class); + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateAAIGenericVnf.class) private XmlParser xmlParser = new XmlParser() @@ -109,9 +107,9 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { msoLogger.trace('Exited ' + method) } catch (BpmnError e) { - throw e; + throw e } catch (Exception e) { - msoLogger.error(e); + msoLogger.error(e) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) } } @@ -131,34 +129,26 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { try { def vnfId = execution.getVariable('UAAIGenVnf_vnfId') - // Construct endpoint - AaiUtil aaiUriUtil = new AaiUtil(this) AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) uri.depth(Depth.ONE) - String endPoint = aaiUriUtil.createAaiUri(uri) - try { - msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') - msoLogger.debug("Sending GET to AAI endpoint: " + endPoint) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) - def responseData = response.getResponseBodyAsString() - execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode', response.getStatusCode()) - execution.setVariable('UAAIGenVnf_getGenericVnfResponse', responseData) - msoLogger.debug("UpdateAAIGenericVnf Response data: " + responseData) - msoLogger.debug('Response code:' + response.getStatusCode()) - msoLogger.debug('Response:' + System.lineSeparator() + responseData) - } catch (Exception ex) { - msoLogger.error(e); + Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri) + if(genericVnf.isPresent()){ + execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode', 200) + execution.setVariable('UAAIGenVnf_getGenericVnfResponse', genericVnf.get()) + }else{ + execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode', 404) + execution.setVariable('UAAIGenVnf_getGenericVnfResponse', "Generic VNF not found for VNF ID: "+vnfId) + } + }catch (Exception ex) { + msoLogger.error(ex.getMessage()) msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode', 500) execution.setVariable('UAAIGenVnf_getGenericVnfResponse', 'AAI GET Failed:' + ex.getMessage()) } msoLogger.trace('Exited ' + method) - } catch (BpmnError e) { - throw e; } catch (Exception e) { - msoLogger.error(e); + msoLogger.error(e) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getGenericVnf(): ' + e.getMessage()) } } @@ -176,38 +166,19 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { try { def vnfId = execution.getVariable('UAAIGenVnf_vnfId') - def genericVnf = execution.getVariable('UAAIGenVnf_getGenericVnfResponse') + GenericVnf genericVnf = execution.getVariable('UAAIGenVnf_getGenericVnfResponse') def origRequest = execution.getVariable('UpdateAAIGenericVnfRequest') msoLogger.debug("UpdateGenericVnf Request: " + origRequest) - // Confirm resource-version is in retrieved Generic VNF - def Node genericVnfNode = xmlParser.parseText(genericVnf) - if (utils.getChildNode(genericVnfNode, 'resource-version') == null) { - def msg = 'Can\'t update Generic VNF ' + vnfId + ' since \'resource-version\' is missing' - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - throw new Exception(msg) - } - // Handle persona-model-id/persona-model-version - def String newPersonaModelId = execution.getVariable('UAAIGenVnf_personaModelId') - def String newPersonaModelVersion = execution.getVariable('UAAIGenVnf_personaModelVersion') - def String personaModelVersionEntry = "" + String newPersonaModelId = execution.getVariable('UAAIGenVnf_personaModelId') + String newPersonaModelVersion = execution.getVariable('UAAIGenVnf_personaModelVersion') + String personaModelVersionEntry = "" if (newPersonaModelId != null || newPersonaModelVersion != null) { - - // Confirm "new" persona-model-id is same as "current" persona-model-id - def Node currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'model-invariant-id') - if (currPersonaModelIdNode == null) { - // check the old attribute name - currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'persona-model-id') - } - def String currPersonaModelId = '' - if (currPersonaModelIdNode != null) { - currPersonaModelId = currPersonaModelIdNode.text() - } - if (!newPersonaModelId.equals(currPersonaModelId)) { + if (newPersonaModelId != genericVnf.getModelInvariantId()) { def msg = 'Can\'t update Generic VNF ' + vnfId + ' since there is \'persona-model-id\' mismatch between the current and new values' - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "") throw new Exception(msg) } @@ -216,24 +187,24 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { } // Handle ipv4-oam-address - def String ipv4OamAddress = execution.getVariable('UAAIGenVnf_ipv4OamAddress') - def String ipv4OamAddressEntry = "" + String ipv4OamAddress = execution.getVariable('UAAIGenVnf_ipv4OamAddress') + String ipv4OamAddressEntry = "" if (ipv4OamAddress != null) { // Construct payload ipv4OamAddressEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'ipv4-oam-address') } // Handle management-v6-address - def String managementV6Address = execution.getVariable('UAAIGenVnf_managementV6Address') - def String managementV6AddressEntry = "" + String managementV6Address = execution.getVariable('UAAIGenVnf_managementV6Address') + String managementV6AddressEntry = "" if (managementV6Address != null) { // Construct payload managementV6AddressEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'management-v6-address') } // Handle orchestration-status - def String orchestrationStatus = execution.getVariable('UAAIGenVnf_orchestrationStatus') - def String orchestrationStatusEntry = "" + String orchestrationStatus = execution.getVariable('UAAIGenVnf_orchestrationStatus') + String orchestrationStatusEntry = "" if (orchestrationStatus != null) { // Construct payload orchestrationStatusEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'orchestration-status') @@ -248,22 +219,10 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { } """ - // Construct endpoint - AaiUtil aaiUriUtil = new AaiUtil(this) AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - String endPoint = aaiUriUtil.createAaiUri(uri) try { - msoLogger.debug('sending PATCH to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload) - msoLogger.debug("Sending PATCH to AAI endpoint: " + endPoint) - - APIResponse response = aaiUriUtil.executeAAIPatchCall(execution, endPoint, payload) - def responseData = response.getResponseBodyAsString() - execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', response.getStatusCode()) - execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', responseData) - msoLogger.debug("UpdateAAIGenericVnf Response Data: " + responseData) - msoLogger.debug('Response code:' + response.getStatusCode()) - msoLogger.debug('Response:' + System.lineSeparator() + responseData) + getAAIClient().update(uri,payload) } catch (Exception ex) { ex.printStackTrace() msoLogger.debug('Exception occurred while executing AAI PATCH:' + ex.getMessage()) @@ -271,10 +230,8 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', 'AAI PATCH Failed:' + ex.getMessage()) } msoLogger.trace('Exited ' + method) - } catch (BpmnError e) { - throw e; } catch (Exception e) { - msoLogger.error(e); + msoLogger.error(e) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in updateGenericVnf(): ' + e.getMessage()) } } @@ -293,7 +250,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { } def elementValue = utils.getNodeText(origRequest, elementName) - if (elementValue.equals('DELETE')) { + if (elementValue == 'DELETE') { // Set the element being deleted to null return """"${elementName}": null,""" } @@ -314,8 +271,8 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { ')' msoLogger.trace('Entered ' + method) - msoLogger.error( 'Error occurred attempting to query AAI, Response Code ' + execution.getVariable('UAAIGenVnf_getGenericVnfResponseCode')); - String processKey = getProcessKey(execution); + msoLogger.error( 'Error occurred attempting to query AAI, Response Code ' + execution.getVariable('UAAIGenVnf_getGenericVnfResponseCode')) + String processKey = getProcessKey(execution) WorkflowException exception = new WorkflowException(processKey, 5000, execution.getVariable('UAAIGenVnf_getGenericVnfResponse')) execution.setVariable('WorkflowException', exception) @@ -335,9 +292,9 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { ')' msoLogger.trace('Entered ' + method) - msoLogger.error('Error occurred attempting to update Generic VNF in AAI, Response Code ' + execution.getVariable('UAAIGenVnf_updateGenericVnfResponseCode')); + msoLogger.error('Error occurred attempting to update Generic VNF in AAI, Response Code ' + execution.getVariable('UAAIGenVnf_updateGenericVnfResponseCode')) - String processKey = getProcessKey(execution); + String processKey = getProcessKey(execution) WorkflowException exception = new WorkflowException(processKey, 5000, execution.getVariable('UAAIGenVnf_updateGenericVnfResponse')) execution.setVariable('WorkflowException', exception) @@ -345,4 +302,4 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { msoLogger.debug("Workflow Exception occurred when Updating GenericVnf: " + exception.getErrorMessage()) msoLogger.trace('Exited ' + method) } -}
\ No newline at end of file +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy index c455ae90ce..6691a82352 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy @@ -20,21 +20,17 @@ package org.onap.so.bpmn.common.scripts +import javax.ws.rs.NotFoundException + import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.rest.APIResponse -import org.springframework.web.util.UriUtils -import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger - - public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateAAIVfModule.class); @@ -106,29 +102,21 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { try { def vnfId = execution.getVariable('UAAIVfMod_vnfId') def vfModuleId = execution.getVariable('UAAIVfMod_vfModuleId') - - AaiUtil aaiUriUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) - String endPoint = aaiUriUtil.createAaiUri(uri) - try { - msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') - msoLogger.debug("UpdateAAIVfModule sending GET to AAI endpoint: " + endPoint) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) - def responseData = response.getResponseBodyAsString() - execution.setVariable('UAAIVfMod_getVfModuleResponseCode', response.getStatusCode()) - execution.setVariable('UAAIVfMod_getVfModuleResponse', responseData) - msoLogger.debug('Response code:' + response.getStatusCode()) - msoLogger.debug('Response:' + System.lineSeparator() + responseData) - msoLogger.debug("UpdateAAIVfModule response data: " + responseData) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); + Optional<org.onap.aai.domain.yang.VfModule> vfModule = getAAIClient().get(org.onap.aai.domain.yang.VfModule.class, resourceUri) + if (vfModule.isPresent()) { + execution.setVariable('UAAIVfMod_getVfModuleResponseCode', 200) + execution.setVariable('UAAIVfMod_getVfModuleResponse', vfModule.get()) + } else { + execution.setVariable('UAAIVfMod_getVfModuleResponseCode', 404) + execution.setVariable('UAAIVfMod_getVfModuleResponse', "VF Module not found in AAI") + } } catch (Exception ex) { - ex.printStackTrace() msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) execution.setVariable('UAAIVfMod_getVfModuleResponseCode', 500) execution.setVariable('UAAIVfMod_getVfModuleResponse', 'AAI GET Failed:' + ex.getMessage()) } - msoLogger.trace('Exited ' + method) } catch (BpmnError e) { throw e; } catch (Exception e) { @@ -151,18 +139,10 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { try { def vnfId = execution.getVariable('UAAIVfMod_vnfId') def vfModuleId = execution.getVariable('UAAIVfMod_vfModuleId') - def vfModule = execution.getVariable('UAAIVfMod_getVfModuleResponse') + org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('UAAIVfMod_getVfModuleResponse') def origRequest = execution.getVariable('UpdateAAIVfModuleRequest') - def Node vfModuleNode = xmlParser.parseText(vfModule) - + msoLogger.debug("UpdateAAIVfModule request: " + origRequest) - // Confirm resource-version is in retrieved VF Module - if (utils.getChildNode(vfModuleNode, 'resource-version') == null) { - def msg = 'Can\'t update VF Module ' + vfModuleId + ' since \'resource-version\' is missing' - msoLogger.error(msg); - throw new Exception(msg) - } - // Handle persona-model-id/persona-model-version def boolean doPersonaModelVersion = true def String newPersonaModelId = utils.getNodeText(origRequest, 'persona-model-id') @@ -171,10 +151,10 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { doPersonaModelVersion = false } else { // Confirm "new" persona-model-id is same as "current" persona-model-id - def String currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'model-invariant-id') + def String currPersonaModelId = vfModule.getModelInvariantId() if (currPersonaModelId == null) { // check the old attribute name - currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'model-version-id') + currPersonaModelId = vfModule.getModelVersionId() } if (currPersonaModelId == null) { currPersonaModelId = '' @@ -187,13 +167,13 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { } // Construct payload - String orchestrationStatusEntry = updateVfModuleNode(origRequest, vfModuleNode, 'orchestration-status') - String heatStackIdEntry = updateVfModuleNode(origRequest, vfModuleNode, 'heat-stack-id') + String orchestrationStatusEntry = updateVfModuleNode(origRequest , 'orchestration-status') + String heatStackIdEntry = updateVfModuleNode(origRequest, 'heat-stack-id') String personaModelVersionEntry = "" if (doPersonaModelVersion) { - personaModelVersionEntry = updateVfModuleNode(origRequest, vfModuleNode, 'persona-model-version') + personaModelVersionEntry = updateVfModuleNode(origRequest, 'persona-model-version') } - String contrailServiceInstanceFqdnEntry = updateVfModuleNode(origRequest, vfModuleNode, 'contrail-service-instance-fqdn') + String contrailServiceInstanceFqdnEntry = updateVfModuleNode(origRequest, 'contrail-service-instance-fqdn') def payload = """ { ${orchestrationStatusEntry} ${heatStackIdEntry} @@ -203,28 +183,16 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { } """ - AaiUtil aaiUriUtil = new AaiUtil(this) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) - String endPoint = aaiUriUtil.createAaiUri(uri) - - try { - msoLogger.debug('sending PATCH to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload) - msoLogger.debug("Sending PATCH to AAI endpoint: " + endPoint) - - APIResponse response = aaiUriUtil.executeAAIPatchCall(execution, endPoint, payload) - def responseData = response.getResponseBodyAsString() - execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', response.getStatusCode()) - execution.setVariable('UAAIVfMod_updateVfModuleResponse', responseData) - msoLogger.debug("UpdateAAIVfModule Response data: " + responseData) - msoLogger.debug('Response code:' + response.getStatusCode()) - msoLogger.debug('Response:' + System.lineSeparator() + responseData) - } catch (Exception ex) { - ex.printStackTrace() - msoLogger.debug('Exception occurred while executing AAI PATCH:' + ex.getMessage()) - execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 500) - execution.setVariable('UAAIVfMod_updateVfModuleResponse', 'AAI PATCH Failed:' + ex.getMessage()) - } - msoLogger.trace('Exited ' + method) + try { + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + getAAIClient().update(resourceUri, payload) + }catch(NotFoundException ignored){ + msoLogger.debug("VF-Module not found!!") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "vf-module " + vfModuleId + " not found for under vnf " + vnfId + " in A&AI!") + } + catch(Exception ex){ + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'Exception occurred while executing AAI PATCH:' + ex.getMessage()) + } } catch (BpmnError e) { throw e; } catch (Exception e) { @@ -237,10 +205,9 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { * Sets up json attributes for PATCH request for Update * * @param origRequest Incoming update request with VF Module elements to be updated. - * @param vfModule Current VF Module retrieved from AAI. * @param element Name of element to be inserted. */ - private String updateVfModuleNode(String origRequest, Node vfModuleNode, String elementName) { + private String updateVfModuleNode(String origRequest, String elementName) { if (!utils.nodeExists(origRequest, elementName)) { return "" @@ -343,25 +310,4 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { msoLogger.debug("UpdateAAIVfModule query failure: " + exception.getErrorMessage()) msoLogger.trace('Exited ' + method) } - - /** - * Generates a WorkflowException if updating a VF Module in AAI returns a response code other than 200. - * - * @param execution The flow's execution instance. - */ - public void handleUpdateVfModuleFailure(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.handleUpdateVfModuleFailure(' + - 'execution=' + execution.getId() + - ')' - msoLogger.trace('Entered ' + method) - - msoLogger.error('Error occurred attempting to update VF Module in AAI, Response Code ' + execution.getVariable('UAAIVfMod_updateVfModuleResponseCode')); - String processKey = getProcessKey(execution); - WorkflowException exception = new WorkflowException(processKey, 5000, - execution.getVariable('UAAIVfMod_updateVfModuleResponse')) - execution.setVariable('WorkflowException', exception) - - msoLogger.debug("UpdateAAIVfModule failure: " + exception.getErrorMessage()) - msoLogger.trace('Exited ' + method) - } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java index bbaebb64dc..1157750312 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java @@ -37,6 +37,7 @@ import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.utils.CryptoUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; /** @@ -54,11 +55,11 @@ public class BpmnRestClient { public static final String DEFAULT_BPEL_AUTH = "admin:admin"; - public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + public static final String ENCRYPTION_KEY_PROP = "org.onap.so.adapters.network.encryptionKey"; public static final String CONTENT_TYPE_JSON = "application/json"; - public static final String CAMUNDA_AUTH = "camundaAuth"; + public static final String CAMUNDA_AUTH = "mso.camundaAuth"; private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; @Autowired @@ -108,7 +109,7 @@ public class BpmnRestClient { String encryptedCredentials; encryptedCredentials = urnPropertiesReader.getVariable(CAMUNDA_AUTH); if(encryptedCredentials != null) { - String userCredentials = getEncryptedPropValue(encryptedCredentials, DEFAULT_BPEL_AUTH, ENCRYPTION_KEY); + String userCredentials = getEncryptedPropValue(encryptedCredentials, DEFAULT_BPEL_AUTH, ENCRYPTION_KEY_PROP); if(userCredentials != null) { post.addHeader("Authorization", "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes())); } @@ -195,7 +196,7 @@ public class BpmnRestClient { */ protected String getEncryptedPropValue(String prop, String defaultValue, String encryptionKey) { try { - return CryptoUtils.decrypt(prop, encryptionKey); + return CryptoUtils.decrypt(prop, urnPropertiesReader.getVariable(encryptionKey)); } catch(GeneralSecurityException e) { msoLogger.debug("Security exception", e); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidator.java new file mode 100644 index 0000000000..d4467b8270 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidator.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.validation; + +import java.util.Set; + +import org.onap.so.bpmn.common.BuildingBlockExecution; + +public interface BuildingBlockValidator { + + + /** + * Name of the building block to be validated + * @return + */ + public Set<String> forBuildingBlock(); + + /** + * Determines whether or not the building block should be executed + * + * @param execution + * @return + */ + public boolean validate(BuildingBlockExecution execution); + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java new file mode 100644 index 0000000000..d26ae7b92b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java @@ -0,0 +1,150 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.validation; + +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import javax.annotation.PostConstruct; +import javax.annotation.Priority; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.javatuples.Pair; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.client.exception.ExceptionBuilder; +import org.reflections.Reflections; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + + +/** + * Controls running all pre and post validation for building blocks. + * + * To define a validation you must make it a spring bean and implement either {@link org.onap.so.bpmn.common.validation.PreBuildingBlockValidator} or + * {@link org.onap.so.bpmn.common.validation.PostBuildingBlockValidator} your validation will automatically be + * run by this class. + * + */ +@Component +public class BuildingBlockValidatorRunner { + + private static Logger logger = LoggerFactory.getLogger(BuildingBlockValidatorRunner.class); + @Autowired + private ApplicationContext context; + + @Autowired + private ExceptionBuilder exceptionBuilder; + + private List<PreBuildingBlockValidator> preBuildingBlockValidators; + private List<PostBuildingBlockValidator> postBuildingBlockValidators; + + + @PostConstruct + protected void init() { + + preBuildingBlockValidators = new ArrayList<>( + Optional.ofNullable(context.getBeansOfType(PreBuildingBlockValidator.class)).orElse(new HashMap<>()).values()); + postBuildingBlockValidators = new ArrayList<>( + Optional.ofNullable(context.getBeansOfType(PostBuildingBlockValidator.class)).orElse(new HashMap<>()).values()); + } + + public boolean preValidate(String bbName, BuildingBlockExecution execution) { + return validate(preBuildingBlockValidators, bbName, execution); + } + + + public boolean postValidate(String bbName, BuildingBlockExecution execution) { + return validate(postBuildingBlockValidators, bbName, execution); + } + + + protected boolean validate(List<? extends BuildingBlockValidator> validators, String bbName, BuildingBlockExecution execution) { + List<Pair<String, Boolean>> results = runValidations(validators, bbName, execution); + + if (!results.isEmpty()) { + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, + "Failed Validations:\n" + results.stream().map(item -> item.getValue0()).collect(Collectors.joining("\n"))); + } + + return true; + + } + protected List<Pair<String, Boolean>> runValidations(List<? extends BuildingBlockValidator> validators, String bbName, BuildingBlockExecution execution) { + + List<BuildingBlockValidator> filtered = filterValidators(validators, bbName); + + List<Pair<String,Boolean>> results = new ArrayList<>(); + filtered.forEach(item -> results.add(new Pair<>(item.getClass().getName(), item.validate(execution)))); + + return results.stream().filter(item -> item.getValue1().equals(false)).collect(Collectors.toList()); + } + + protected List<BuildingBlockValidator> filterValidators(List<? extends BuildingBlockValidator> validators, String bbName) { + return validators.stream() + .filter(item -> { + return item.forBuildingBlock().contains(bbName); + }) + .sorted(Comparator.comparing(item -> { + Priority p = Optional.ofNullable(item.getClass().getAnnotation(Priority.class)).orElse(new Priority() { + public int value() { + return 1000; + } + + @Override + public Class<? extends Annotation> annotationType() { + return Priority.class; + } + }); + return p.value(); + })).collect(Collectors.toList()); + } + + protected <T> List<T> buildalidatorList(Reflections reflections, Class<T> clazz) { + List<T> result = new ArrayList<>(); + try { + for (Class<? extends T> klass : reflections.getSubTypesOf(clazz)) { + result.add(klass.newInstance()); + } + } catch (InstantiationException | IllegalAccessException e) { + logger.error("failed to build validator list for " + clazz.getName(), e); + throw new RuntimeException(e); + } + + return result; + } + + protected List<PreBuildingBlockValidator> getPreBuildingBlockValidators() { + return this.preBuildingBlockValidators; + } + + protected List<PostBuildingBlockValidator> getPostBuildingBlockValidators() { + return this.postBuildingBlockValidators; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java new file mode 100644 index 0000000000..0b1ef5c6e1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.validation; + + +public interface PostBuildingBlockValidator extends BuildingBlockValidator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java new file mode 100644 index 0000000000..489ac483d0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.validation; + +public interface PreBuildingBlockValidator extends BuildingBlockValidator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 8cc25a2c52..5296d5995f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -336,14 +336,16 @@ public class BBInputSetup implements JavaDelegate { protected VnfVfmoduleCvnfcConfigurationCustomization findVnfVfmoduleCvnfcConfigurationCustomization(String vfModuleCustomizationUUID, String vnfResourceCustomizationUUID, String cvnfcCustomizationUUID, ConfigurationResourceCustomization configurationResourceCustomization) { - for(VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization : - configurationResourceCustomization.getConfigurationResource().getVnfVfmoduleCvnfcConfigurationCustomization()) { - if(vnfVfmoduleCvnfcConfigurationCustomization.getVfModuleCustomization().getModelCustomizationUUID().equalsIgnoreCase(vfModuleCustomizationUUID) - && vnfVfmoduleCvnfcConfigurationCustomization.getVnfResourceCustomization().getModelCustomizationUUID().equalsIgnoreCase(vnfResourceCustomizationUUID) - && vnfVfmoduleCvnfcConfigurationCustomization.getCvnfcCustomization().getModelCustomizationUUID().equalsIgnoreCase(cvnfcCustomizationUUID)) { - return vnfVfmoduleCvnfcConfigurationCustomization; + + if(configurationResourceCustomization.getConfigurationResource() != null) + for(VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization : + configurationResourceCustomization.getConfigurationResource().getVnfVfmoduleCvnfcConfigurationCustomization()) { + if(vnfVfmoduleCvnfcConfigurationCustomization.getVfModuleCustomization().getModelCustomizationUUID().equalsIgnoreCase(vfModuleCustomizationUUID) + && vnfVfmoduleCvnfcConfigurationCustomization.getVnfResourceCustomization().getModelCustomizationUUID().equalsIgnoreCase(vnfResourceCustomizationUUID) + && vnfVfmoduleCvnfcConfigurationCustomization.getCvnfcCustomization().getModelCustomizationUUID().equalsIgnoreCase(cvnfcCustomizationUUID)) { + return vnfVfmoduleCvnfcConfigurationCustomization; + } } - } return null; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index d8f9a66568..e815051eaa 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -57,7 +57,7 @@ public class ExecuteBuildingBlockRainyDay { } } - public void queryRainyDayTable(DelegateExecution execution) { + public void queryRainyDayTable(DelegateExecution execution, boolean primaryPolicy) { try { ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock"); String bbName = ebb.getBuildingBlock().getBpmnFlowName(); @@ -102,10 +102,18 @@ public class ExecuteBuildingBlockRainyDay { if(rainyDayHandlerStatus==null){ handlingCode = "Abort"; }else{ - handlingCode = rainyDayHandlerStatus.getPolicy(); + if(primaryPolicy){ + handlingCode = rainyDayHandlerStatus.getPolicy(); + }else{ + handlingCode = rainyDayHandlerStatus.getSecondaryPolicy(); + } } }else{ - handlingCode = rainyDayHandlerStatus.getPolicy(); + if(primaryPolicy){ + handlingCode = rainyDayHandlerStatus.getPolicy(); + }else{ + handlingCode = rainyDayHandlerStatus.getSecondaryPolicy(); + } } msoLogger.debug("RainyDayHandler Status Code is: " + handlingCode); execution.setVariable(HANDLING_CODE, handlingCode); diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/UpdateAAIVfModule.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/UpdateAAIVfModule.bpmn index f0b1d8d027..7ad101f33f 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/UpdateAAIVfModule.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/UpdateAAIVfModule.bpmn @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_Wblj8GyfEeWUWLTvug7ZOg" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_Wblj8GyfEeWUWLTvug7ZOg" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="UpdateAAIVfModule" name="UpdateAAIVfModule" isExecutable="true"> - <bpmn2:documentation>This flow expects its incoming request to be in the variable 'UpdateAAIVfModuleRequest'. This flow produces no output.</bpmn2:documentation> + <bpmn2:documentation><![CDATA[This flow expects its incoming request to be in the variable 'UpdateAAIVfModuleRequest'. This flow produces no output.]]></bpmn2:documentation> <bpmn2:scriptTask id="QueryAAIForVfModule" name="Query AAI for VF Module" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_38</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_39</bpmn2:outgoing> @@ -9,10 +9,10 @@ def uvm = new UpdateAAIVfModule() uvm.getVfModule(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_39" name="" sourceRef="QueryAAIForVfModule" targetRef="ExclusiveGateway_3"/> + <bpmn2:sequenceFlow id="SequenceFlow_39" name="" sourceRef="QueryAAIForVfModule" targetRef="ExclusiveGateway_3" /> <bpmn2:endEvent id="EndEvent_7"> <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_68" errorRef="Error_1"/> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_68" errorRef="Error_1" /> </bpmn2:endEvent> <bpmn2:scriptTask id="AAIQueryFailure" name="Handle AAI Query Failure" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> @@ -21,11 +21,7 @@ uvm.getVfModule(execution)]]></bpmn2:script> def uvm= new UpdateAAIVfModule() uvm.handleAAIQueryFailure(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_18" name="" sourceRef="AAIQueryFailure" targetRef="EndEvent_7"/> - <bpmn2:endEvent id="EndEvent_2"> - <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_50" errorRef="Error_1"/> - </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_18" name="" sourceRef="AAIQueryFailure" targetRef="EndEvent_7" /> <bpmn2:endEvent id="EndEvent_4" name="TheEnd"> <bpmn2:extensionElements> <camunda:connector> @@ -36,7 +32,7 @@ uvm.handleAAIQueryFailure(execution)]]></bpmn2:script> </camunda:inputOutput> </camunda:connector> </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_13</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_1x7tivg</bpmn2:incoming> </bpmn2:endEvent> <bpmn2:exclusiveGateway id="ExclusiveGateway_3" default="SequenceFlow_23"> <bpmn2:incoming>SequenceFlow_39</bpmn2:incoming> @@ -44,38 +40,20 @@ uvm.handleAAIQueryFailure(execution)]]></bpmn2:script> <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> </bpmn2:exclusiveGateway> <bpmn2:sequenceFlow id="SequenceFlow_22" name="" sourceRef="ExclusiveGateway_3" targetRef="UpdateVfModule"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('UAAIVfMod_getVfModuleResponseCode') == 200}</bpmn2:conditionExpression> - </bpmn2:sequenceFlow> - <bpmn2:sequenceFlow id="SequenceFlow_23" name="AAI Query failure or
VF Module not found" sourceRef="ExclusiveGateway_3" targetRef="AAIQueryFailure"/> - <bpmn2:scriptTask id="HandleUpdateVfModuleFailure" name="Handle Update VF Module Failure" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -def uvm= new UpdateAAIVfModule() -uvm.handleUpdateVfModuleFailure(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="HandleUpdateVfModuleFailure" targetRef="EndEvent_2"/> - <bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_4"> - <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_13</bpmn2:outgoing> - <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> - </bpmn2:exclusiveGateway> - <bpmn2:sequenceFlow id="SequenceFlow_13" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_4"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable('UAAIVfMod_updateVfModuleResponseCode') == 200}</bpmn2:conditionExpression> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable('UAAIVfMod_getVfModuleResponseCode') == 200}]]></bpmn2:conditionExpression> </bpmn2:sequenceFlow> - <bpmn2:sequenceFlow id="SequenceFlow_4" name="Update VF Module Failure" sourceRef="ExclusiveGateway_1" targetRef="HandleUpdateVfModuleFailure"/> + <bpmn2:sequenceFlow id="SequenceFlow_23" name="AAI Query failure or
VF Module not found" sourceRef="ExclusiveGateway_3" targetRef="AAIQueryFailure" /> <bpmn2:scriptTask id="UpdateVfModule" name="Update VF Module" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_22</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_1x7tivg</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* def uvm= new UpdateAAIVfModule() uvm.updateVfModule(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="UpdateVfModule" targetRef="ExclusiveGateway_1"/> <bpmn2:startEvent id="StartEvent_1" name="Start"> <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="ProcessReceivedRequest"/> + <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="ProcessReceivedRequest" /> <bpmn2:scriptTask id="ProcessReceivedRequest" name="Process Received Request" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_38</bpmn2:outgoing> @@ -83,142 +61,101 @@ uvm.updateVfModule(execution)]]></bpmn2:script> def uvm= new UpdateAAIVfModule() uvm.preProcessRequest(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_38" name="" sourceRef="ProcessReceivedRequest" targetRef="QueryAAIForVfModule"/> + <bpmn2:sequenceFlow id="SequenceFlow_38" name="" sourceRef="ProcessReceivedRequest" targetRef="QueryAAIForVfModule" /> + <bpmn2:sequenceFlow id="SequenceFlow_1x7tivg" sourceRef="UpdateVfModule" targetRef="EndEvent_4" /> </bpmn2:process> - <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> + <bpmn2:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="UpdateAAIVfModule"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_37" bpmnElement="StartEvent_1"> - <dc:Bounds height="36.0" width="36.0" x="69.0" y="212.0"/> + <dc:Bounds x="69" y="212" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="34.0" x="70.0" y="253.0"/> + <dc:Bounds x="70" y="253" width="34" height="22" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_22" bpmnElement="ProcessReceivedRequest"> - <dc:Bounds height="80.0" width="100.0" x="180.0" y="190.0"/> + <dc:Bounds x="180" y="190" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_37" targetElement="_BPMNShape_ScriptTask_22"> - <di:waypoint xsi:type="dc:Point" x="105.0" y="230.0"/> - <di:waypoint xsi:type="dc:Point" x="180.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="105" y="230" /> + <di:waypoint xsi:type="dc:Point" x="180" y="230" /> <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="127.0" y="230.0"/> + <dc:Bounds x="127" y="230" width="6" height="6" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="UpdateVfModule"> - <dc:Bounds height="80.0" width="100.0" x="672.0" y="190.0"/> + <dc:Bounds x="672" y="190" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_EndEvent_92" bpmnElement="EndEvent_4"> - <dc:Bounds height="36.0" width="36.0" x="1016.0" y="212.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="50.0" x="1009.0" y="253.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_54" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> - <dc:Bounds height="50.0" width="50.0" x="840.0" y="206.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="865.0" y="261.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_13" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_EndEvent_92"> - <di:waypoint xsi:type="dc:Point" x="890.0" y="231.0"/> - <di:waypoint xsi:type="dc:Point" x="993.0" y="231.0"/> - <di:waypoint xsi:type="dc:Point" x="993.0" y="230.0"/> - <di:waypoint xsi:type="dc:Point" x="1016.0" y="230.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="928.0" y="231.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_120" bpmnElement="EndEvent_2"> - <dc:Bounds height="36.0" width="36.0" x="848.0" y="0.0"/> + <dc:Bounds x="1016" y="212" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="866.0" y="41.0"/> + <dc:Bounds x="1009" y="253" width="50" height="22" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_86" bpmnElement="ExclusiveGateway_3" isMarkerVisible="true"> - <dc:Bounds height="50.0" width="50.0" x="493.0" y="204.0"/> + <dc:Bounds x="493" y="204" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="518.0" y="259.0"/> + <dc:Bounds x="518" y="259" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_23" bpmnElement="SequenceFlow_22" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_Task_2"> - <di:waypoint xsi:type="dc:Point" x="543.0" y="229.0"/> - <di:waypoint xsi:type="dc:Point" x="607.0" y="229.0"/> - <di:waypoint xsi:type="dc:Point" x="607.0" y="230.0"/> - <di:waypoint xsi:type="dc:Point" x="672.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="543" y="229" /> + <di:waypoint xsi:type="dc:Point" x="607" y="229" /> + <di:waypoint xsi:type="dc:Point" x="607" y="230" /> + <di:waypoint xsi:type="dc:Point" x="672" y="230" /> <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="558.0" y="229.0"/> + <dc:Bounds x="558" y="229" width="6" height="6" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_155" bpmnElement="AAIQueryFailure"> - <dc:Bounds height="80.0" width="100.0" x="468.0" y="60.0"/> + <dc:Bounds x="468" y="60" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_24" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_86" targetElement="_BPMNShape_ScriptTask_155"> - <di:waypoint xsi:type="dc:Point" x="518.0" y="204.0"/> - <di:waypoint xsi:type="dc:Point" x="518.0" y="140.0"/> + <di:waypoint xsi:type="dc:Point" x="518" y="204" /> + <di:waypoint xsi:type="dc:Point" x="518" y="140" /> <bpmndi:BPMNLabel> - <dc:Bounds height="38.0" width="130.0" x="528.0" y="152.0"/> + <dc:Bounds x="528" y="152" width="130" height="38" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_7"> - <dc:Bounds height="36.0" width="36.0" x="500.0" y="0.0"/> + <dc:Bounds x="500" y="0" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="518.0" y="41.0"/> + <dc:Bounds x="518" y="41" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_18" sourceElement="_BPMNShape_ScriptTask_155" targetElement="_BPMNShape_EndEvent_160"> - <di:waypoint xsi:type="dc:Point" x="518.0" y="60.0"/> - <di:waypoint xsi:type="dc:Point" x="518.0" y="36.0"/> + <di:waypoint xsi:type="dc:Point" x="518" y="60" /> + <di:waypoint xsi:type="dc:Point" x="518" y="36" /> <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="515.0" y="49.0"/> + <dc:Bounds x="515" y="49" width="6" height="6" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_160" bpmnElement="QueryAAIForVfModule"> - <dc:Bounds height="80.0" width="100.0" x="336.0" y="190.0"/> + <dc:Bounds x="336" y="190" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_38" sourceElement="_BPMNShape_ScriptTask_22" targetElement="_BPMNShape_ScriptTask_160"> - <di:waypoint xsi:type="dc:Point" x="280.0" y="230.0"/> - <di:waypoint xsi:type="dc:Point" x="336.0" y="230.0"/> + <di:waypoint xsi:type="dc:Point" x="280" y="230" /> + <di:waypoint xsi:type="dc:Point" x="336" y="230" /> <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="300.0" y="230.0"/> + <dc:Bounds x="300" y="230" width="6" height="6" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_39" bpmnElement="SequenceFlow_39" sourceElement="_BPMNShape_ScriptTask_160" targetElement="_BPMNShape_ExclusiveGateway_86"> - <di:waypoint xsi:type="dc:Point" x="436.0" y="230.0"/> - <di:waypoint xsi:type="dc:Point" x="452.0" y="230.0"/> - <di:waypoint xsi:type="dc:Point" x="452.0" y="229.0"/> - <di:waypoint xsi:type="dc:Point" x="493.0" y="229.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="449.0" y="229.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_161" bpmnElement="HandleUpdateVfModuleFailure"> - <dc:Bounds height="80.0" width="100.0" x="816.0" y="60.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_161" targetElement="_BPMNShape_EndEvent_120"> - <di:waypoint xsi:type="dc:Point" x="866.0" y="60.0"/> - <di:waypoint xsi:type="dc:Point" x="866.0" y="36.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="863.0" y="51.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_ExclusiveGateway_54"> - <di:waypoint xsi:type="dc:Point" x="772.0" y="230.0"/> - <di:waypoint xsi:type="dc:Point" x="797.0" y="230.0"/> - <di:waypoint xsi:type="dc:Point" x="797.0" y="231.0"/> - <di:waypoint xsi:type="dc:Point" x="840.0" y="231.0"/> + <di:waypoint xsi:type="dc:Point" x="436" y="230" /> + <di:waypoint xsi:type="dc:Point" x="452" y="230" /> + <di:waypoint xsi:type="dc:Point" x="452" y="229" /> + <di:waypoint xsi:type="dc:Point" x="493" y="229" /> <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="801.0" y="231.0"/> + <dc:Bounds x="449" y="229" width="6" height="6" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ScriptTask_161"> - <di:waypoint xsi:type="dc:Point" x="865.0" y="206.0"/> - <di:waypoint xsi:type="dc:Point" x="865.0" y="172.0"/> - <di:waypoint xsi:type="dc:Point" x="867.0" y="172.0"/> - <di:waypoint xsi:type="dc:Point" x="867.0" y="140.0"/> + <bpmndi:BPMNEdge id="SequenceFlow_1x7tivg_di" bpmnElement="SequenceFlow_1x7tivg"> + <di:waypoint xsi:type="dc:Point" x="772" y="230" /> + <di:waypoint xsi:type="dc:Point" x="1016" y="230" /> <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="157.0" x="883.0" y="160.0"/> + <dc:Bounds x="894" y="208" width="0" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn2:definitions>
\ No newline at end of file +</bpmn2:definitions> |