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);
}
}
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);
}
}
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);
}
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));
}
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));
}
Aggregations