Search in sources :

Example 1 with VolumeGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup in project so by onap.

the class AAIDeleteTasks method deleteVolumeGroup.

/**
 * BPMN access method to delete the VolumeGroup from A&AI.
 *
 * It will extract the volumeGroup from the BBObject and cloudRegion from execution object .
 *
 * Then it will delete from A&AI.
 *
 * @param execution
 * @throws Exception
 */
public void deleteVolumeGroup(BuildingBlockExecution execution) {
    try {
        VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
        CloudRegion cloudRegion = execution.getGeneralBuildingBlock().getCloudRegion();
        aaiVolumeGroupResources.deleteVolumeGroup(volumeGroup, cloudRegion);
    } catch (Exception ex) {
        logger.error("Exception occurred in AAIDeleteTasks deleteVolumeGroup process", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)

Example 2 with VolumeGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup in project so by onap.

the class VnfAdapterImpl method postProcessVnfAdapter.

public void postProcessVnfAdapter(BuildingBlockExecution execution) {
    try {
        String vnfAdapterResponse = execution.getVariable("WorkflowResponse");
        if (!StringUtils.isEmpty(vnfAdapterResponse)) {
            Object vnfRestResponse = unMarshal(vnfAdapterResponse);
            if (vnfRestResponse instanceof CreateVfModuleResponse) {
                VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
                String heatStackId = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleStackId();
                if (!StringUtils.isEmpty(heatStackId)) {
                    vfModule.setHeatStackId(heatStackId);
                    execution.setVariable(HEAT_STACK_ID, heatStackId);
                }
                Map<String, String> vfModuleOutputs = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleOutputs();
                if (vfModuleOutputs != null) {
                    processVfModuleOutputs(execution, vfModuleOutputs);
                }
            } else if (vnfRestResponse instanceof DeleteVfModuleResponse) {
                VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
                GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
                Boolean vfModuleDelete = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleDeleted();
                if (null != vfModuleDelete && vfModuleDelete) {
                    vfModule.setHeatStackId(null);
                    execution.setVariable(HEAT_STACK_ID, null);
                    Map<String, String> vfModuleOutputs = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleOutputs();
                    if (vfModuleOutputs != null) {
                        processVfModuleOutputs(execution, vfModuleOutputs);
                        if (execution.getVariable(OAM_MANAGEMENT_V4_ADDRESS) != null) {
                            genericVnf.setIpv4OamAddress("");
                            execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, "");
                        }
                        if (execution.getVariable(OAM_MANAGEMENT_V6_ADDRESS) != null) {
                            genericVnf.setManagementV6Address("");
                            execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, "");
                        }
                        if (execution.getVariable(CONTRAIL_SERVICE_INSTANCE_FQDN) != null) {
                            vfModule.setContrailServiceInstanceFqdn("");
                            execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, "");
                        }
                    }
                }
            } else if (vnfRestResponse instanceof CreateVolumeGroupResponse) {
                VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
                String heatStackId = ((CreateVolumeGroupResponse) vnfRestResponse).getVolumeGroupStackId();
                if (!StringUtils.isEmpty(heatStackId)) {
                    volumeGroup.setHeatStackId(heatStackId);
                    execution.setVariable(HEAT_STACK_ID, heatStackId);
                } else {
                    exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "HeatStackId is missing from create VolumeGroup Vnf Adapter response.");
                }
            } else if (vnfRestResponse instanceof DeleteVolumeGroupResponse) {
                VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
                Boolean volumeGroupDelete = ((DeleteVolumeGroupResponse) vnfRestResponse).getVolumeGroupDeleted();
                if (null != volumeGroupDelete && volumeGroupDelete) {
                    volumeGroup.setHeatStackId(null);
                    execution.setVariable(HEAT_STACK_ID, null);
                }
            }
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : CreateVolumeGroupResponse(org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) DeleteVolumeGroupResponse(org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) DeleteVfModuleResponse(org.onap.so.adapters.vnfrest.DeleteVfModuleResponse) MarshallerException(org.onap.so.exceptions.MarshallerException) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) CreateVfModuleResponse(org.onap.so.adapters.vnfrest.CreateVfModuleResponse) Map(java.util.Map)

Example 3 with VolumeGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup in project so by onap.

the class BuildingBlockTestDataSetup method setVolumeGroup.

public VolumeGroup setVolumeGroup() {
    VolumeGroup volumeGroup = buildVolumeGroup();
    GenericVnf genericVnf = null;
    try {
        genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
    } catch (BBObjectNotFoundException e) {
        genericVnf = setGenericVnf();
    }
    genericVnf.getVolumeGroups().add(volumeGroup);
    lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
    return volumeGroup;
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)

Example 4 with VolumeGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup in project so by onap.

the class VnfEBBLoader method processVolumeGroups.

private void processVolumeGroups(GenericVnf vnf, List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, Resource vnfResource) {
    if (vnf.getVolumeGroups() != null) {
        for (VolumeGroup volumeGroup : vnf.getVolumeGroups()) {
            aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
            resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false, vnfResource));
        }
    }
}
Also used : VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) Resource(org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)

Example 5 with VolumeGroup

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup in project so by onap.

the class BBInputSetupTest method test_getGBBMacroNoUserParamsExistingService_forUnassignVolumeGroupBB.

@Test
public void test_getGBBMacroNoUserParamsExistingService_forUnassignVolumeGroupBB() throws Exception {
    // given
    String requestAction = "unassignInstance";
    GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
    L3Network network = new L3Network();
    network.setNetworkId("networkId");
    gBB.getServiceInstance().getNetworks().add(network);
    ServiceInstance serviceInstance = gBB.getServiceInstance();
    ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
    requestDetails.getRequestParameters().setUserParams(null);
    Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
    Service service = Mockito.mock(Service.class);
    org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
    GenericVnf vnf = new GenericVnf();
    vnf.setVnfId("vnfId");
    gBB.getServiceInstance().getVnfs().add(vnf);
    org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
    aaiVnf.setModelCustomizationId("modelCustId");
    VfModule vfModule = new VfModule();
    vfModule.setVfModuleId("vfModuleId");
    gBB.getServiceInstance().getVnfs().get(0).getVfModules().add(vfModule);
    CloudRegion cloudRegion = new CloudRegion();
    cloudRegion.setLcpCloudRegionId("cloudRegionId");
    cloudRegion.setCloudOwner("CloudOwner");
    VolumeGroup volumeGroup = new VolumeGroup();
    volumeGroup.setVolumeGroupId("volumeGroupId");
    gBB.getServiceInstance().getVnfs().get(0).getVolumeGroups().add(volumeGroup);
    org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
    aaiVolumeGroup.setModelCustomizationId("modelCustId");
    ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
    executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
    BuildingBlock buildingBlock = executeBB.getBuildingBlock();
    buildingBlock.setBpmnFlowName("UnassignVolumeGroupBB").setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
    aaiServiceInstance.setModelVersionId("modelVersionId");
    doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
    doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
    doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
    doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(any(BBInputSetupParameter.class));
    doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
    doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
    doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
    doReturn(Optional.of(cloudRegion)).when(SPY_cloudInfoFromAAI).getCloudInfoFromAAI(gBB.getServiceInstance());
    // when
    SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
    // then
    verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class), any(Service.class));
    verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(isA(VolumeGroup.class), isA(ModelInfo.class), isA(Service.class), isA(String.class));
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) Service(org.onap.so.db.catalog.beans.Service) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) ConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys) BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys(org.onap.so.bpmn.servicedecomposition.tasks.BaseBBInputSetupTestHelper.prepareConfigurationResourceKeys) File(java.io.File) Test(org.junit.Test)

Aggregations

VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)44 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)28 Test (org.junit.Test)23 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)20 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)17 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)15 HashMap (java.util.HashMap)13 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)13 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)13 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)11 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)11 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)10 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)8 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)8 Service (org.onap.so.db.catalog.beans.Service)8 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)7 Map (java.util.Map)6 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)6 CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)5 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)5