use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowAction method loadExecuteBuildingBlocksForAlaCarte.
private List<ExecuteBuildingBlock> loadExecuteBuildingBlocksForAlaCarte(List<OrchestrationFlow> orchFlows, DelegateExecution execution, String requestAction, WorkflowType resourceType, String cloudOwner, String serviceType, ServiceInstancesRequest sIRequest, String requestId, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, String resourceId, String vnfType, String apiVersion) throws Exception {
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
if (orchFlows == null || orchFlows.isEmpty()) {
orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true, cloudOwner, serviceType);
}
Resource resourceKey = getResourceKey(sIRequest, resourceType);
ReplaceInstanceRelatedInformation replaceInfo = new ReplaceInstanceRelatedInformation();
if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) && resourceType.equals(WorkflowType.VFMODULE)) {
logger.debug("Build a BB list for replacing BB modules");
ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution, sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId, vnfType, orchFlows, apiVersion, resourceKey, replaceInfo);
orchFlows = getVfModuleReplaceBuildingBlocks(cbbdo);
createBuildingBlocksForOrchFlows(execution, sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId, flowsToExecute, vnfType, orchFlows, apiVersion, resourceKey, replaceInfo);
} else {
if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATE_INSTANCE)) {
addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId, flowsToExecute, vnfType, apiVersion, resourceKey, replaceInfo, orchFlows);
}
orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
for (OrchestrationFlow orchFlow : orchFlows) {
ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, requestDetails, false, null, null, false, replaceInfo);
flowsToExecute.add(ebb);
}
}
return flowsToExecute;
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow 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;
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowAction method queryNorthBoundRequestCatalogDb.
protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction, WorkflowType resourceName, boolean aLaCarte, String cloudOwner, String serviceType) {
List<OrchestrationFlow> listToExecute = new ArrayList<>();
NorthBoundRequest northBoundRequest;
if (serviceType.equalsIgnoreCase(SERVICE_TYPE_TRANSPORT) || serviceType.equalsIgnoreCase(SERVICE_TYPE_BONDING)) {
northBoundRequest = catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType(requestAction, resourceName.toString(), aLaCarte, cloudOwner, serviceType);
} else {
northBoundRequest = catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(requestAction, resourceName.toString(), aLaCarte, cloudOwner);
}
if (northBoundRequest == null) {
northBoundRequest = catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(requestAction, resourceName.toString(), aLaCarte, CLOUD_OWNER);
}
if (northBoundRequest == null) {
buildAndThrowException(execution, String.format("The request: %s %s %s is not supported by GR_API.", (aLaCarte ? "AlaCarte" : "Macro"), resourceName, requestAction));
} else {
if (northBoundRequest.getIsToplevelflow() != null) {
execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, northBoundRequest.getIsToplevelflow());
}
List<OrchestrationFlow> flows = northBoundRequest.getOrchestrationFlowList();
if (flows == null) {
flows = new ArrayList<>();
} else {
flows.sort(Comparator.comparingInt(OrchestrationFlow::getSequenceNumber));
}
for (OrchestrationFlow flow : flows) {
if (!flow.getFlowName().contains("BB") && !flow.getFlowName().contains("Activity")) {
List<OrchestrationFlow> macroQueryFlows = catalogDbClient.getOrchestrationFlowByAction(flow.getFlowName());
listToExecute.addAll(macroQueryFlows);
} else {
listToExecute.add(flow);
}
}
}
return listToExecute;
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowAction method createBuildingBlocksForOrchFlows.
private void createBuildingBlocksForOrchFlows(DelegateExecution execution, ServiceInstancesRequest sIRequest, String requestId, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, String requestAction, String resourceId, List<ExecuteBuildingBlock> flowsToExecute, String vnfType, List<OrchestrationFlow> orchFlows, String apiVersion, Resource resourceKey, ReplaceInstanceRelatedInformation replaceInfo) throws Exception {
for (OrchestrationFlow orchFlow : orchFlows) {
if (orchFlow.getFlowName().contains(CONFIGURATION)) {
List<OrchestrationFlow> configOrchFlows = new ArrayList<>();
configOrchFlows.add(orchFlow);
addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId, flowsToExecute, vnfType, apiVersion, resourceKey, replaceInfo, configOrchFlows);
} else {
ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, requestDetails, false, null, null, false, replaceInfo);
flowsToExecute.add(ebb);
}
}
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowAction method getVfModuleReplaceBuildingBlocks.
protected List<OrchestrationFlow> getVfModuleReplaceBuildingBlocks(ConfigBuildingBlocksDataObject dataObj) throws Exception {
String vnfId = dataObj.getWorkflowResourceIds().getVnfId();
String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId();
logger.debug("BUILDING REPLACE LIST");
boolean volumeGroupExisted = false;
boolean volumeGroupWillExist = false;
boolean keepVolumeGroup = false;
boolean rebuildVolumeGroups = false;
if (dataObj.getRequestDetails().getRequestParameters() != null && dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups() != null) {
rebuildVolumeGroups = dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups();
}
String volumeGroupName = "";
Optional<VolumeGroup> volumeGroupFromVfModule = bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, vfModuleId);
if (volumeGroupFromVfModule.isPresent()) {
String volumeGroupId = volumeGroupFromVfModule.get().getVolumeGroupId();
volumeGroupName = volumeGroupFromVfModule.get().getVolumeGroupName();
logger.debug("Volume group id of the existing volume group is: {}", volumeGroupId);
volumeGroupExisted = true;
dataObj.getWorkflowResourceIds().setVolumeGroupId(volumeGroupId);
dataObj.getReplaceInformation().setOldVolumeGroupName(volumeGroupName);
}
List<OrchestrationFlow> orchFlows = dataObj.getOrchFlows();
VfModuleCustomization vfModuleCustomization = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(dataObj.getRequestDetails().getModelInfo().getModelCustomizationUuid());
if (vfModuleCustomization != null && vfModuleCustomization.getVfModule() != null && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null && vfModuleCustomization.getVolumeHeatEnv() != null) {
volumeGroupWillExist = true;
if (!volumeGroupExisted) {
String newVolumeGroupId = UUID.randomUUID().toString();
dataObj.getWorkflowResourceIds().setVolumeGroupId(newVolumeGroupId);
dataObj.getReplaceInformation().setOldVolumeGroupName(volumeGroupName);
logger.debug("newVolumeGroupId: {}", newVolumeGroupId);
}
}
if (volumeGroupExisted && volumeGroupWillExist && !rebuildVolumeGroups) {
keepVolumeGroup = true;
}
if (!volumeGroupExisted || keepVolumeGroup) {
logger.debug("Filtering out deletion of volume groups");
orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().matches(VOLUMEGROUP_DELETE_PATTERN)).collect(Collectors.toList());
}
if (!volumeGroupWillExist || keepVolumeGroup) {
logger.debug("Filtering out creation of volume groups");
orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().matches(VOLUMEGROUP_CREATE_PATTERN)).collect(Collectors.toList());
}
return orchFlows;
}
Aggregations