Search in sources :

Example 1 with CreateVfModuleResponse

use of org.onap.so.adapters.vnfrest.CreateVfModuleResponse 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 CreateVfModuleResponse

use of org.onap.so.adapters.vnfrest.CreateVfModuleResponse in project so by onap.

the class VnfAdapterClientIT method createVfModuleTest.

@Test
public void createVfModuleTest() throws JsonProcessingException, VnfAdapterClientException {
    CreateVfModuleRequest request = new CreateVfModuleRequest();
    request.setCloudSiteId(TESTING_ID);
    CreateVfModuleResponse mockResponse = new CreateVfModuleResponse();
    mockResponse.setVfModuleCreated(true);
    wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
    CreateVfModuleResponse response = client.createVfModule(AAI_VNF_ID, request);
    assertEquals("Testing CreateVfModule response", true, response.getVfModuleCreated());
}
Also used : CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) CreateVfModuleResponse(org.onap.so.adapters.vnfrest.CreateVfModuleResponse) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Example 3 with CreateVfModuleResponse

use of org.onap.so.adapters.vnfrest.CreateVfModuleResponse in project so by onap.

the class PollService method determineCreateVfModuleStatus.

private Optional<String> determineCreateVfModuleStatus(CreateVfModuleRequest req, ExternalTask externalTask, MutableBoolean success, boolean isMulticloud) throws MsoException {
    String stackId = externalTask.getVariable("stackId");
    boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
    int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), false);
    if (pollRollbackStatus) {
        logger.debug("Executing External Task Poll Service for Rollback Vf Module");
        if (!isMulticloud) {
            pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), stackId, success);
        }
        return Optional.empty();
    } else {
        logger.debug("Executing External Task Poll Service for Create Vf Module");
        Map<String, String> outputs = new HashMap<String, String>();
        if (!isMulticloud) {
            StackInfo stack = pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), stackId, success);
            outputs = vnfAdapterImpl.copyStringOutputs(stack.getOutputs());
        }
        VfModuleRollback modRollback = new VfModuleRollback(buildVnfRollback(req, stackId, isMulticloud), req.getVfModuleId(), stackId, req.getMessageId());
        CreateVfModuleResponse createResponse = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), stackId, Boolean.TRUE, outputs, modRollback, req.getMessageId());
        return Optional.of(createResponse.toXmlString());
    }
}
Also used : HashMap(java.util.HashMap) VfModuleRollback(org.onap.so.adapters.vnfrest.VfModuleRollback) CreateVfModuleResponse(org.onap.so.adapters.vnfrest.CreateVfModuleResponse) StackInfo(org.onap.so.openstack.beans.StackInfo)

Aggregations

CreateVfModuleResponse (org.onap.so.adapters.vnfrest.CreateVfModuleResponse)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)1 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)1 CreateVolumeGroupResponse (org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse)1 DeleteVfModuleResponse (org.onap.so.adapters.vnfrest.DeleteVfModuleResponse)1 DeleteVolumeGroupResponse (org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse)1 VfModuleRollback (org.onap.so.adapters.vnfrest.VfModuleRollback)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