use of org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest in project so by onap.
the class StackService method createVolumeGroup.
private void createVolumeGroup(String xmlRequest, Holder<String> canonicalStackId, MutableBoolean backout, MutableBoolean success) throws VnfException {
CreateVolumeGroupRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateVolumeGroupRequest.class);
String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
if (isMulticloud) {
vnfPluginImpl.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), completeVnfVfModuleType, req.getVnfVersion(), "", req.getVolumeGroupName(), "", "VOLUME", null, null, req.getModelCustomizationUuid(), req.getVolumeGroupParams(), false, true, req.getEnableBridge(), req.getMsoRequest(), canonicalStackId);
} else {
vnfAdapterImpl.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), completeVnfVfModuleType, req.getVnfVersion(), "", req.getVolumeGroupName(), "", "VOLUME", null, null, req.getModelCustomizationUuid(), req.getVolumeGroupParams(), false, true, req.getEnableBridge(), req.getMsoRequest(), canonicalStackId);
}
success.setTrue();
backout.setValue(!req.getSuppressBackout());
}
use of org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest in project so by onap.
the class VnfAdapterCreateTasks method createVolumeGroupRequest.
/**
* This method is used for creating the request for the VolumeGroup.
*
* @param execution
* @return
*/
public void createVolumeGroupRequest(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
VfModule vfModule;
String sdncVfModuleQueryResponse = null;
try {
vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
if (vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) {
sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId());
} else {
throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value");
}
} catch (BBObjectNotFoundException bbException) {
logger.error("Exception occurred", bbException);
// If there is not a vf module in the general building block (in aLaCarte case),
// we will not retrieve
// the SDNCQueryResponse and proceed as normal without throwing an error
}
CreateVolumeGroupRequest createVolumeGroupRequest = vnfAdapterVolumeGroupResources.createVolumeGroupRequest(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
execution.setVariable(VNFREST_REQUEST, createVolumeGroupRequest.toXmlString());
} catch (Exception ex) {
logger.error("Exception occurred", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest in project so by onap.
the class VnfVolumeAdapterClientIT method createVolumeGroupTest.
@Test
public void createVolumeGroupTest() throws VnfAdapterClientException {
CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
request.setCloudSiteId(TESTING_ID);
CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
mockResponse.setVolumeGroupCreated(true);
VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
AdapterRestClient mockClient = mock(AdapterRestClient.class);
doReturn(mockClient).when(client).getAdapterRestClient("");
when(mockClient.post(request, CreateVolumeGroupResponse.class)).thenReturn(mockResponse);
CreateVolumeGroupResponse response = client.createVNFVolumes(request);
assertEquals("Testing CreateVolumeGroup response", mockResponse.getVolumeGroupCreated(), response.getVolumeGroupCreated());
}
use of org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest in project so by onap.
the class VnfVolumeAdapterClientIT method createVolumeGroupTestThrowException.
@Test(expected = VnfAdapterClientException.class)
public void createVolumeGroupTestThrowException() throws VnfAdapterClientException {
CreateVolumeGroupRequest request = new CreateVolumeGroupRequest();
request.setCloudSiteId(TESTING_ID);
CreateVolumeGroupResponse mockResponse = new CreateVolumeGroupResponse();
mockResponse.setVolumeGroupCreated(true);
VnfVolumeAdapterClientImpl client = spy(VnfVolumeAdapterClientImpl.class);
AdapterRestClient mockClient = mock(AdapterRestClient.class);
doReturn(mockClient).when(client).getAdapterRestClient("");
when(mockClient.post(request, CreateVolumeGroupResponse.class)).thenThrow(new InternalServerErrorException("Error in create volume group"));
client.createVNFVolumes(request);
}
use of org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest 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));
}
Aggregations