use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class ExecuteBuildingBlockBuilder method buildExecuteBuildingBlockList.
protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows, 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) {
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;
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class WorkflowActionBBFailure method updateRequestStatusToFailed.
public void updateRequestStatusToFailed(DelegateExecution execution) {
try {
String requestId = (String) execution.getVariable("mso-request-id");
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
String rollbackErrorMsg = "";
String errorMsg = "";
Boolean rollbackCompletedSuccessfully = (Boolean) execution.getVariable("isRollbackComplete");
Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback");
ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
if (rollbackCompletedSuccessfully == null)
rollbackCompletedSuccessfully = false;
if (isRollbackFailure == null)
isRollbackFailure = false;
if (rollbackCompletedSuccessfully) {
rollbackErrorMsg = "Rollback has been completed successfully.";
request.setRollbackStatusMessage(rollbackErrorMsg);
execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
String rollbackTargetState = (String) execution.getVariable(ROLLBACK_TARGET_STATE);
request.setRequestStatus(rollbackTargetState);
} else if (isRollbackFailure) {
if (ebb != null && ebb.getBuildingBlock() != null && ebb.getBuildingBlock().getBpmnFlowName() != null) {
String flowName = ebb.getBuildingBlock().getBpmnFlowName();
if (DEACTIVATE_FABRIC_CONFIGURATION_FLOW.equalsIgnoreCase(flowName) || UNASSIGN_FABRIC_CONFIGURATION_FLOW.equalsIgnoreCase(flowName) || DELETE_FABRIC_CONFIGURATION_FLOW.equalsIgnoreCase(flowName)) {
String statusMessage = String.format("%s Warning: The vf-module is active but configuration was not removed completely for one or more VMs.", request.getStatusMessage());
request.setStatusMessage(statusMessage);
}
}
Optional<String> rollbackErrorMsgOp = retrieveErrorMessage(execution);
if (rollbackErrorMsgOp.isPresent()) {
rollbackErrorMsg = rollbackErrorMsgOp.get();
} else {
rollbackErrorMsg = "Failed to determine rollback error message.";
}
request.setRollbackStatusMessage(rollbackErrorMsg);
execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
request.setRequestStatus(Status.FAILED.toString());
} else {
Optional<String> errorMsgOp = retrieveErrorMessage(execution);
if (errorMsgOp.isPresent()) {
errorMsg = errorMsgOp.get();
} else {
errorMsg = "Failed to determine error message";
}
request.setStatusMessage(errorMsg);
execution.setVariable("ErrorMessage", errorMsg);
String handlingCode = (String) execution.getVariable("handlingCode");
if ("Abort".equalsIgnoreCase(handlingCode)) {
request.setRequestStatus(Status.ABORTED.toString());
} else {
request.setRequestStatus(Status.FAILED.toString());
}
}
if (ebb != null && ebb.getBuildingBlock() != null) {
String flowStatus = "";
if (rollbackCompletedSuccessfully) {
flowStatus = "All Rollback flows have completed successfully";
} else {
flowStatus = ebb.getBuildingBlock().getBpmnFlowName() + " has failed.";
}
request.setFlowStatus(flowStatus);
execution.setVariable("flowStatus", flowStatus);
}
request.setProgress(Long.valueOf(100));
request.setLastModifiedBy("CamundaBPMN");
request.setEndTime(new Timestamp(System.currentTimeMillis()));
requestDbclient.updateInfraActiveRequests(request);
} catch (Exception e) {
workflowAction.buildAndThrowException(execution, "Error Updating Request Database", e);
}
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class WorkflowActionTest method selectExecutionListNetworkCollectionMacroCreate.
@Ignore
@Test
public void selectExecutionListNetworkCollectionMacroCreate() throws Exception {
String gAction = "createInstance";
String resource = "NetworkCollection";
String bpmnRequest = readBpmnRequestFromFile(MACRO_CREATE_NETWORK_COLLECTION_JSON);
initExecution(gAction, bpmnRequest, false);
execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkCollectionBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
Service service = new Service();
CollectionResourceCustomization collectionResourceCustomization = new CollectionResourceCustomization();
CollectionResource collectionResource = new CollectionResource();
collectionResource.setToscaNodeType("Data NetworkCollection Data");
collectionResourceCustomization.setCollectionResource(collectionResource);
service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "CreateNetworkCollectionBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB");
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class WorkflowActionTest method selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest.
@Test
public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest() throws Exception {
String gAction = "replaceInstanceRetainAssignments";
String resource = "VfModule";
String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON);
initExecution(gAction, bpmnRequest, true);
execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
execution.setVariable("vfModuleId", "1234");
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
doReturn(Optional.of(volumeGroup)).when(bbSetupUtils).getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
vfModule.setVolumeHeatTemplate(new HeatTemplate());
vfModuleCustomization.setVfModule(vfModule);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(vfModuleCustomization);
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "ChangeModelVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
}
use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.
the class WorkflowActionTest method selectExecutionListALaCarteVfModuleNoFabricDeleteTest.
@Test
public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception {
String gAction = "deleteInstance";
String resource = "VfModule";
String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON);
initExecution(gAction, bpmnRequest, true);
execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB", "DeleteFabricConfigurationBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
vnf.setVnfId("vnf0");
vnf.setModelCustomizationId("modelCustomizationId");
when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
vfModule.setModelCustomizationId("modelCustomizationId");
when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
SPY_workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB");
}
Aggregations