Search in sources :

Example 26 with VolumeGroup

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

the class AAICreateTasks method createVolumeGroup.

/**
 * This method is used for creating the volume group in A&AI.
 *
 * @param execution
 * @throws @return
 */
public void createVolumeGroup(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
        CloudRegion cloudRegion = gBBInput.getCloudRegion();
        aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
        aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
        aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 27 with VolumeGroup

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

the class AAICreateTasks method connectVfModuleToVolumeGroup.

/**
 * BPMN access method to establish relationships in AAI
 *
 * @param execution
 * @throws Exception
 */
public void connectVfModuleToVolumeGroup(BuildingBlockExecution execution) {
    try {
        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        VolumeGroup volumeGroup = null;
        try {
            volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
        } catch (BBObjectNotFoundException e) {
            logger.info("VolumeGroup not found. Skipping Connect between VfModule and VolumeGroup");
        }
        if (volumeGroup != null) {
            logger.debug("Connecting VfModule to VolumGroup");
            aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup, execution.getGeneralBuildingBlock().getCloudRegion());
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 28 with VolumeGroup

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

the class VnfAdapterObjectMapperTest method test_createVolumeGroupParams_without_sdncResponse.

@Test
public void test_createVolumeGroupParams_without_sdncResponse() throws Exception {
    GenericVnf genericVnf = new GenericVnf();
    genericVnf.setVnfId("vnfId");
    genericVnf.setVnfName("vnfName");
    VolumeGroup volumeGroup = new VolumeGroup();
    volumeGroup.setVolumeGroupId("volumeGroupId");
    volumeGroup.setVolumeGroupName("volumeGroupName");
    Map<String, String> expectedVolumeGroupParams = new HashMap<>();
    expectedVolumeGroupParams.put("vnf_id", genericVnf.getVnfId());
    expectedVolumeGroupParams.put("vnf_name", genericVnf.getVnfName());
    expectedVolumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
    expectedVolumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
    RequestContext requestContext = new RequestContext();
    Map<String, Object> actualVolumeGroupParams = vnfAdapterObjectMapper.createVolumeGroupParams(requestContext, genericVnf, volumeGroup, null);
    assertEquals(expectedVolumeGroupParams, actualVolumeGroupParams);
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Test(org.junit.Test)

Example 29 with VolumeGroup

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

the class VnfAdapterObjectMapperTest method test_createVolumeGroupRequestMapper.

@Test
public void test_createVolumeGroupRequestMapper() throws Exception {
    RequestContext requestContext = new RequestContext();
    requestContext.setMsoRequestId("msoRequestId");
    ServiceInstance serviceInstance = new ServiceInstance();
    serviceInstance.setServiceInstanceId("serviceInstanceId");
    ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
    modelInfoServiceInstance.setModelVersion("modelVersion");
    serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
    GenericVnf genericVnf = new GenericVnf();
    genericVnf.setVnfId("vnfId");
    genericVnf.setVnfName("vnfName");
    genericVnf.setVnfType("vnfType");
    serviceInstance.getVnfs().add(genericVnf);
    ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
    modelInfoVfModule.setModelName("modelName");
    modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
    VolumeGroup volumeGroup = new VolumeGroup();
    volumeGroup.setVolumeGroupId("volumeGroupId");
    volumeGroup.setVolumeGroupName("volumeGroupName");
    volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
    volumeGroup.setModelInfoVfModule(modelInfoVfModule);
    serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
    CloudRegion cloudRegion = new CloudRegion();
    cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
    cloudRegion.setTenantId("tenantId");
    OrchestrationContext orchestrationContext = new OrchestrationContext();
    orchestrationContext.setIsRollbackEnabled(true);
    String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
    CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
    expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
    expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
    expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
    expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
    expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
    expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
    expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
    expectedCreateVolumeGroupRequest.setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
    Map<String, Object> volumeGroupParams = new HashMap<>();
    volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
    volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
    volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
    volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
    volumeGroupParams.put("paramOne", "paramOneValue");
    volumeGroupParams.put("paramTwo", "paramTwoValue");
    volumeGroupParams.put("paramThree", "paramThreeValue");
    expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
    expectedCreateVolumeGroupRequest.setSkipAAI(true);
    expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
    expectedCreateVolumeGroupRequest.setFailIfExists(false);
    MsoRequest msoRequest = new MsoRequest();
    msoRequest.setRequestId(requestContext.getMsoRequestId());
    msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
    expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
    expectedCreateVolumeGroupRequest.setMessageId("messageId");
    expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
    doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
    doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
    CreateVolumeGroupRequest actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
    assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
    doReturn("false").when(vnfAdapterObjectMapper).getProperty("mso.bridgeEnabled");
    actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
    assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
    doReturn(null).when(vnfAdapterObjectMapper).getProperty("mso.bridgeEnabled");
    expectedCreateVolumeGroupRequest.setEnableBridge(true);
    actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
    assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
    doReturn("true").when(vnfAdapterObjectMapper).getProperty("mso.bridgeEnabled");
    expectedCreateVolumeGroupRequest.setEnableBridge(true);
    actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
    assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) MsoRequest(org.onap.so.entity.MsoRequest) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Example 30 with VolumeGroup

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

the class AAIVfModuleResourcesTest method connectVfModuleToVolumeGroupTest.

@Test
public void connectVfModuleToVolumeGroupTest() throws Exception {
    VolumeGroup volumeGroup = buildVolumeGroup();
    volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
    CloudRegion cloudRegion = buildCloudRegion();
    aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup, cloudRegion);
    verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) 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