use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock 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.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class WorkflowActionBBTasks method postProcessingExecuteBBActivateVfModule.
protected void postProcessingExecuteBBActivateVfModule(DelegateExecution execution, ExecuteBuildingBlock ebb, List<ExecuteBuildingBlock> flowsToExecute) {
try {
String requestAction = (String) execution.getVariable(BBConstants.G_ACTION);
String serviceInstanceId = ebb.getWorkflowResourceIds().getServiceInstanceId();
String vnfId = ebb.getWorkflowResourceIds().getVnfId();
String vfModuleId = ebb.getResourceId();
ebb.getWorkflowResourceIds().setVfModuleId(vfModuleId);
String serviceModelUUID = "";
String vnfCustomizationUUID = "";
String vfModuleCustomizationUUID = "";
if (requestAction.equalsIgnoreCase("replaceInstance") || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) {
for (RelatedInstanceList relatedInstList : ebb.getRequestDetails().getRelatedInstanceList()) {
RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
vnfCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
}
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) {
serviceModelUUID = relatedInstance.getModelInfo().getModelVersionId();
}
}
vfModuleCustomizationUUID = ebb.getRequestDetails().getModelInfo().getModelCustomizationId();
} else {
serviceModelUUID = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId).getModelVersionId();
vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
vfModuleCustomizationUUID = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
}
List<Vnfc> vnfcs = workflowAction.getRelatedResourcesInVfModule(vnfId, vfModuleId, Vnfc.class, Types.VNFC);
logger.debug("Vnfc Size: {}", vnfcs.size());
for (Vnfc vnfc : vnfcs) {
String modelCustomizationId = vnfc.getModelCustomizationId();
logger.debug("Processing Vnfc: {}", modelCustomizationId);
CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization(serviceModelUUID, vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId);
if (fabricConfig != null && fabricConfig.getConfigurationResource() != null && fabricConfig.getConfigurationResource().getToscaNodeType() != null && fabricConfig.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
String configurationId = getConfigurationId(vnfc);
ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId);
configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID);
configurationResourceKeys.setVnfResourceCustomizationUUID(vnfCustomizationUUID);
configurationResourceKeys.setVnfcName(vnfc.getVnfcName());
ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb, configurationId, configurationResourceKeys);
flowsToExecute.add(addConfigBB);
flowsToExecute.stream().forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}", executeBB.getBuildingBlock().getBpmnFlowName()));
execution.setVariable("flowsToExecute", flowsToExecute);
execution.setVariable(COMPLETED, false);
} else {
logger.debug("No cvnfcCustomization found for customizationId: {}", modelCustomizationId);
}
}
} catch (EntityNotFoundException e) {
logger.debug("Will not be running Fabric Config Building Blocks", e);
} catch (Exception e) {
String errorMessage = "Error occurred in post processing of Vf Module create";
execution.setVariable(HANDLINGCODE, ROLLBACKTOCREATED);
execution.setVariable("WorkflowActionErrorMessage", errorMessage);
logger.error(errorMessage, e);
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class WorkflowActionBBTasks method rollbackExecutionPath.
/**
* Rollback will only handle Create/Activate/Assign Macro flows. Execute layer will rollback the flow its currently
* working on.
*/
public void rollbackExecutionPath(DelegateExecution execution) {
final String action = (String) execution.getVariable(BBConstants.G_ACTION);
final String resourceName = (String) execution.getVariable("resourceName");
if (!(boolean) execution.getVariable("isRollback")) {
List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
List<ExecuteBuildingBlock> flowsToExecuteChangeBBs = flowsToExecute.stream().filter(buildingBlock -> buildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")).collect(Collectors.toList());
List<ExecuteBuildingBlock> rollbackFlows = new ArrayList<>();
int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
int listSize = flowsToExecute.size();
for (int i = listSize - 1; i >= 0; i--) {
if (i > currentSequence - 1) {
flowsToExecute.remove(i);
} else {
String flowName = flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName();
if (flowName.startsWith("Assign")) {
flowName = flowName.replaceFirst("Assign", "Unassign");
} else if (flowName.startsWith("Create")) {
flowName = flowName.replaceFirst("Create", "Delete");
} else if (flowName.startsWith("Activate")) {
flowName = flowName.replaceFirst("Activate", "Deactivate");
} else if (flowName.startsWith("Add")) {
flowName = flowName.replaceFirst("Add", "Delete");
} else if (flowName.startsWith("VNF")) {
if (flowName.startsWith("VNFSet")) {
flowName = flowName.replaceFirst("VNFSet", "VNFUnset");
} else if (flowName.startsWith("VNFLock")) {
flowName = flowName.replaceFirst("VNFLock", "VNFUnlock");
} else if (flowName.startsWith("VNFStop")) {
flowName = flowName.replaceFirst("VNFStop", "VNFStart");
} else if (flowName.startsWith("VNFQuiesce")) {
flowName = flowName.replaceFirst("VNFQuiesce", "VNFResume");
} else {
continue;
}
} else {
continue;
}
flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(flowName);
rollbackFlows.add(flowsToExecute.get(i));
}
}
String handlingCode = (String) execution.getVariable(HANDLINGCODE);
List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>(rollbackFlows);
if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode) || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)) {
for (ExecuteBuildingBlock rollbackFlow : rollbackFlows) {
if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Unassign") && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) {
rollbackFlowsFiltered.remove(rollbackFlow);
} else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Delete") && ((!rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") && (ROLLBACKTOCREATED.equals(handlingCode) || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode))) || (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") && ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)))) {
rollbackFlowsFiltered.remove(rollbackFlow);
}
}
}
List<ExecuteBuildingBlock> rollbackFlowsFilteredNonChangeBBs = new ArrayList<>();
if (action.equals(REPLACEINSTANCE) && resourceName.equals(VFMODULE)) {
for (ExecuteBuildingBlock executeBuildingBlock : rollbackFlowsFiltered) {
if (!executeBuildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")) {
rollbackFlowsFilteredNonChangeBBs.add(executeBuildingBlock);
}
}
rollbackFlowsFiltered.clear();
rollbackFlowsFiltered.addAll(flowsToExecuteChangeBBs);
rollbackFlowsFiltered.addAll(rollbackFlowsFilteredNonChangeBBs);
}
workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
execution.setVariable("isRollbackNeeded", !rollbackFlows.isEmpty());
execution.setVariable("flowsToExecute", rollbackFlowsFiltered);
execution.setVariable(HANDLINGCODE, "PreformingRollback");
execution.setVariable("isRollback", true);
execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0);
execution.setVariable(RETRY_COUNT, 0);
} else {
workflowAction.buildAndThrowException(execution, "Rollback has already been called. Cannot rollback a request that is currently in the rollback state.");
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class WorkflowActionBBTasks method getUpdatedRequest.
protected InfraActiveRequests getUpdatedRequest(DelegateExecution execution, int currentSequence) {
List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
ExecuteBuildingBlock completedBB = flowsToExecute.get(currentSequence - 2);
ExecuteBuildingBlock nextBB = flowsToExecute.get(currentSequence - 1);
int completedBBs = currentSequence - 1;
int totalBBs = flowsToExecute.size();
int remainingBBs = totalBBs - completedBBs;
String statusMessage = this.getStatusMessage(completedBB.getBuildingBlock().getBpmnFlowName(), nextBB.getBuildingBlock().getBpmnFlowName(), completedBBs, remainingBBs);
Long percentProgress = this.getPercentProgress(completedBBs, totalBBs);
request.setFlowStatus(statusMessage);
request.setProgress(percentProgress);
request.setLastModifiedBy("CamundaBPMN");
return request;
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class ExecuteBuildingBlockBuilder method buildExecuteBuildingBlock.
protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration, ReplaceInstanceRelatedInformation replaceInfo) {
BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString()).setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey).setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse(""));
Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(buildingBlock::setBpmnAction);
Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(buildingBlock::setBpmnScope);
String oldVolumeGroupName = "";
if (replaceInfo != null) {
oldVolumeGroupName = replaceInfo.getOldVolumeGroupName();
}
if (resource != null && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) {
logger.debug("Setting resourceId to volume group id for volume group flow on replace");
resourceId = workflowResourceIds.getVolumeGroupId();
}
ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion).setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock).setRequestDetails(requestDetails).setOldVolumeGroupName(oldVolumeGroupName);
if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) {
ConfigurationResourceKeys configurationResourceKeys = getConfigurationResourceKeys(resource, vnfcName);
executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
}
return executeBuildingBlock;
}
Aggregations