Search in sources :

Example 1 with CreateVnfRequest

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest in project so by onap.

the class VnfmAdapterCreateVnfTask method invokeVnfmAdapter.

/**
 * Invoke VNFM adapter to create and instantiate VNF
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 */
public void invokeVnfmAdapter(final BuildingBlockExecution execution) {
    try {
        LOGGER.debug("Executing invokeVnfmAdapter  ...");
        final CreateVnfRequest request = execution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
        final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
        final Optional<CreateVnfResponse> response = vnfmAdapterServiceProvider.invokeCreateInstantiationRequest(vnf.getVnfId(), request);
        if (!response.isPresent()) {
            final String errorMessage = "Unexpected error while processing create and instantiation request";
            LOGGER.error(errorMessage);
            exceptionUtil.buildAndThrowWorkflowException(execution, 1201, errorMessage);
        }
        final CreateVnfResponse vnfResponse = response.get();
        LOGGER.debug("Vnf instantiation response: {}", vnfResponse);
        execution.setVariable(CREATE_VNF_RESPONSE_PARAM_NAME, vnfResponse);
        LOGGER.debug("Finished executing invokeVnfmAdapter ...");
    } catch (final Exception exception) {
        LOGGER.error("Unable to invoke create and instantiation request", exception);
        exceptionUtil.buildAndThrowWorkflowException(execution, 1202, exception);
    }
}
Also used : CreateVnfResponse(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) CreateVnfRequest(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest)

Example 2 with CreateVnfRequest

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest in project so by onap.

the class VnfmAdapterCreateVnfTaskTest method testBuildCreateVnfRequest_extractPojosForBBThrowsException_exceptionBuilderCalled.

@Test
public void testBuildCreateVnfRequest_extractPojosForBBThrowsException_exceptionBuilderCalled() throws Exception {
    final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
    when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class);
    objUnderTest.buildCreateVnfRequest(stubbedxecution);
    final CreateVnfRequest actual = stubbedxecution.getVariable(CREATE_VNF_REQUEST_PARAM_NAME);
    assertNull(actual);
    verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1200), any(Exception.class));
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) CreateVnfRequest(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 3 with CreateVnfRequest

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest in project so by onap.

the class VnfmAdapterCreateVnfTaskTest method testInvokeVnfmAdapter_invalidValues_storesResponseInExecution.

@Test
public void testInvokeVnfmAdapter_invalidValues_storesResponseInExecution() throws Exception {
    final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
    stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
    when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
    when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class))).thenReturn(Optional.absent());
    objUnderTest.invokeVnfmAdapter(stubbedxecution);
    assertNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
    verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1202), any(Exception.class));
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) CreateVnfRequest(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 4 with CreateVnfRequest

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest in project so by onap.

the class VnfmAdapterCreateVnfTaskTest method testInvokeVnfmAdapter_validValues_storesResponseInExecution.

@Test
public void testInvokeVnfmAdapter_validValues_storesResponseInExecution() throws Exception {
    final VnfmAdapterCreateVnfTask objUnderTest = getEtsiVnfInstantiateTask();
    stubbedxecution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, new CreateVnfRequest());
    when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(getGenericVnf());
    when(mockedVnfmAdapterServiceProvider.invokeCreateInstantiationRequest(eq(VNF_ID), any(CreateVnfRequest.class))).thenReturn(getCreateVnfResponse());
    objUnderTest.invokeVnfmAdapter(stubbedxecution);
    assertNotNull(stubbedxecution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME));
}
Also used : CreateVnfRequest(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 5 with CreateVnfRequest

use of org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest in project so by onap.

the class VnfmAdapterCreateVnfTask method buildCreateVnfRequest.

/**
 * Create {@link CreateVnfRequest} object with required fields and store it in
 * {@link org.camunda.bpm.engine.delegate.DelegateExecution}
 *
 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
 */
public void buildCreateVnfRequest(final BuildingBlockExecution execution) {
    try {
        LOGGER.debug("Executing buildCreateVnfRequest  ...");
        final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock();
        final CloudRegion cloudRegion = buildingBlock.getCloudRegion();
        final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID);
        final ModelInfoGenericVnf modelInfoGenericVnf = vnf.getModelInfoGenericVnf();
        final InputParameter inputParameter = getInputParameter(execution);
        final CreateVnfRequest createVnfRequest = new CreateVnfRequest();
        createVnfRequest.setName(getName(vnf.getVnfName(), modelInfoGenericVnf.getModelInstanceName()));
        createVnfRequest.setTenant(getTenant(cloudRegion));
        createVnfRequest.setAdditionalParams(inputParameter.getAdditionalParams());
        createVnfRequest.setExternalVirtualLinks(inputParameter.getExtVirtualLinks());
        LOGGER.info("CreateVnfRequest : {}", createVnfRequest);
        execution.setVariable(CREATE_VNF_REQUEST_PARAM_NAME, createVnfRequest);
        LOGGER.debug("Finished executing buildCreateVnfRequest ...");
    } catch (final Exception exception) {
        LOGGER.error("Unable to execute buildCreateVnfRequest", exception);
        exceptionUtil.buildAndThrowWorkflowException(execution, 1200, exception);
    }
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ModelInfoGenericVnf(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf) CreateVnfRequest(org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest) InputParameter(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter) NullInputParameter(org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.NullInputParameter)

Aggregations

CreateVnfRequest (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfRequest)6 Test (org.junit.Test)4 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)4 CreateVnfResponse (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse)2 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)2 InputParameter (org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.InputParameter)2 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)2 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)2 Tenant (org.onap.so.adapters.etsisol003adapter.lcm.v1.model.Tenant)1 NullInputParameter (org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.utils.NullInputParameter)1 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)1 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)1 HttpResouceNotFoundException (org.onap.so.rest.exceptions.HttpResouceNotFoundException)1 InvalidRestRequestException (org.onap.so.rest.exceptions.InvalidRestRequestException)1 RestProcessingException (org.onap.so.rest.exceptions.RestProcessingException)1 HttpStatus (org.springframework.http.HttpStatus)1