Search in sources :

Example 26 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow 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;
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArrayList(java.util.ArrayList) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow)

Example 27 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow 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");
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Service(org.onap.so.db.catalog.beans.Service) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) Ignore(org.junit.Ignore) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 28 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow 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");
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) VfModule(org.onap.aai.domain.yang.VfModule) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) VfModule(org.onap.aai.domain.yang.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 29 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class WorkflowActionTest method selectExecutionListVnfMacroRecreateTest.

@Test
public void selectExecutionListVnfMacroRecreateTest() throws Exception {
    String gAction = "recreateInstance";
    String resource = "Vnf";
    String bpmnRequest = readBpmnRequestFromFile(MACRO_VNF_MACRO_REPLACE_JSON);
    initExecution(gAction, bpmnRequest, false);
    execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/recreate");
    execution.setVariable("serviceInstanceId", "123");
    execution.setVariable("vnfId", "1234");
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ActivateVnfBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    ServiceInstance serviceInstanceAAI = new ServiceInstance();
    serviceInstanceAAI.setServiceInstanceId("123");
    org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance();
    org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf();
    vnf.setVnfId("1234");
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
    vfModule.setVfModuleId("vfModule1");
    vnf.getVfModules().add(vfModule);
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = new org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule();
    vfModule2.setVfModuleId("vfModule2");
    vnf.getVfModules().add(vfModule2);
    serviceInstanceMSO.getVnfs().add(vnf);
    org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
    aaiVfModule.setIsBaseVfModule(false);
    doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any());
    doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(bbSetupUtils).getAAIGenericVnf(vnf.getVnfId());
    doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
    doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "cloud-owner")).thenReturn(northBoundRequest);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) GenericVnf(org.onap.aai.domain.yang.GenericVnf) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) VfModule(org.onap.aai.domain.yang.VfModule) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) VfModule(org.onap.aai.domain.yang.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 30 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class WorkflowActionTest method getConfigBuildingBlocksNullConfigurationTest.

@Test
public void getConfigBuildingBlocksNullConfigurationTest() throws Exception {
    String gAction = "deleteInstance";
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
    WorkflowType resourceType = WorkflowType.VFMODULE;
    execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
    execution.setVariable("requestAction", gAction);
    String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
    execution.setVariable("bpmnRequest", bpmnRequest);
    execution.setVariable("vnfId", "1234");
    execution.setVariable("vfModuleId", "vfModuleId1234");
    execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
    ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
    RequestDetails requestDetails = sIRequest.getRequestDetails();
    String requestAction = "deleteInstance";
    String requestId = "9c944122-d161-4280-8594-48c06a9d96d5";
    boolean aLaCarte = true;
    String apiVersion = "7";
    String vnfType = "vnfType";
    String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
    String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
    Resource resourceKey = new Resource(resourceType, key, aLaCarte, null);
    WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
    List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB", "DeleteFabricConfigurationBB");
    ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion).setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution);
    org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
    vnf.setVnfId("vnf0");
    vnf.setModelCustomizationId("modelCustomizationId");
    when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf);
    org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
    vfModule.setModelCustomizationId("modelCustomizationId");
    /* this is a test case where configuration for vnfc is null */
    org.onap.aai.domain.yang.Configuration config1 = null;
    org.onap.aai.domain.yang.Configuration config2 = new org.onap.aai.domain.yang.Configuration();
    config2.setConfigurationId("config2");
    List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
    org.onap.aai.domain.yang.Vnfc vnfc1 = new org.onap.aai.domain.yang.Vnfc();
    vnfc1.setVnfcName("zauk53avetd02svm001");
    org.onap.aai.domain.yang.Vnfc vnfc2 = new org.onap.aai.domain.yang.Vnfc();
    vnfc2.setVnfcName("zauk53avetd02tvm001");
    vnfcs.add(vnfc1);
    vnfcs.add(vnfc2);
    when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule);
    doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), eq(org.onap.aai.domain.yang.Vnfc.class), eq(Types.VNFC));
    doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1), eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION));
    doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2), eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION));
    List<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj);
    assertFalse(results.isEmpty());
    assertEquals(1, results.size());
    assertEquals("config2", results.get(0).getWorkflowResourceIds().getConfigurationId());
    assertEquals("zauk53avetd02tvm001", results.get(0).getConfigurationResourceKeys().getVnfcName());
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) VfModule(org.onap.aai.domain.yang.VfModule) VfModule(org.onap.aai.domain.yang.VfModule) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GenericVnf(org.onap.aai.domain.yang.GenericVnf) ConfigurationResource(org.onap.so.db.catalog.beans.ConfigurationResource) CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)44 ArrayList (java.util.ArrayList)39 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)37 Test (org.junit.Test)33 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)32 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)32 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)31 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)31 List (java.util.List)30 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)27 RelationshipList (org.onap.aai.domain.yang.RelationshipList)27 VfModule (org.onap.aai.domain.yang.VfModule)15 GenericVnf (org.onap.aai.domain.yang.GenericVnf)11 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)9 Service (org.onap.so.db.catalog.beans.Service)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)8 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)8 VolumeGroup (org.onap.aai.domain.yang.VolumeGroup)7 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)7