Search in sources :

Example 16 with VolumeGroup

use of org.onap.aai.domain.yang.VolumeGroup 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;
}
Also used : VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization)

Example 17 with VolumeGroup

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

the class AAIDataRetrieval method getVolumeGroup.

public VolumeGroup getVolumeGroup(String vnfId, String volumeGroupId) throws AAIEntityNotFound {
    AAIResultWrapper wrapper = this.getAaiResourcesClient().get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).relatedTo(Types.VOLUME_GROUP.getFragment(volumeGroupId)));
    Optional<VolumeGroup> volume = wrapper.asBean(VolumeGroup.class);
    if (volume.isPresent()) {
        return volume.get();
    } else {
        logger.debug("No VolumeGroup in A&AI found: {}", vnfId);
        return null;
    }
}
Also used : VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 18 with VolumeGroup

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

the class AAIDataRetrieval method getVolumeGroupsOfVnf.

public List<VolumeGroup> getVolumeGroupsOfVnf(String vnfId) {
    List<VolumeGroup> volumeGroupList = new ArrayList<VolumeGroup>();
    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).relatedTo(Types.VOLUME_GROUPS.getFragment());
    Optional<VolumeGroups> volumeGroups = getAaiResourcesClient().get(VolumeGroups.class, uri);
    if (!volumeGroups.isPresent() || volumeGroups.get().getVolumeGroup().isEmpty()) {
        logger.debug("No VolumeGroups attached to Vnf in AAI : {}", vnfId);
    } else {
        volumeGroupList = volumeGroups.get().getVolumeGroup();
    }
    return volumeGroupList;
}
Also used : AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) ArrayList(java.util.ArrayList) VolumeGroups(org.onap.aai.domain.yang.VolumeGroups)

Example 19 with VolumeGroup

use of org.onap.aai.domain.yang.VolumeGroup 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");
}
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)

Example 20 with VolumeGroup

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

the class WorkflowActionTest method selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceTest.

@Test
public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceTest() throws Exception {
    String gAction = "replaceInstance";
    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(replaceVfModuleOrchFlows);
    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", "UnassignVFModuleBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "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

VolumeGroup (org.onap.aai.domain.yang.VolumeGroup)30 Test (org.junit.Test)25 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)16 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)12 ArrayList (java.util.ArrayList)11 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)11 List (java.util.List)10 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)10 RelationshipList (org.onap.aai.domain.yang.RelationshipList)10 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)10 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)10 VfModule (org.onap.aai.domain.yang.VfModule)8 VolumeGroups (org.onap.aai.domain.yang.VolumeGroups)8 GenericVnf (org.onap.aai.domain.yang.GenericVnf)6 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)6 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)6 HeatEnvironment (org.onap.so.db.catalog.beans.HeatEnvironment)5 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)5 OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)4 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)3