Search in sources :

Example 1 with CreateVolumeGroupResponse

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);
    }
}
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 2 with CreateVolumeGroupResponse

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));
}
Also used : CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) CreateVolumeGroupResponse(org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse) Test(org.junit.Test)

Example 3 with CreateVolumeGroupResponse

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());
    }
}
Also used : VolumeGroupRollback(org.onap.so.adapters.vnfrest.VolumeGroupRollback) CreateVolumeGroupResponse(org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse) HashMap(java.util.HashMap) StackInfo(org.onap.so.openstack.beans.StackInfo)

Example 4 with CreateVolumeGroupResponse

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());
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) CreateVolumeGroupResponse(org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Example 5 with CreateVolumeGroupResponse

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);
}
Also used : AdapterRestClient(org.onap.so.client.adapter.rest.AdapterRestClient) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) CreateVolumeGroupResponse(org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) Test(org.junit.Test) BaseIntegrationTest(org.onap.so.BaseIntegrationTest)

Aggregations

CreateVolumeGroupResponse (org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse)5 Test (org.junit.Test)3 CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)3 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)2 AdapterRestClient (org.onap.so.client.adapter.rest.AdapterRestClient)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)1 CreateVfModuleResponse (org.onap.so.adapters.vnfrest.CreateVfModuleResponse)1 DeleteVfModuleResponse (org.onap.so.adapters.vnfrest.DeleteVfModuleResponse)1 DeleteVolumeGroupResponse (org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse)1 VolumeGroupRollback (org.onap.so.adapters.vnfrest.VolumeGroupRollback)1 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)1 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)1 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)1 MarshallerException (org.onap.so.exceptions.MarshallerException)1 StackInfo (org.onap.so.openstack.beans.StackInfo)1