Search in sources :

Example 26 with VfModule

use of org.onap.aai.domain.yang.VfModule 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")) {
        workflowAction.buildAndThrowException(execution, "Rollback has already been called. Cannot rollback a request that is currently in the rollback state.");
    }
    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();
    List<BuildingBlockRollback> bbRollbackList = catalogDbClient.getBuildingBlockRollbackEntries();
    for (int i = listSize - 1; i >= 0; i--) {
        if (i > currentSequence - 1) {
            flowsToExecute.remove(i);
        } else {
            // filter bbRollbackList for bbrollback, and check if action exists, then filter by action
            BuildingBlock bb = flowsToExecute.get(i).getBuildingBlock();
            String flowName = bb.getBpmnFlowName();
            String scope = Objects.toString(bb.getBpmnScope(), "");
            String bbAction = Objects.toString(bb.getBpmnAction(), "");
            ExecuteBuildingBlock currentBB = (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
            List<BuildingBlockRollback> filteredList = bbRollbackList.stream().filter(k -> k.getBuildingBlockName().equals((flowName))).collect(Collectors.toList());
            Optional<BuildingBlockRollback> matchedBBRollback = "".equals(bbAction) ? filteredList.stream().findFirst() : filteredList.stream().filter(k -> bbAction.equals(k.getAction())).findFirst();
            if (matchedBBRollback.isPresent()) {
                final BuildingBlockRollback buildingBlockRollbackItem = matchedBBRollback.get();
                String rollbackFlow = buildingBlockRollbackItem.getRollbackBuildingBlockName();
                flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(rollbackFlow);
                // if we have an action, search the filtered list for the bbrollback that matches the given action.
                if (null != buildingBlockRollbackItem.getRollbackAction()) {
                    logger.info("Setting rollback_action {} for BB: {} action: {}", buildingBlockRollbackItem.getRollbackAction(), buildingBlockRollbackItem.getBuildingBlockName(), buildingBlockRollbackItem.getAction());
                    flowsToExecute.get(i).getBuildingBlock().setBpmnAction(buildingBlockRollbackItem.getRollbackAction());
                }
                rollbackFlows.add(flowsToExecute.get(i));
            }
        }
    }
    String handlingCode = (String) execution.getVariable(HANDLINGCODE);
    List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>(rollbackFlows);
    if (ROLLBACK_TO_ASSIGNED.equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode) || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)) {
        for (ExecuteBuildingBlock rollbackFlow : rollbackFlows) {
            if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains(UNASSIGN) && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains(FABRIC_CONFIGURATION)) {
                rollbackFlowsFiltered.remove(rollbackFlow);
            } else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains(DELETE) && ((!rollbackFlow.getBuildingBlock().getBpmnFlowName().contains(FABRIC_CONFIGURATION) && (ROLLBACKTOCREATED.equals(handlingCode) || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode))) || (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains(FABRIC_CONFIGURATION) && 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);
    }
    logger.info("List of BuildingBlocks to execute for rollback");
    rollbackFlowsFiltered.forEach(item -> {
        logger.info(item.getBuildingBlock().getBpmnFlowName());
    });
    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);
}
Also used : ServiceInstance(org.onap.aai.domain.yang.ServiceInstance) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) BBConstants(org.onap.so.bpmn.common.BBConstants) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) Configuration(org.onap.aaiclient.client.aai.entities.Configuration) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) VfModule(org.onap.aai.domain.yang.VfModule) Vnfc(org.onap.aai.domain.yang.Vnfc) ArrayList(java.util.ArrayList) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) RequestsDbListenerRunner(org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner) FlowManipulatorListenerRunner(org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) EntityNotFoundException(javax.persistence.EntityNotFoundException) InstanceGroup(org.onap.aai.domain.yang.InstanceGroup) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) L3Network(org.onap.aai.domain.yang.L3Network) GenericVnf(org.onap.aai.domain.yang.GenericVnf) BBInputSetupUtils(org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils) RequestsDbClient(org.onap.so.db.request.client.RequestsDbClient) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) Logger(org.slf4j.Logger) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) Timestamp(java.sql.Timestamp) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) CatalogDbClient(org.onap.so.db.catalog.client.CatalogDbClient) Objects(java.util.Objects) WorkflowContextHolder(org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder) RequestReferences(org.onap.so.serviceinstancebeans.RequestReferences) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) Component(org.springframework.stereotype.Component) CvnfcConfigurationCustomization(org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization) BuildingBlockRollback(org.onap.so.db.catalog.beans.BuildingBlockRollback) Environment(org.springframework.core.env.Environment) ModelType(org.onap.so.serviceinstancebeans.ModelType) Optional(java.util.Optional) WorkflowCallbackResponse(org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlockRollback(org.onap.so.db.catalog.beans.BuildingBlockRollback) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList)

Example 27 with VfModule

use of org.onap.aai.domain.yang.VfModule in project so by onap.

the class WorkflowActionTest method selectExecutionListServiceMacroUnassignTest.

@Test
public void selectExecutionListServiceMacroUnassignTest() throws Exception {
    String gAction = "unassignInstance";
    String resource = "Service";
    String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
    initExecution(gAction, bpmnRequest, false);
    execution.setVariable("requestUri", "v6/serviceInstances/123");
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    List<OrchestrationFlow> orchFlows = createFlowList("UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    ServiceInstance serviceInstanceAAI = new ServiceInstance();
    serviceInstanceAAI.setServiceInstanceId("aaisi123");
    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("vnfId123");
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule();
    vnf.getVfModules().add(vfModule);
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = buildVfModule();
    vnf.getVfModules().add(vfModule2);
    org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
    volumeGroup.setVolumeGroupId("vg123");
    vnf.getVolumeGroups().add(volumeGroup);
    serviceInstanceMSO.getVnfs().add(vnf);
    VfModule aaiVfModule = new VfModule();
    aaiVfModule.setIsBaseVfModule(false);
    doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any());
    doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
    doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
    doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any());
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "UnassignVfModuleBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignServiceInstanceBB");
}
Also used : 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) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) VfModule(org.onap.aai.domain.yang.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) 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 28 with VfModule

use of org.onap.aai.domain.yang.VfModule 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)

Example 29 with VfModule

use of org.onap.aai.domain.yang.VfModule in project so by onap.

the class WorkflowActionTest method selectExecutionListServiceMacroDeleteTest.

@Test
public void selectExecutionListServiceMacroDeleteTest() throws Exception {
    String gAction = "deleteInstance";
    String resource = "Service";
    String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
    initExecution(gAction, bpmnRequest, false);
    execution.setVariable("requestUri", "v6/serviceInstances/123");
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivatePnfBB", "DeactivateNetworkBB", "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    ServiceInstance serviceInstanceAAI = new ServiceInstance();
    serviceInstanceAAI.setServiceInstanceId("aaisi123");
    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();
    org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf();
    vnf.setVnfId("vnfId123");
    pnf.setPnfId("pnfId123");
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule();
    vnf.getVfModules().add(vfModule);
    org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = buildVfModule();
    vnf.getVfModules().add(vfModule2);
    org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup = new org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup();
    volumeGroup.setVolumeGroupId("vg123");
    vnf.getVolumeGroups().add(volumeGroup);
    serviceInstanceMSO.getVnfs().add(vnf);
    serviceInstanceMSO.getPnfs().add(pnf);
    VfModule aaiVfModule = new VfModule();
    aaiVfModule.setIsBaseVfModule(false);
    doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any());
    doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
    doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
    doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any());
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignServiceInstanceBB");
}
Also used : 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) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) VfModule(org.onap.aai.domain.yang.VfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) 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 VfModule

use of org.onap.aai.domain.yang.VfModule in project so by onap.

the class WorkflowActionTest method selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceRetainAssignmentsTest.

@Test
public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceRetainAssignmentsTest() throws Exception {
    String gAction = "replaceInstanceRetainAssignments";
    String resource = "VfModule";
    String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_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", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", "ChangeModelVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
}
Also used : HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) 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) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

VfModule (org.onap.aai.domain.yang.VfModule)46 Test (org.junit.Test)39 ArrayList (java.util.ArrayList)26 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)26 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)25 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)24 List (java.util.List)23 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 GenericVnf (org.onap.aai.domain.yang.GenericVnf)22 RelationshipList (org.onap.aai.domain.yang.RelationshipList)22 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)19 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)19 OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)15 HeatEnvironment (org.onap.so.db.catalog.beans.HeatEnvironment)12 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)12 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)12 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)11 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)10 VolumeGroup (org.onap.aai.domain.yang.VolumeGroup)10 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)8