use of org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse 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);
}
}
use of org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse in project so by onap.
the class VnfAdapterVolumeGroupResourcesTest method test_createVolumeGroup.
@Test
public void test_createVolumeGroup() throws Exception {
volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
CreateVolumeGroupRequest createVolumeGroupRequest = new CreateVolumeGroupRequest();
createVolumeGroupRequest.setCloudSiteId("cloudSiteId");
CreateVolumeGroupResponse expectedCreateVolumeGroupResponse = new CreateVolumeGroupResponse();
expectedCreateVolumeGroupResponse.setVolumeGroupStackId("volumeGroupStackId");
expectedCreateVolumeGroupResponse.setVolumeGroupCreated(true);
String sdncVfModuleQueryResponse = "sdncVfModuleQueryResponse";
doReturn(createVolumeGroupRequest).when(MOCK_vnfAdapterObjectMapper).createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
CreateVolumeGroupRequest actualCreateVolumeGroupResponse = vnfAdapterVolumeGroupResources.createVolumeGroupRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
verify(MOCK_vnfAdapterObjectMapper, times(1)).createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
assertThat(createVolumeGroupRequest, Matchers.sameBeanAs(actualCreateVolumeGroupResponse));
}
use of org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse in project so by onap.
the class PollService method determineCreateVolumeGroupStatus.
private Optional<String> determineCreateVolumeGroupStatus(CreateVolumeGroupRequest req, ExternalTask externalTask, MutableBoolean success, boolean isMulticloud) throws MsoException {
boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
String stackId = externalTask.getVariable("stackId");
if (pollRollbackStatus) {
logger.debug("Executing External Task Poll Service for Rollback Volume Group");
if (!isMulticloud) {
pollDeleteResource(118, req.getCloudSiteId(), req.getTenantId(), stackId, success);
}
return Optional.empty();
} else {
logger.debug("Executing External Task Poll Service for Create Volume Group");
Map<String, String> outputs = new HashMap<String, String>();
if (!isMulticloud) {
int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), true);
StackInfo stack = pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), stackId, success);
outputs = vnfAdapterImpl.copyStringOutputs(stack.getOutputs());
}
VolumeGroupRollback rb = new VolumeGroupRollback(req.getVolumeGroupId(), stackId, true, req.getTenantId(), req.getCloudOwner(), req.getCloudSiteId(), req.getMsoRequest(), req.getMessageId());
CreateVolumeGroupResponse createResponse = new CreateVolumeGroupResponse(req.getVolumeGroupId(), stackId, true, outputs, rb, req.getMessageId());
return Optional.of(createResponse.toXmlString());
}
}
use of org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse 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.CreateVolumeGroupResponse 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);
}
Aggregations