use of org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE in project so by onap.
the class WorkflowAction method loadExecuteBuildingBlocksForMacro.
private List<ExecuteBuildingBlock> loadExecuteBuildingBlocksForMacro(ServiceInstancesRequest sIRequest, WorkflowType resourceType, String requestAction, DelegateExecution execution, String serviceInstanceId, String resourceId, WorkflowResourceIds workflowResourceIds, List<OrchestrationFlow> orchFlows, String cloudOwner, String serviceType, String requestId, String apiVersion, String vnfType, RequestDetails requestDetails) throws IOException, VrfBondingServiceException {
List<ExecuteBuildingBlock> flowsToExecute;
List<Resource> resourceList = new ArrayList<>();
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
if (resourceType == WorkflowType.SERVICE || isVNFCreate(resourceType, requestAction)) {
resourceList = serviceEBBLoader.getResourceListForService(sIRequest, requestAction, execution, serviceInstanceId, resourceId, aaiResourceIds);
} else if (resourceType == WorkflowType.VNF && (DELETE_INSTANCE.equalsIgnoreCase(requestAction) || REPLACEINSTANCE.equalsIgnoreCase(requestAction) || (RECREATE_INSTANCE.equalsIgnoreCase(requestAction)))) {
vnfEBBLoader.traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds);
} else if (resourceType == WorkflowType.VNF && UPDATE_INSTANCE.equalsIgnoreCase(requestAction)) {
vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds);
} else if (resourceType == WorkflowType.VNF && HEALTH_CHECK.equalsIgnoreCase(requestAction)) {
vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds);
} else if (resourceType == WorkflowType.VNF && UPGRADE_CNF.equalsIgnoreCase(requestAction)) {
vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds);
} else {
buildAndThrowException(execution, "Current Macro Request is not supported");
}
StringBuilder foundObjects = new StringBuilder();
for (WorkflowType type : WorkflowType.values()) {
foundObjects.append(type).append(" - ").append((int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count()).append(" ");
}
logger.info("Found {}", foundObjects);
if (orchFlows == null || orchFlows.isEmpty()) {
orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, false, cloudOwner, serviceType);
}
boolean vnfReplace = false;
if (resourceType.equals(WorkflowType.VNF) && (REPLACEINSTANCE.equalsIgnoreCase(requestAction) || REPLACEINSTANCERETAINASSIGNMENTS.equalsIgnoreCase(requestAction))) {
vnfReplace = true;
}
flowsToExecute = executeBuildingBlockBuilder.buildExecuteBuildingBlockList(orchFlows, resourceList, requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace);
if (serviceEBBLoader.isNetworkCollectionInTheResourceList(resourceList)) {
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)) && resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
execution.setVariable(HOMING, true);
execution.setVariable("calledHoming", false);
}
if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE) || requestAction.equalsIgnoreCase(CREATE_INSTANCE))) {
generateResourceIds(flowsToExecute, resourceList, serviceInstanceId);
} else {
updateResourceIdsFromAAITraversal(flowsToExecute, resourceList, aaiResourceIds, serviceInstanceId);
}
execution.setVariable("resources", resourceList);
return flowsToExecute;
}
Aggregations