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