use of org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters in project so by onap.
the class GeneralTopologyObjectMapperTest method buildVfModuleInformationTest_withNoModelIsFromPreload.
@Test
public void buildVfModuleInformationTest_withNoModelIsFromPreload() {
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("TestVfModuleId");
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
GenericVnf genericVnf = new GenericVnf();
genericVnf.setVnfId("TestVnfId");
RequestContext requestContext = new RequestContext();
RequestParameters requestParameters = new RequestParameters();
requestParameters.setUsePreload(true);
requestContext.setRequestParameters(requestParameters);
GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
try {
gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
} catch (MapperException ex) {
}
assertNotNull(gcRequestInput);
assertNull(vfModule.getModelInfoVfModule());
assertNull(gcRequestInput.getOnapModelInformation());
assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
assertNotNull(gcRequestInput.getVfModuleId());
assertTrue(gcRequestInput.getFromPreload());
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters in project so by onap.
the class GeneralTopologyObjectMapperTest method buildVfModuleInformationTest_withNoModelIsNotFromPreload.
@Test
public void buildVfModuleInformationTest_withNoModelIsNotFromPreload() {
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("TestVfModuleId");
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
GenericVnf genericVnf = new GenericVnf();
genericVnf.setVnfId("TestVnfId");
RequestContext requestContext = new RequestContext();
RequestParameters requestParameters = new RequestParameters();
requestParameters.setUsePreload(false);
requestContext.setRequestParameters(requestParameters);
GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
try {
gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
} catch (MapperException ex) {
}
assertNotNull(gcRequestInput);
assertNull(vfModule.getModelInfoVfModule());
assertNull(gcRequestInput.getOnapModelInformation());
assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId());
assertNotNull(gcRequestInput.getVfModuleId());
assertFalse(gcRequestInput.getFromPreload());
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters in project so by onap.
the class GenericCDSProcessingBBTest method createGeneralBuildingBlock.
private GeneralBuildingBlock createGeneralBuildingBlock() {
GeneralBuildingBlock generalBuildingBlock = new GeneralBuildingBlock();
RequestContext requestContext = new RequestContext();
RequestParameters requestParameters = new RequestParameters();
requestParameters.setUserParams(createRequestParameters());
requestContext.setRequestParameters(requestParameters);
requestContext.setMsoRequestId(TEST_MSO_REQUEST_ID);
generalBuildingBlock.setRequestContext(requestContext);
return generalBuildingBlock;
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters in project so by onap.
the class ConfigAssignVnfTest method createGeneralBuildingBlock.
private GeneralBuildingBlock createGeneralBuildingBlock(Object serviceJson) {
GeneralBuildingBlock generalBuildingBlock = new GeneralBuildingBlock();
RequestContext requestContext = new RequestContext();
RequestParameters requestParameters = new RequestParameters();
requestParameters.setUserParams(createRequestUserParams(serviceJson));
requestContext.setRequestParameters(requestParameters);
generalBuildingBlock.setRequestContext(requestContext);
return generalBuildingBlock;
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters in project so by onap.
the class SniroHomingV2 method callSniro.
/**
* Generates the request payload then sends to sniro manager to perform homing and licensing for the provided
* demands
*
* @param execution
*/
public void callSniro(BuildingBlockExecution execution) {
logger.debug("Started Sniro Homing Call Sniro");
try {
GeneralBuildingBlock bb = execution.getGeneralBuildingBlock();
RequestContext requestContext = bb.getRequestContext();
RequestParameters requestParams = requestContext.getRequestParameters();
String requestId = requestContext.getMsoRequestId();
ServiceInstance serviceInstance = bb.getCustomer().getServiceSubscription().getServiceInstances().get(0);
Customer customer = bb.getCustomer();
String timeout = execution.getVariable("timeout");
if (isBlank(timeout)) {
timeout = env.getProperty("sniro.manager.timeout", "PT30M");
}
SniroManagerRequest request = new SniroManagerRequest();
RequestInfo requestInfo = buildRequestInfo(requestId, timeout);
request.setRequestInformation(requestInfo);
ServiceInfo serviceInfo = buildServiceInfo(serviceInstance);
request.setServiceInformation(serviceInfo);
PlacementInfo placementInfo = buildPlacementInfo(customer, requestParams);
List<Demand> placementDemands = buildPlacementDemands(serviceInstance);
placementInfo.setDemands(placementDemands);
request.setPlacementInformation(placementInfo);
LicenseInfo licenseInfo = new LicenseInfo();
List<Demand> licenseDemands = buildLicenseDemands(serviceInstance);
licenseInfo.setDemands(licenseDemands);
request.setLicenseInformation(licenseInfo);
if (!placementDemands.isEmpty() || !licenseDemands.isEmpty()) {
client.postDemands(request);
} else {
logger.debug(SERVICE_MISSING_DATA + "resources eligible for homing or licensing");
throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + "resources eligible for homing or licensing");
}
// Variables for ReceiveWorkflowMessage subflow
execution.setVariable("asyncCorrelator", requestId);
execution.setVariable("asyncMessageType", "SNIROResponse");
execution.setVariable("asyncTimeout", timeout);
logger.trace("Completed Sniro Homing Call Sniro");
} catch (BpmnError e) {
logger.error(EXCEPTION_OCCURRED, e);
exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage(), ONAPComponents.SNIRO);
} catch (BadResponseException e) {
logger.error(EXCEPTION_OCCURRED, e);
exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage(), ONAPComponents.SNIRO);
} catch (Exception e) {
logger.error(EXCEPTION_OCCURRED, e);
exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while preparing sniro request: " + e.getMessage(), ONAPComponents.SO);
}
}
Aggregations