Search in sources :

Example 16 with RequestParameters

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());
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) MapperException(org.onap.so.client.exception.MapperException) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) GenericResourceApiVfmoduleinformationVfModuleInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters) Test(org.junit.Test)

Example 17 with RequestParameters

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());
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) MapperException(org.onap.so.client.exception.MapperException) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) GenericResourceApiVfmoduleinformationVfModuleInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters) Test(org.junit.Test)

Example 18 with RequestParameters

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;
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)

Example 19 with RequestParameters

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;
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)

Example 20 with RequestParameters

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);
    }
}
Also used : Demand(org.onap.so.client.sniro.beans.Demand) LicenseInfo(org.onap.so.client.sniro.beans.LicenseInfo) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) BadResponseException(org.onap.so.client.exception.BadResponseException) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) RequestInfo(org.onap.so.client.sniro.beans.RequestInfo) BadResponseException(org.onap.so.client.exception.BadResponseException) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters) SniroManagerRequest(org.onap.so.client.sniro.beans.SniroManagerRequest) ServiceInfo(org.onap.so.client.sniro.beans.ServiceInfo) PlacementInfo(org.onap.so.client.sniro.beans.PlacementInfo) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) BpmnError(org.camunda.bpm.engine.delegate.BpmnError)

Aggregations

RequestParameters (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)25 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)18 Test (org.junit.Test)9 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)9 HashMap (java.util.HashMap)8 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)8 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)7 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)7 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)7 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)6 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)4 URI (java.net.URI)3 GenericResourceApiVfModuleOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation)3 GenericResourceApiVfmoduleinformationVfModuleInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation)3 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)3 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)3 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)3 MapperException (org.onap.so.client.exception.MapperException)3