Search in sources :

Example 6 with CreateVolumeGroupRequest

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());
}
Also used : CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) StringReader(java.io.StringReader)

Example 7 with CreateVolumeGroupRequest

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);
    }
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 8 with CreateVolumeGroupRequest

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());
}
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 9 with CreateVolumeGroupRequest

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

Example 10 with CreateVolumeGroupRequest

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));
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CreateVolumeGroupRequest(org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) MsoRequest(org.onap.so.entity.MsoRequest) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Aggregations

CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)12 Test (org.junit.Test)7 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)5 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)5 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)5 HashMap (java.util.HashMap)4 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)4 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)4 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)4 StringReader (java.io.StringReader)3 CreateVolumeGroupResponse (org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse)3 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)3 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)2 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)2 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)2 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)2 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)2 AdapterRestClient (org.onap.so.client.adapter.rest.AdapterRestClient)2 MsoRequest (org.onap.so.entity.MsoRequest)2 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)1