diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java/org')
12 files changed, 568 insertions, 224 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java index 1220dc05c1..f49cf48ff5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java @@ -109,12 +109,15 @@ public class CnfAdapterCreateTasks { protected InstanceRequest createInstanceRequest(VfModule vfModule, CloudRegion cloudRegion, Map<String, String> sdncDirectives) { InstanceRequest request = new InstanceRequest(); - request.setRbName(vfModule.getModelInfoVfModule().getModelInvariantUUID()); - request.setRbVersion(vfModule.getModelInfoVfModule().getModelUUID()); + request.setModelInvariantId(vfModule.getModelInfoVfModule().getModelInvariantUUID()); + request.setModelVersionId(vfModule.getModelInfoVfModule().getModelUUID()); + request.setModelCustomizationId(vfModule.getModelInfoVfModule().getModelCustomizationUUID()); request.setCloudRegion(cloudRegion.getLcpCloudRegionId()); request.setVfModuleUUID(vfModule.getVfModuleId()); request.setProfileName(sdncDirectives.get("k8s-rb-profile-name")); request.setReleaseName(sdncDirectives.get("k8s-rb-instance-release-name")); + if (sdncDirectives.containsKey("k8s-rb-instance-status-check")) + request.setStatusCheck(sdncDirectives.get("k8s-rb-instance-status-check").equalsIgnoreCase("true")); request.setOverrideValues(sdncDirectives); return request; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java index 8e6e8678ed..7c6473f79d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java @@ -2,12 +2,15 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; import java.io.ByteArrayInputStream; import java.io.StringReader; +import java.nio.charset.StandardCharsets; import java.util.Optional; +import javax.xml.XMLConstants; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import org.apache.commons.lang3.StringUtils; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkResponse; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; @@ -22,6 +25,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.w3c.dom.Document; @Component public class NetworkAdapterImpl { @@ -80,14 +84,16 @@ public class NetworkAdapterImpl { return unmarshaller.unmarshal(reader); } - protected Optional<String> findResponseType(String xmlString) { + protected Optional<String> findResponseType(final String xmlString) { try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - org.w3c.dom.Document doc; - doc = builder.parse(new ByteArrayInputStream(xmlString.getBytes("UTF-8"))); + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, StringUtils.EMPTY); + factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, StringUtils.EMPTY); + + final DocumentBuilder builder = factory.newDocumentBuilder(); + final Document doc = builder.parse(new ByteArrayInputStream(xmlString.getBytes(StandardCharsets.UTF_8))); return Optional.of(doc.getDocumentElement().getNodeName()); - } catch (Exception e) { + } catch (final Exception e) { logger.error("Error Finding Response Type", e); return Optional.empty(); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java index 2d39cc185e..76c67eefc5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java @@ -21,11 +21,12 @@ */ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; +import static org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants.CONTROLLER_STATUS; import java.util.HashMap; import java.util.Optional; -import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.appc.client.lcm.model.Action; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -33,9 +34,9 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.catalog.beans.ControllerSelectionReference; -import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,13 +91,12 @@ public class GenericVnfHealthCheck { public void callAppcClient(BuildingBlockExecution execution) { logger.trace("Start runAppcCommand "); String appcCode = "1002"; - String appcMessage = ""; + String appcMessage; try { - Action action = null; - action = Action.valueOf(execution.getVariable("action")); + Action action = Action.valueOf(execution.getVariable("action")); String msoRequestId = execution.getVariable("msoRequestId"); String vnfId = execution.getVariable("vnfId"); - Optional<String> payload = null; + Optional<String> payload = Optional.empty(); if (execution.getVariable("payload") != null) { String pay = execution.getVariable("payload"); payload = Optional.of(pay); @@ -108,7 +108,7 @@ public class GenericVnfHealthCheck { payloadInfo.put(OAM_IP_ADDRESS, execution.getVariable(OAM_IP_ADDRESS)); payloadInfo.put(VNF_HOST_IP_ADDRESS, execution.getVariable(VNF_HOST_IP_ADDRESS)); - logger.debug("Running APP-C action: {}", action.toString()); + logger.debug("Running APP-C action: {}", action); logger.debug("VNFID: {}", vnfId); // PayloadInfo contains extra information that adds on to payload before making request to appc appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType); @@ -134,11 +134,14 @@ public class GenericVnfHealthCheck { exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } } + logger.error("Error Message: " + appcMessage); logger.error("ERROR CODE: " + appcCode); - logger.trace("End of runAppCommand "); if (appcCode != null && !("0").equals(appcCode)) { exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } + + execution.setVariable(CONTROLLER_STATUS, "Success"); + logger.debug("Successfully end of runAppCommand "); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java index e55fa9e24b..7ed8447fa6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import java.io.StringReader; import java.io.StringWriter; +import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; @@ -30,14 +31,15 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; +import org.apache.commons.lang3.StringUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.logging.filter.base.ONAPComponents; import org.onap.so.bpmn.infrastructure.sdnc.exceptions.SDNCErrorResponseException; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCRequest; -import org.onap.logging.filter.base.ONAPComponents; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -47,10 +49,17 @@ import org.w3c.dom.Document; import org.xml.sax.InputSource; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.PathNotFoundException; +import net.sf.saxon.lib.NamespaceConstant; +import net.sf.saxon.xpath.XPathFactoryImpl; @Component public class SDNCRequestTasks { + private static final String NET_SF_SAXON_XPATH_IMPL = "net.sf.saxon.xpath.XPathFactoryImpl"; + + private static final String XPATH_FACTORY_PROPERTY_NAME = + "javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_SAXON; + private static final Logger logger = LoggerFactory.getLogger(SDNCRequestTasks.class); private static final String SDNC_REQUEST = "SDNCRequest"; @@ -143,14 +152,20 @@ public class SDNCRequestTasks { return "Y".equals(finalMessageIndicator); } - protected String getXmlElement(Document doc, String exp) throws Exception { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - StringWriter writer = new StringWriter(); + protected String getXmlElement(final Document doc, final String exp) throws Exception { + final TransformerFactory factory = TransformerFactory.newInstance(); + factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, StringUtils.EMPTY); + factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, StringUtils.EMPTY); + + final Transformer transformer = factory.newTransformer(); + final StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); logger.debug(writer.getBuffer().toString()); - XPath xPath = XPathFactory.newInstance().newXPath(); - String result = xPath.evaluate(exp, doc); + + System.setProperty(XPATH_FACTORY_PROPERTY_NAME, NET_SF_SAXON_XPATH_IMPL); + final XPathFactory xPathFactory = XPathFactoryImpl.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON); + final XPath xPath = xPathFactory.newXPath(); + final String result = xPath.evaluate(exp, doc); if (result == null || result.isEmpty()) { throw new Exception("XPath Failed to find element expression: " + exp); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java index 813dc04ecd..2bd0f2c786 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java @@ -10,6 +10,8 @@ * ================================================================================ * Modifications Copyright (c) 2020 Tech Mahindra * ================================================================================ + * Modifications Copyright (c) 2021 Orange + * ================================================================================ * 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 @@ -26,7 +28,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; -import java.util.Comparator; +import org.apache.commons.lang3.builder.ToStringBuilder; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; @@ -41,16 +43,7 @@ import java.util.List; import java.util.Optional; import java.util.UUID; import java.util.stream.Collectors; -import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ACTIVATE_INSTANCE; -import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE; -import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONFIGURATION; -import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER; -import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE; -import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION; -import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE; -import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS; -import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE; -import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.VOLUMEGROUP; +import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.*; @Component public class ExecuteBuildingBlockBuilder { @@ -63,80 +56,117 @@ public class ExecuteBuildingBlockBuilder { private static final String NETWORK = "Network"; protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows, - List<Resource> resourceList, String requestId, String apiVersion, String resourceId, String requestAction, - String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, - boolean replaceVnf) { + List<Resource> originalResourceList, String requestId, String apiVersion, String resourceId, + String requestAction, String vnfType, WorkflowResourceIds workflowResourceIds, + RequestDetails requestDetails, boolean replaceVnf) { + List<Resource> resourceList = getOnlyRootResourceList(originalResourceList); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + + boolean ascendingOrder = requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE) + || requestAction.equals(ACTIVATE_INSTANCE); + + ExecutionPlan plan = ExecutionPlan.build(resourceList, ascendingOrder); + + logger.info("Orchestration Flows"); for (OrchestrationFlow orchFlow : orchFlows) { - if (orchFlow.getFlowName().contains(SERVICE)) { - if (!replaceVnf) { - workflowResourceIds.setServiceInstanceId(resourceId); - } - addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.SERVICE, orchFlow, requestId, - apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, - false); - } else if (orchFlow.getFlowName().contains(VNF) || (orchFlow.getFlowName().contains(CONTROLLER) - && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) { - addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VNF, orchFlow, requestId, - apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, - false); - } else if (orchFlow.getFlowName().contains(PNF) || (orchFlow.getFlowName().contains(CONTROLLER) - && (PNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) { - addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.PNF, orchFlow, requestId, - apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, - false); - } else if (orchFlow.getFlowName().contains(NETWORK) - && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) { - addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORK, orchFlow, requestId, - apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, - false); - addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VIRTUAL_LINK, orchFlow, - requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, - true, false); - } else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER) - && (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) { - Comparator<Resource> resourceComparator; - if (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE) - || requestAction.equals(ACTIVATE_INSTANCE)) { - resourceComparator = Resource.sortBaseFirst; - } else { - resourceComparator = Resource.sortBaseLast; - } - List<Resource> vfModuleResourcesSorted = - resourceList.stream().filter(x -> WorkflowType.VFMODULE == x.getResourceType()) - .sorted(resourceComparator).collect(Collectors.toList()); - - for (Resource resource : vfModuleResourcesSorted) { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, - requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null, - false, null)); - } - } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) { - if (requestAction.equalsIgnoreCase(REPLACEINSTANCE) - || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) { - logger.debug("Replacing workflow resource id by volume group id"); - resourceId = workflowResourceIds.getVolumeGroupId(); - } - addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VOLUMEGROUP, orchFlow, - requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, - false, false); - } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) { - addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORKCOLLECTION, orchFlow, - requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, - false, false); - } else if (orchFlow.getFlowName().contains(CONFIGURATION)) { - addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.CONFIGURATION, orchFlow, - requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, - false, true); - } else { - flowsToExecute - .add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, requestAction, - false, vnfType, workflowResourceIds, requestDetails, false, null, null, false, null)); + String flowDetails = new ToStringBuilder(this).append("id", orchFlow.getId()) + .append("action", orchFlow.getAction()).append("sequenceNumber", orchFlow.getSequenceNumber()) + .append("flowName", orchFlow.getFlowName()).append("flowVersion", orchFlow.getFlowVersion()) + .append("bpmnAction", orchFlow.getBpmnAction()).append("bpmnScope", orchFlow.getBpmnScope()) + .toString(); + logger.info("Flow: " + flowDetails); + buildExecuteBuildingBlockListPlan(orchFlow, plan, requestId, apiVersion, resourceId, requestAction, vnfType, + workflowResourceIds, requestDetails, replaceVnf); + } + + plan.flushBlocksFromCache(flowsToExecute); + + return flowsToExecute; + } + + protected void buildExecuteBuildingBlockListPlan(OrchestrationFlow flow, ExecutionPlan plan, String requestId, + String apiVersion, String resourceId, String requestAction, String vnfType, + WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean replaceVnf) { + + List<ExecuteBuildingBlock> mainFlows = buildExecuteBuildingBlockListRaw(flow, plan.getResource(), requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, replaceVnf); + + plan.pushBlockToCache(mainFlows); + + for (ExecutionGroup nestedGroup : plan.getNestedExecutions()) { + for (ExecutionPlan nestedPlan : nestedGroup.getNestedExecutions()) { + buildExecuteBuildingBlockListPlan(flow, nestedPlan, requestId, apiVersion, resourceId, requestAction, + vnfType, workflowResourceIds, requestDetails, replaceVnf); + } + if (nestedGroup.getCacheSize() > 0) + plan.changeCurrentGroup(nestedGroup); + } + } + + private List<ExecuteBuildingBlock> buildExecuteBuildingBlockListRaw(OrchestrationFlow orchFlow, Resource resource, + String requestId, String apiVersion, String resourceId, String requestAction, String vnfType, + WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean replaceVnf) { + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + if (orchFlow.getFlowName().contains(SERVICE) || (orchFlow.getFlowName().contains(CONTROLLER) + && (SERVICE).equalsIgnoreCase(orchFlow.getBpmnScope()))) { + if (!replaceVnf) { + workflowResourceIds.setServiceInstanceId(resourceId); + } + addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.SERVICE, orchFlow, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false); + } else if (orchFlow.getFlowName().contains(VNF) + || (orchFlow.getFlowName().contains(CONTROLLER) && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) { + addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VNF, orchFlow, requestId, apiVersion, + resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false); + } else if (orchFlow.getFlowName().contains(PNF) + || (orchFlow.getFlowName().contains(CONTROLLER) && (PNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) { + addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.PNF, orchFlow, requestId, apiVersion, + resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false); + } else if (orchFlow.getFlowName().contains(NETWORK) && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) { + addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.NETWORK, orchFlow, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false); + addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VIRTUAL_LINK, orchFlow, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, true, false); + } else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER) + && (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) { + addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VFMODULE, orchFlow, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false); + } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) { + if (requestAction.equalsIgnoreCase(REPLACEINSTANCE) + || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) { + logger.debug("Replacing workflow resource id by volume group id"); + resourceId = workflowResourceIds.getVolumeGroupId(); } + addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VOLUMEGROUP, orchFlow, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false); + } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) { + addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.NETWORKCOLLECTION, orchFlow, + requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, + false, false); + } else if (orchFlow.getFlowName().contains(CONFIGURATION)) { + addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.CONFIGURATION, orchFlow, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, true); + } else { + flowsToExecute + .add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, requestAction, + false, vnfType, workflowResourceIds, requestDetails, false, null, null, false, null)); } return flowsToExecute; } + protected List<Resource> getOnlyRootResourceList(List<Resource> resourceList) { + return resourceList.stream().filter(x -> countResourceOnTheResourceList(x, resourceList) == 1) + .collect(Collectors.toList()); + } + + protected int countResourceOnTheResourceList(Resource resource, List<Resource> resourceList) { + int count = resourceList.stream() + .mapToInt(x -> (x.equals(resource) ? 1 : 0) + countResourceOnTheResourceList(resource, x.getChildren())) + .reduce(0, Integer::sum); + return count; + } + protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, @@ -172,15 +202,16 @@ public class ExecuteBuildingBlockBuilder { return executeBuildingBlock; } - private void addBuildingBlockToExecuteBBList(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList, + private void addBuildingBlockToExecuteBBList(List<ExecuteBuildingBlock> flowsToExecute, Resource resource, WorkflowType workflowType, OrchestrationFlow orchFlow, String requestId, String apiVersion, String resourceId, String requestAction, String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean isVirtualLink, boolean isConfiguration) { - resourceList.stream().filter(resource -> resource.getResourceType().equals(workflowType)) - .forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, - apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, - isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration, null))); + if (resource == null || !resource.getResourceType().equals(workflowType)) + return; + flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, + requestAction, false, vnfType, workflowResourceIds, requestDetails, isVirtualLink, + resource.getVirtualLinkKey(), null, isConfiguration, null)); } protected ConfigurationResourceKeys getConfigurationResourceKeys(Resource resource, String vnfcName) { @@ -191,6 +222,4 @@ public class ExecuteBuildingBlockBuilder { configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId()); return configurationResourceKeys; } - - } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecutionPlan.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecutionPlan.java new file mode 100644 index 0000000000..77cb616eb9 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecutionPlan.java @@ -0,0 +1,167 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2021 Orange Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.stream.Collectors; + +class ExecutionPlan extends ExecutionCollection<ExecutionGroup> { + private final Resource resource; + private ExecutionGroup currentGroup = null; + + public ExecutionPlan(Resource resource, ExecutionGroup group) { + super(resource != null ? resource.getResourceType() : WorkflowType.SERVICE); + this.resource = resource; + if (group != null) { + group.addNestedPlans(Collections.singletonList(this)); + } + } + + public void changeCurrentGroup(ExecutionGroup group) { + if (currentGroup == null || !currentGroup.equals(group)) { + logger.info("Change " + getName() + " group[" + group.getName() + "]"); + if (currentGroup != null) + currentGroup.flushBlocksFromCache(this.blocksBuiltCache); + } + currentGroup = group; + } + + Resource getResource() { + return resource; + } + + protected String getName() { + return super.getName() + "[" + + (resource != null ? (resource.getProcessingPriority() + ", " + resource.getResourceId()) : "") + "]"; + } + + public static ExecutionPlan build(List<Resource> resourceList, boolean ascendingOrder) { + ExecutionPlan plan = new ExecutionPlan(null, null); + buildExecutionPlan(plan, resourceList, ascendingOrder); + if (plan.getNestedExecutions().size() == 1 + && plan.getNestedExecutions().get(0).getNestedExecutions().size() == 1) + plan = plan.getNestedExecutions().get(0).getNestedExecutions().get(0); + return plan; + } + + private static void buildExecutionPlan(ExecutionPlan plan, List<Resource> resourceList, boolean ascendingOrder) { + Map<WorkflowType, List<Resource>> resourceGroups = new TreeMap<>(); + for (Resource resource : resourceList) { + if (!resourceGroups.containsKey(resource.getResourceType())) { + resourceGroups.put(resource.getResourceType(), new ArrayList<>()); + } + resourceGroups.get(resource.getResourceType()).add(resource); + } + for (WorkflowType type : resourceGroups.keySet()) { + ExecutionGroup nestedGroup = new ExecutionGroup(type, plan); + List<Resource> resourceGroupSorted = resourceGroups.get(type).stream() + .sorted(ascendingOrder ? Resource.sortByPriorityAsc : Resource.sortByPriorityDesc) + .collect(Collectors.toList()); + for (Resource resource : resourceGroupSorted) { + ExecutionPlan planInGroup = new ExecutionPlan(resource, nestedGroup); + if (resource.getChildren().size() > 0) + buildExecutionPlan(planInGroup, resource.getChildren(), ascendingOrder); + } + } + } +} + + +class ExecutionGroup extends ExecutionCollection<ExecutionPlan> { + + public ExecutionGroup(WorkflowType groupType, ExecutionPlan plan) { + super(groupType); + plan.addNestedPlans(Collections.singletonList(this)); + } +} + + +class ExecutionCollection<T extends ExecutionCollection<?>> { + + protected static final Logger logger = LoggerFactory.getLogger(ExecutionCollection.class); + + protected final WorkflowType type; + protected List<ExecuteBuildingBlock> blocksBuiltCache; + protected final List<T> nestedExecutions; + + public ExecutionCollection(WorkflowType type) { + this.type = type; + this.nestedExecutions = new ArrayList<>(); + this.blocksBuiltCache = new ArrayList<>(); + } + + public WorkflowType getType() { + return type; + } + + public List<T> getNestedExecutions() { + return nestedExecutions; + } + + public void addNestedPlans(List<T> executions) { + nestedExecutions.addAll(executions); + } + + public void pushBlockToCache(List<ExecuteBuildingBlock> blocksCache) { + if (blocksCache.size() == 0) + return; + this.flushNestedBlocksToCache(); + String blocks = + blocksCache.stream().map(x -> x.getBuildingBlock().getBpmnFlowName() + ", ").reduce("", String::concat); + blocks = blocks.substring(0, blocks.length() - 2); + logger.info("Push " + getName() + " (" + blocksCache.size() + ") blocks [" + blocks + "]"); + this.blocksBuiltCache.addAll(blocksCache); + } + + private void flushNestedBlocksToCache() { + for (T collection : nestedExecutions) { + collection.flushBlocksFromCache(this.blocksBuiltCache); + } + } + + public void flushBlocksFromCache(List<ExecuteBuildingBlock> blockList) { + flushNestedBlocksToCache(); + if (this.blocksBuiltCache.size() > 0) { + String blocks = this.blocksBuiltCache.stream().map(x -> x.getBuildingBlock().getBpmnFlowName() + ", ") + .reduce("", String::concat); + blocks = blocks.substring(0, blocks.length() - 2); + logger.info("Flush " + getName() + " (" + blocksBuiltCache.size() + ") blocks [" + blocks + "]"); + blockList.addAll(this.blocksBuiltCache); + this.blocksBuiltCache.clear(); + } + } + + public int getCacheSize() { + return blocksBuiltCache.size() + + getNestedExecutions().stream().mapToInt(x -> x.getCacheSize()).reduce(0, Integer::sum); + } + + protected String getName() { + return type.name(); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java index 692d8bccdb..0d2844d08b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2021 Orange + * ================================================================================ * 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 @@ -20,7 +22,10 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; +import java.util.List; public class Resource { @@ -32,14 +37,24 @@ public class Resource { private String vnfCustomizationId; private String vfModuleCustomizationId; private String cvnfModuleCustomizationId; + private int processingPriority; + private Resource parent; + private List<Resource> children; - public static final Comparator<Resource> sortBaseFirst = Comparator.comparingInt(x -> x.isBaseVfModule() ? 0 : 1); - public static final Comparator<Resource> sortBaseLast = Comparator.comparingInt(x -> x.isBaseVfModule() ? 1 : 0); + public static final Comparator<Resource> sortByPriorityAsc = + Comparator.comparingInt(Resource::getProcessingPriority); + public static final Comparator<Resource> sortByPriorityDesc = + Comparator.comparingInt(x -> -x.getProcessingPriority()); - public Resource(WorkflowType resourceType, String resourceId, boolean generated) { + public Resource(WorkflowType resourceType, String resourceId, boolean generated, Resource parent) { this.resourceId = resourceId; this.resourceType = resourceType; this.generated = generated; + this.processingPriority = 0; + this.children = new ArrayList<>(); + this.parent = parent; + if (parent != null) + this.parent.children.add(this); } public String getResourceId() { @@ -105,4 +120,20 @@ public class Resource { public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) { this.cvnfModuleCustomizationId = cvnfModuleCustomizationId; } + + public int getProcessingPriority() { + return processingPriority == 0 ? (isBaseVfModule() ? Integer.MIN_VALUE + 1 : 0) : processingPriority; + } + + public void setProcessingPriority(int processingPriority) { + this.processingPriority = processingPriority; + } + + public Resource getParent() { + return this.parent; + } + + public List<Resource> getChildren() { + return this.children; + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 8a9289981d..ce775af476 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -10,6 +10,8 @@ * ================================================================================ * Modifications Copyright (c) 2020 Tech Mahindra * ================================================================================ + * Modifications Copyright (c) 2021 Orange + * ================================================================================ * 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 @@ -318,6 +320,24 @@ public class WorkflowAction { logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } + logger.info("Building Block Execution Order"); + for (ExecuteBuildingBlock block : flowsToExecute) { + Resource res = resourceList.stream() + .filter(resource -> resource.getResourceId() == block.getBuildingBlock().getKey()).findAny() + .orElse(null); + String log = "Block: " + block.getBuildingBlock().getBpmnFlowName(); + if (res != null) { + log += ", Resource: " + res.getResourceType() + "[" + res.getResourceId() + "]"; + log += ", Priority: " + res.getProcessingPriority(); + if (res.getResourceType() == WorkflowType.VFMODULE) + log += ", Base: " + res.isBaseVfModule(); + } + if (block.getBuildingBlock().getBpmnScope() != null) + log += ", Scope: " + block.getBuildingBlock().getBpmnScope(); + if (block.getBuildingBlock().getBpmnAction() != null) + log += ", Action: " + block.getBuildingBlock().getBpmnAction(); + logger.info(log); + } // By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE if (resourceType == WorkflowType.SERVICE && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE)) @@ -417,7 +437,7 @@ public class WorkflowAction { resourceId = modelInfo.getModelCustomizationId(); } } - return new Resource(resourceType, resourceId, true); + return new Resource(resourceType, resourceId, true, null); } private String getCloudOwner(CloudConfiguration cloudConfiguration) { @@ -732,7 +752,7 @@ public class WorkflowAction { type = action; } } - return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated); + return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated, null); } else { throw new IllegalArgumentException("Uri could not be parsed: " + uri); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java index 6d02594c68..e4c6d2951f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java @@ -1,3 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2020 Nokia + * ================================================================================ + * Modifications Copyright (c) 2021 Orange + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader; import com.fasterxml.jackson.core.JsonProcessingException; @@ -121,7 +143,7 @@ public class ServiceEBBLoader { // to query the SI in AAI to find related instances. traverseAAIService(execution, resourceList, resourceId, aaiResourceIds); } else if (DEACTIVATE_INSTANCE.equalsIgnoreCase(requestAction)) { - resourceList.add(new Resource(WorkflowType.SERVICE, "", false)); + resourceList.add(new Resource(WorkflowType.SERVICE, "", false, null)); } return resourceList; } @@ -142,16 +164,18 @@ public class ServiceEBBLoader { if (service == null) { buildAndThrowException(execution, "Could not find the service model in catalog db."); } else { - resourceList.add(new Resource(WorkflowType.SERVICE, service.getModelUUID(), false)); + Resource serviceResource = new Resource(WorkflowType.SERVICE, service.getModelUUID(), false, null); + resourceList.add(serviceResource); RelatedInstance relatedVpnBinding = bbInputSetupUtils.getRelatedInstanceByType(sIRequest.getRequestDetails(), ModelType.vpnBinding); RelatedInstance relatedLocalNetwork = bbInputSetupUtils.getRelatedInstanceByType(sIRequest.getRequestDetails(), ModelType.network); if (relatedVpnBinding != null && relatedLocalNetwork != null) { - traverseVrfConfiguration(aaiResourceIds, resourceList, service, relatedVpnBinding, relatedLocalNetwork); + traverseVrfConfiguration(aaiResourceIds, resourceList, serviceResource, service, relatedVpnBinding, + relatedLocalNetwork); } else { - traverseNetworkCollection(execution, resourceList, service); + traverseNetworkCollection(execution, resourceList, serviceResource, service); } } } @@ -169,14 +193,17 @@ public class ServiceEBBLoader { ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(resourceId); org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI); - resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false)); - traverseServiceInstanceMSOVnfs(resourceList, aaiResourceIds, serviceInstanceMSO); - traverseServiceInstanceMSOPnfs(resourceList, aaiResourceIds, serviceInstanceMSO); + Resource serviceResource = + new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null); + resourceList.add(serviceResource); + traverseServiceInstanceMSOVnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO); + traverseServiceInstanceMSOPnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO); if (serviceInstanceMSO.getNetworks() != null) { for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO .getNetworks()) { aaiResourceIds.add(new Pair<>(WorkflowType.NETWORK, network.getNetworkId())); - resourceList.add(new Resource(WorkflowType.NETWORK, network.getNetworkId(), false)); + resourceList + .add(new Resource(WorkflowType.NETWORK, network.getNetworkId(), false, serviceResource)); } } if (serviceInstanceMSO.getCollection() != null) { @@ -184,7 +211,7 @@ public class ServiceEBBLoader { aaiResourceIds .add(new Pair<>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId())); resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, - serviceInstanceMSO.getCollection().getId(), false)); + serviceInstanceMSO.getCollection().getId(), false, serviceResource)); } if (serviceInstanceMSO.getConfigurations() != null) { for (Configuration config : serviceInstanceMSO.getConfigurations()) { @@ -195,8 +222,8 @@ public class ServiceEBBLoader { if (relationship.getRelatedTo().contains("vnfc") || relationship.getRelatedTo().contains("vpn-binding")) { aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.getConfigurationId())); - resourceList.add( - new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), false)); + resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), + false, serviceResource)); break; } } @@ -210,7 +237,7 @@ public class ServiceEBBLoader { } } - private void traverseServiceInstanceMSOVnfs(List<Resource> resourceList, + private void traverseServiceInstanceMSOVnfs(List<Resource> resourceList, Resource serviceResource, List<Pair<WorkflowType, String>> aaiResourceIds, org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) { if (serviceInstanceMSO.getVnfs() == null) { @@ -218,18 +245,20 @@ public class ServiceEBBLoader { } for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) { aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); - resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false)); - traverseVnfModules(resourceList, aaiResourceIds, vnf); + Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getVnfId(), false, serviceResource); + resourceList.add(vnfResource); + traverseVnfModules(resourceList, vnfResource, aaiResourceIds, vnf); if (vnf.getVolumeGroups() != null) { for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf.getVolumeGroups()) { aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId())); - resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false)); + resourceList.add( + new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false, vnfResource)); } } } } - private void traverseServiceInstanceMSOPnfs(List<Resource> resourceList, + private void traverseServiceInstanceMSOPnfs(List<Resource> resourceList, Resource serviceResource, List<Pair<WorkflowType, String>> aaiResourceIds, org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) { if (serviceInstanceMSO.getPnfs() == null) { @@ -237,12 +266,12 @@ public class ServiceEBBLoader { } for (org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf : serviceInstanceMSO.getPnfs()) { aaiResourceIds.add(new Pair<>(WorkflowType.PNF, pnf.getPnfId())); - resourceList.add(new Resource(WorkflowType.PNF, pnf.getPnfId(), false)); + resourceList.add(new Resource(WorkflowType.PNF, pnf.getPnfId(), false, serviceResource)); } } protected void traverseVrfConfiguration(List<Pair<WorkflowType, String>> aaiResourceIds, - List<Resource> resourceList, org.onap.so.db.catalog.beans.Service service, + List<Resource> resourceList, Resource serviceResource, org.onap.so.db.catalog.beans.Service service, RelatedInstance relatedVpnBinding, RelatedInstance relatedLocalNetwork) throws VrfBondingServiceException, JsonProcessingException { org.onap.aai.domain.yang.L3Network aaiLocalNetwork = @@ -260,12 +289,12 @@ public class ServiceEBBLoader { aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration)); } resourceList.add(new Resource(WorkflowType.CONFIGURATION, - service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false)); + service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false, serviceResource)); } protected void traverseNetworkCollection(DelegateExecution execution, List<Resource> resourceList, - org.onap.so.db.catalog.beans.Service service) { + Resource serviceResource, org.onap.so.db.catalog.beans.Service service) { if (isVnfCustomizationsInTheService(service)) { buildAndThrowException(execution, "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows"); @@ -280,14 +309,16 @@ public class ServiceEBBLoader { } else { CollectionResourceCustomization collectionResourceCustomization = findCatalogNetworkCollection(execution, service); - traverseNetworkCollectionResourceCustomization(resourceList, collectionResourceCustomization); + traverseNetworkCollectionResourceCustomization(resourceList, serviceResource, + collectionResourceCustomization); } - traverseNetworkCollectionCustomization(resourceList, service); + traverseNetworkCollectionCustomization(resourceList, serviceResource, service); } - private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList, + private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList, Resource serviceResource, CollectionResourceCustomization collectionResourceCustomization) { - if (collectionResourceCustomizationShouldNotBeProcessed(resourceList, collectionResourceCustomization)) + if (collectionResourceCustomizationShouldNotBeProcessed(resourceList, serviceResource, + collectionResourceCustomization)) return; int minNetworks = 0; org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = @@ -312,7 +343,7 @@ public class ServiceEBBLoader { for (int i = 0; i < minNetworks; i++) { if (collectionNetworkResourceCust != null) { Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, - collectionNetworkResourceCust.getModelCustomizationUUID(), false); + collectionNetworkResourceCust.getModelCustomizationUUID(), false, serviceResource); resource.setVirtualLinkKey(Integer.toString(i)); resourceList.add(resource); } @@ -334,13 +365,13 @@ public class ServiceEBBLoader { } private boolean collectionResourceCustomizationShouldNotBeProcessed(List<Resource> resourceList, - CollectionResourceCustomization collectionResourceCustomization) { + Resource serviceResource, CollectionResourceCustomization collectionResourceCustomization) { if (collectionResourceCustomization == null) { logger.debug("No Network Collection Customization found"); return true; } resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, - collectionResourceCustomization.getModelCustomizationUUID(), false)); + collectionResourceCustomization.getModelCustomizationUUID(), false, serviceResource)); logger.debug("Found a network collection"); if (collectionResourceCustomization.getCollectionResource() == null) { logger.debug("No Network Collection found. collectionResource is null"); @@ -368,7 +399,7 @@ public class ServiceEBBLoader { return toscaNodeType != null && toscaNodeType.contains(NETWORKCOLLECTION); } - private void traverseNetworkCollectionCustomization(List<Resource> resourceList, + private void traverseNetworkCollectionCustomization(List<Resource> resourceList, Resource serviceResource, org.onap.so.db.catalog.beans.Service service) { if (isNetworkCollectionInTheResourceList(resourceList)) { return; @@ -379,7 +410,7 @@ public class ServiceEBBLoader { } for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { resourceList.add(new Resource(WorkflowType.NETWORK, - service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false)); + service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false, serviceResource)); } } @@ -391,14 +422,15 @@ public class ServiceEBBLoader { return !(service.getPnfCustomizations() == null || service.getPnfCustomizations().isEmpty()); } - private void traverseVnfModules(List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds, + private void traverseVnfModules(List<Resource> resourceList, Resource vnfResource, + List<Pair<WorkflowType, String>> aaiResourceIds, org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf) { if (vnf.getVfModules() == null) { return; } for (VfModule vfModule : vnf.getVfModules()) { aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); - Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false); + Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false, vnfResource); resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean()); resourceList.add(resource); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java index 4b1fdd8da1..1f932743ca 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java @@ -10,6 +10,8 @@ * ================================================================================ * Modifications Copyright (c) 2020 Tech Mahindra * ================================================================================ + * Modifications Copyright (c) 2021 Orange + * ================================================================================ * 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 @@ -89,38 +91,45 @@ public class UserParamsServiceTraversal { private List<Resource> getResourceList(DelegateExecution execution, String serviceModelVersionId, String requestAction, Service validate) { List<Resource> resourceList = new ArrayList<>(); - resourceList.add(new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false)); + Resource serviceResource = + new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false, null); + resourceList.add(serviceResource); if (validate.getResources().getVnfs() != null) { - setResourceListForVnfs(execution, resourceList, validate); + setResourceListForVnfs(execution, resourceList, serviceResource, validate); } if (validate.getResources().getPnfs() != null) { - setResourceListForPnfs(resourceList, validate); + setResourceListForPnfs(resourceList, serviceResource, validate); } if (validate.getResources().getNetworks() != null) { - setResourceListForNetworks(execution, serviceModelVersionId, requestAction, resourceList, validate); + setResourceListForNetworks(execution, serviceModelVersionId, requestAction, resourceList, serviceResource, + validate); } return resourceList; } - private void setResourceListForVnfs(DelegateExecution execution, List<Resource> resourceList, Service validate) { + private void setResourceListForVnfs(DelegateExecution execution, List<Resource> resourceList, + Resource serviceResource, Service validate) { for (Vnfs vnf : validate.getResources().getVnfs()) { setVnfCustomizationUUID(vnf); - resourceList.add(new Resource(WorkflowType.VNF, vnf.getModelInfo().getModelCustomizationId(), false)); - setResourceListForVfModules(execution, resourceList, validate, vnf); + Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getModelInfo().getModelCustomizationId(), false, + serviceResource); + vnfResource.setProcessingPriority(vnf.getProcessingPriority()); + resourceList.add(vnfResource); + setResourceListForVfModules(execution, resourceList, vnfResource, validate, vnf); } } - private void setResourceListForVfModules(DelegateExecution execution, List<Resource> resourceList, Service validate, - Vnfs vnf) { + private void setResourceListForVfModules(DelegateExecution execution, List<Resource> resourceList, + Resource vnfResource, Service validate, Vnfs vnf) { if (vnf.getVfModules() != null) { for (VfModules vfModule : vnf.getVfModules()) { setVfModuleCustomizationUUID(vfModule); VfModuleCustomization vfModuleCustomization = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(vfModuleCustomizationUUID); if (vfModuleCustomization != null && vfModuleCustomization.getVfModule() != null) { - setVolumeGroupWorkFlowTypeToResourceList(resourceList, vfModuleCustomization); - setVfModuleAndConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule, - vfModuleCustomization); + setVolumeGroupWorkFlowTypeToResourceList(resourceList, vnfResource, vfModuleCustomization); + setVfModuleAndConfigurationWorkFlowTypeToResourceList(resourceList, vnfResource, validate, vnf, + vfModule, vfModuleCustomization); if (!foundVfModuleOrVG) { buildAndThrowException(execution, "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null"); @@ -130,46 +139,49 @@ public class UserParamsServiceTraversal { } } - private void setVolumeGroupWorkFlowTypeToResourceList(List<Resource> resourceList, + private void setVolumeGroupWorkFlowTypeToResourceList(List<Resource> resourceList, Resource vnfResource, VfModuleCustomization vfModuleCustomization) { if (vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null && vfModuleCustomization.getVolumeHeatEnv() != null) { foundVfModuleOrVG = true; - resourceList.add( - new Resource(WorkflowType.VOLUMEGROUP, vfModuleCustomization.getModelCustomizationUUID(), false)); + resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, vfModuleCustomization.getModelCustomizationUUID(), + false, vnfResource)); } } - private void setVfModuleAndConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Service validate, - Vnfs vnf, VfModules vfModule, VfModuleCustomization vfModuleCustomization) { + private void setVfModuleAndConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, + Resource vnfResource, Service validate, Vnfs vnf, VfModules vfModule, + VfModuleCustomization vfModuleCustomization) { if ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null && vfModuleCustomization.getHeatEnvironment() != null) || (vfModuleCustomization.getVfModule().getModelName() != null && vfModuleCustomization.getVfModule().getModelName().contains("helm"))) { foundVfModuleOrVG = true; - Resource resource = setVfModuleWorkFlowTypeToResourceList(resourceList, vfModuleCustomization); - setConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule, resource); + Resource resource = + setVfModuleWorkFlowTypeToResourceList(resourceList, vnfResource, vfModuleCustomization, vfModule); + setConfigurationWorkFlowTypeToResourceList(resourceList, vnfResource, validate, vnf, vfModule, resource); } } - private Resource setVfModuleWorkFlowTypeToResourceList(List<Resource> resourceList, - VfModuleCustomization vfModuleCustomization) { - Resource resource = - new Resource(WorkflowType.VFMODULE, vfModuleCustomization.getModelCustomizationUUID(), false); + private Resource setVfModuleWorkFlowTypeToResourceList(List<Resource> resourceList, Resource vnfResource, + VfModuleCustomization vfModuleCustomization, VfModules vfModule) { + Resource resource = new Resource(WorkflowType.VFMODULE, vfModuleCustomization.getModelCustomizationUUID(), + false, vnfResource); + resource.setProcessingPriority(vfModule.getProcessingPriority()); resource.setBaseVfModule(vfModuleCustomization.getVfModule().getIsBase() != null && vfModuleCustomization.getVfModule().getIsBase()); resourceList.add(resource); return resource; } - private void setConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Service validate, Vnfs vnf, - VfModules vfModule, Resource resource) { + private void setConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Resource vnfResource, + Service validate, Vnfs vnf, VfModules vfModule, Resource resource) { if (!vnfCustomizationUUID.isEmpty() && !vfModuleCustomizationUUID.isEmpty()) { List<CvnfcConfigurationCustomization> configs = traverseCatalogDbForConfiguration(validate.getModelInfo().getModelVersionId()); for (CvnfcConfigurationCustomization config : configs) { Resource configResource = new Resource(WorkflowType.CONFIGURATION, - config.getConfigurationResource().getModelUUID(), false); + config.getConfigurationResource().getModelUUID(), false, vnfResource); resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId()); resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId()); resourceList.add(configResource); @@ -193,22 +205,28 @@ public class UserParamsServiceTraversal { } } - private void setResourceListForPnfs(List<Resource> resourceList, Service validate) { + private void setResourceListForPnfs(List<Resource> resourceList, Resource serviceResource, Service validate) { for (Pnfs pnf : validate.getResources().getPnfs()) { - resourceList.add(new Resource(WorkflowType.PNF, pnf.getModelInfo().getModelCustomizationId(), false)); + Resource pnfResource = new Resource(WorkflowType.PNF, pnf.getModelInfo().getModelCustomizationId(), false, + serviceResource); + pnfResource.setProcessingPriority(pnf.getProcessingPriority()); + resourceList.add(pnfResource); } } private void setResourceListForNetworks(DelegateExecution execution, String serviceModelVersionId, - String requestAction, List<Resource> resourceList, Service validate) { + String requestAction, List<Resource> resourceList, Resource serviceResource, Service validate) { for (Networks network : validate.getResources().getNetworks()) { - resourceList - .add(new Resource(WorkflowType.NETWORK, network.getModelInfo().getModelCustomizationId(), false)); + Resource networkResource = new Resource(WorkflowType.NETWORK, + network.getModelInfo().getModelCustomizationId(), false, serviceResource); + networkResource.setProcessingPriority(network.getProcessingPriority()); + resourceList.add(networkResource); } if (requestAction.equals(CREATE_INSTANCE)) { String networkColCustId = queryCatalogDbForNetworkCollection(execution, serviceModelVersionId); if (networkColCustId != null) { - resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false)); + resourceList + .add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false, serviceResource)); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java index b271226414..c1d1d7ad5a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java @@ -10,6 +10,8 @@ * ================================================================================ * Modifications Copyright (c) 2020 Tech Mahindra * ================================================================================ + * Modifications Copyright (c) 2021 Orange + * ================================================================================ * 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 @@ -73,9 +75,11 @@ public class VnfEBBLoader { org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId); ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI); - resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false)); + Resource serviceResource = + new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null); + resourceList.add(serviceResource); if (serviceInstanceMSO.getVnfs() != null) { - findVnfWithGivenId(serviceInstanceMSO, vnfId, aaiResourceIds, resourceList, execution); + findVnfWithGivenId(serviceInstanceMSO, vnfId, aaiResourceIds, resourceList, serviceResource, execution); } } catch (Exception ex) { logger.error("Exception in traverseAAIVnf", ex); @@ -90,10 +94,12 @@ public class VnfEBBLoader { org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceId); ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI); - resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false)); + Resource serviceResource = + new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null); + resourceList.add(serviceResource); if (serviceInstanceMSO.getVnfs() != null) { findVnfWithGivenIdAndAddCustomizationUUID(serviceInstanceMSO, vnfId, aaiResourceIds, resourceList, - execution); + serviceResource, execution); } } catch (Exception ex) { logger.error("Exception in customTraverseAAIVnf", ex); @@ -104,34 +110,38 @@ public class VnfEBBLoader { } private void findVnfWithGivenId(ServiceInstance serviceInstanceMSO, String vnfId, - List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, DelegateExecution execution) { + List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, Resource serviceResource, + DelegateExecution execution) { for (GenericVnf vnf : serviceInstanceMSO.getVnfs()) { if (vnf.getVnfId().equals(vnfId)) { aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); - resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false)); - processVfModules(vnf, aaiResourceIds, resourceList, execution); - processVolumeGroups(vnf, aaiResourceIds, resourceList); + Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getVnfId(), false, serviceResource); + resourceList.add(vnfResource); + processVfModules(vnf, aaiResourceIds, resourceList, vnfResource, execution); + processVolumeGroups(vnf, aaiResourceIds, resourceList, vnfResource); break; } } } private void findVnfWithGivenIdAndAddCustomizationUUID(ServiceInstance serviceInstanceMSO, String vnfId, - List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, DelegateExecution execution) { + List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, Resource serviceResource, + DelegateExecution execution) { for (GenericVnf vnf : serviceInstanceMSO.getVnfs()) { if (vnf.getVnfId().equals(vnfId)) { aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); - resourceList.add(new Resource(WorkflowType.VNF, - bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(), false)); - processVfModules(vnf, aaiResourceIds, resourceList, execution); - processVolumeGroups(vnf, aaiResourceIds, resourceList); + Resource vnfResource = new Resource(WorkflowType.VNF, + bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(), false, serviceResource); + resourceList.add(vnfResource); + processVfModules(vnf, aaiResourceIds, resourceList, vnfResource, execution); + processVolumeGroups(vnf, aaiResourceIds, resourceList, vnfResource); break; } } } private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId, - List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds) { + List<Resource> resourceList, Resource vfModuleResource, List<Pair<WorkflowType, String>> aaiResourceIds) { try { org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId); AAIResultWrapper vfModuleWrapper = new AAIResultWrapper( @@ -140,7 +150,7 @@ public class VnfEBBLoader { relationshipsOp = vfModuleWrapper.getRelationships(); if (relationshipsOp.isPresent()) { relationshipsOp = workflowActionUtils.extractRelationshipsVnfc(relationshipsOp.get()); - addConfigToResources(relationshipsOp, resourceList, aaiResourceIds); + addConfigToResources(relationshipsOp, resourceList, vfModuleResource, aaiResourceIds); } } catch (Exception ex) { logger.error("Exception in findConfigurationsInsideVfModule", ex); @@ -149,35 +159,39 @@ public class VnfEBBLoader { } private void processVfModules(GenericVnf vnf, List<Pair<WorkflowType, String>> aaiResourceIds, - List<Resource> resourceList, DelegateExecution execution) { + List<Resource> resourceList, Resource vnfResource, DelegateExecution execution) { if (vnf.getVfModules() != null) { for (VfModule vfModule : vnf.getVfModules()) { aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); - resourceList.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false)); + Resource vfModuleResource = + new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false, vnfResource); + resourceList.add(vfModuleResource); findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(), resourceList, - aaiResourceIds); + vfModuleResource, aaiResourceIds); } } } private void processVolumeGroups(GenericVnf vnf, List<Pair<WorkflowType, String>> aaiResourceIds, - List<Resource> resourceList) { + List<Resource> resourceList, Resource vnfResource) { if (vnf.getVolumeGroups() != null) { for (VolumeGroup volumeGroup : vnf.getVolumeGroups()) { aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId())); - resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false)); + resourceList.add( + new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false, vnfResource)); } } } private void addConfigToResources(Optional<Relationships> relationshipsOp, List<Resource> resourceList, - List<Pair<WorkflowType, String>> aaiResourceIds) { + Resource vfModuleResource, List<Pair<WorkflowType, String>> aaiResourceIds) { if (relationshipsOp.isPresent()) { Optional<Configuration> config = workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get()); if (config.isPresent()) { aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.get().getConfigurationId())); - resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false)); + resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false, + vfModuleResource)); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java index f4b2a8b4b1..c4fbdc5359 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java @@ -7,83 +7,89 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"rb-name", "rb-version", "profile-name", "release-name", "cloud-region", "labels", - "override-values"}) public class InstanceRequest { @JsonProperty("modelInvariantId") - private String rbName; + private String modelInvariantId; @JsonProperty("modelVersionId") - private String rbVersion; + private String modelVersionId; + @JsonProperty("modelCustomizationId") + private String modelCustomizationId; @JsonProperty("k8sRBProfileName") private String profileName; @JsonProperty("k8sRBInstanceReleaseName") private String releaseName; + @JsonProperty("k8sRBInstanceStatusCheck") + private Boolean statusCheck = false; @JsonProperty("vfModuleUUID") private String vfModuleUUID; @JsonProperty("cloudRegionId") private String cloudRegion; @JsonProperty("labels") private Map<String, String> labels; - @JsonProperty(value = "override-values") + @JsonProperty("override-values") private Map<String, String> overrideValues; - @JsonProperty("rb-name") - public String getRbName() { - return rbName; + public String getModelInvariantId() { + return modelInvariantId; } - @JsonProperty("rb-name") - public void setRbName(String rbName) { - this.rbName = rbName; + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; } - @JsonProperty("rb-version") - public String getRbVersion() { - return rbVersion; + public String getModelVersionId() { + return modelVersionId; } - @JsonProperty("rb-version") - public void setRbVersion(String rbVersion) { - this.rbVersion = rbVersion; + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + public String getModelCustomizationId() { + return modelCustomizationId; + } + + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; } - @JsonProperty("profile-name") public String getProfileName() { return profileName; } - @JsonProperty("profile-name") public void setProfileName(String profileName) { this.profileName = profileName; } - @JsonProperty("release-name") + public Boolean getStatusCheck() { + return statusCheck; + } + + public void setStatusCheck(Boolean statusCheck) { + this.statusCheck = statusCheck; + } + public String getReleaseName() { return releaseName; } - @JsonProperty("release-name") public void setReleaseName(String releaseName) { this.releaseName = releaseName; } - @JsonProperty("cloud-region") public String getCloudRegion() { return cloudRegion; } - @JsonProperty("cloud-region") public void setCloudRegion(String cloudRegion) { this.cloudRegion = cloudRegion; } - @JsonProperty("labels") public Map<String, String> getLabels() { return labels; } - @JsonProperty("labels") public void setLabels(Map<String, String> labels) { this.labels = labels; } |