Search in sources :

Example 26 with Customer

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Customer in project so by onap.

the class GeneralTopologyObjectMapperTest method testBuildServiceInformation.

@Test
public void testBuildServiceInformation() {
    // prepare and set service instance
    ServiceInstance serviceInstance = new ServiceInstance();
    serviceInstance.setServiceInstanceId("serviceInstanceId");
    ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
    modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
    modelInfoServiceInstance.setModelName("serviceModelName");
    modelInfoServiceInstance.setModelUuid("serviceModelUuid");
    modelInfoServiceInstance.setModelVersion("serviceModelVersion");
    serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
    // prepare Customer object
    Customer customer = new Customer();
    customer.setGlobalCustomerId("globalCustomerId");
    ServiceSubscription serviceSubscription = new ServiceSubscription();
    serviceSubscription.setServiceType("productFamilyId");
    customer.setServiceSubscription(serviceSubscription);
    // set Customer on service instance
    customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
    // 
    RequestContext requestContext = new RequestContext();
    Map<String, Object> userParams = new HashMap<>();
    userParams.put("key1", "value1");
    requestContext.setUserParams(userParams);
    requestContext.setProductFamilyId("productFamilyId");
    GenericResourceApiServiceinformationServiceInformation serviceInfo = genObjMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
    assertEquals("serviceModelInvariantUuid", serviceInfo.getOnapModelInformation().getModelInvariantUuid());
    assertEquals("serviceModelName", serviceInfo.getOnapModelInformation().getModelName());
    assertEquals("serviceModelUuid", serviceInfo.getOnapModelInformation().getModelUuid());
    assertEquals("serviceModelVersion", serviceInfo.getOnapModelInformation().getModelVersion());
    assertNull(serviceInfo.getOnapModelInformation().getModelCustomizationUuid());
    assertEquals("serviceInstanceId", serviceInfo.getServiceInstanceId());
    assertEquals("serviceInstanceId", serviceInfo.getServiceId());
    assertEquals("globalCustomerId", serviceInfo.getGlobalCustomerId());
    assertEquals("productFamilyId", serviceInfo.getSubscriptionServiceType());
}
Also used : GenericResourceApiServiceinformationServiceInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) HashMap(java.util.HashMap) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) Test(org.junit.Test)

Example 27 with Customer

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Customer in project so by onap.

the class OofHomingV2 method callOof.

/**
 * Generates the request payload then sends to Oof to perform homing and licensing for the provided demands
 *
 * @param execution
 */
public void callOof(BuildingBlockExecution execution) {
    logger.trace("Started Oof Homing Call Oof");
    try {
        GeneralBuildingBlock bb = execution.getGeneralBuildingBlock();
        RequestContext requestContext = bb.getRequestContext();
        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("oof.timeout", "PT30M");
        }
        OofRequest oofRequest = new OofRequest();
        RequestInfo requestInfo = buildRequestInfo(requestId, timeout);
        oofRequest.setRequestInformation(requestInfo);
        ServiceInfo serviceInfo = buildServiceInfo(serviceInstance);
        oofRequest.setServiceInformation(serviceInfo);
        PlacementInfo placementInfo = buildPlacementInfo(customer);
        placementInfo = buildPlacementDemands(serviceInstance, placementInfo);
        oofRequest.setPlacementInformation(placementInfo);
        LicenseInfo licenseInfo = buildLicenseInfo(serviceInstance);
        oofRequest.setLicenseInformation(licenseInfo);
        if (!placementInfo.getPlacementDemands().isEmpty() || !licenseInfo.getLicenseDemands().isEmpty()) {
            oofClient.postDemands(oofRequest);
        } 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", "OofResponse");
        execution.setVariable("asyncTimeout", timeout);
        logger.trace("Completed Oof Homing Call Oof");
    } catch (BpmnError e) {
        logger.debug(ERROR_WHILE_PREPARING_OOF_REQUEST + e.getStackTrace());
        exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage());
    } catch (BadResponseException e) {
        logger.debug(ERROR_WHILE_PREPARING_OOF_REQUEST + e.getStackTrace());
        exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage());
    } catch (Exception e) {
        logger.debug(ERROR_WHILE_PREPARING_OOF_REQUEST + e.getStackTrace());
        exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while " + "preparing oof request: " + e + "   Stack:" + ExceptionUtils.getFullStackTrace(e));
    }
}
Also used : LicenseInfo(org.onap.so.client.oof.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.oof.beans.RequestInfo) BadResponseException(org.onap.so.client.exception.BadResponseException) ServiceInfo(org.onap.so.client.oof.beans.ServiceInfo) PlacementInfo(org.onap.so.client.oof.beans.PlacementInfo) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) OofRequest(org.onap.so.client.oof.beans.OofRequest) BpmnError(org.camunda.bpm.engine.delegate.BpmnError)

Example 28 with Customer

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Customer in project so by onap.

the class AAIObjectMapperTest method mapCustomerTest.

@Test
public void mapCustomerTest() {
    Customer customer = new Customer();
    customer.setGlobalCustomerId("globalCustomerId");
    customer.setSubscriberName("subscriberName");
    customer.setSubscriberType("subscriberType");
    org.onap.aai.domain.yang.Customer expectedCustomer = new org.onap.aai.domain.yang.Customer();
    expectedCustomer.setGlobalCustomerId("globalCustomerId");
    expectedCustomer.setSubscriberName("subscriberName");
    expectedCustomer.setSubscriberType("subscriberType");
    org.onap.aai.domain.yang.Customer actualCustomer = aaiObjectMapper.mapCustomer(customer);
    assertThat(actualCustomer, sameBeanAs(expectedCustomer));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) Test(org.junit.Test)

Example 29 with Customer

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Customer in project so by onap.

the class BBInputSetup method getGBBALaCarteService.

protected GeneralBuildingBlock getGBBALaCarteService(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId) throws Exception {
    Customer customer = getCustomerAndServiceSubscription(requestDetails, resourceId);
    if (customer != null) {
        Project project = null;
        OwningEntity owningEntity = null;
        if (requestDetails.getProject() != null)
            project = mapperLayer.mapRequestProject(requestDetails.getProject());
        if (requestDetails.getOwningEntity() != null)
            owningEntity = mapperLayer.mapRequestOwningEntity(requestDetails.getOwningEntity());
        String modelVersionId = requestDetails.getModelInfo().getModelVersionId();
        if (ModelType.vnf == requestDetails.getModelInfo().getModelType()) {
            for (RelatedInstanceList relatedInstanceList : requestDetails.getRelatedInstanceList()) {
                if (ModelType.service == relatedInstanceList.getRelatedInstance().getModelInfo().getModelType()) {
                    modelVersionId = relatedInstanceList.getRelatedInstance().getModelInfo().getModelVersionId();
                    break;
                }
            }
        }
        Service service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId);
        if (service == null) {
            service = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID(requestDetails.getModelInfo().getModelVersion(), requestDetails.getModelInfo().getModelInvariantId());
            if (service == null) {
                throw new Exception("Could not find service for model version Id: " + requestDetails.getModelInfo().getModelVersionId() + " and for model invariant Id: " + requestDetails.getModelInfo().getModelInvariantId());
            }
        }
        ServiceInstance serviceInstance = this.getALaCarteServiceInstance(service, requestDetails, customer, project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()), executeBB.getBuildingBlock().getBpmnFlowName());
        BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestDetails(requestDetails).setServiceInstance(serviceInstance).setExecuteBB(executeBB).setRequestAction(requestAction).setCustomer(customer).build();
        return this.populateGBBWithSIAndAdditionalInfo(parameter);
    } else {
        throw new Exception("Could not find customer");
    }
}
Also used : Project(org.onap.so.bpmn.servicedecomposition.bbobjects.Project) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) OwningEntity(org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ServiceModelNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException) NoServiceInstanceFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException) ResourceNotFoundException(org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ResourceNotFoundException)

Example 30 with Customer

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Customer in project so by onap.

the class BBInputSetup method getCustomerAndServiceSubscription.

protected Customer getCustomerAndServiceSubscription(RequestDetails requestDetails, String resourceId) {
    Customer customer;
    if (requestDetails.getSubscriberInfo() != null) {
        customer = this.getCustomerFromRequest(requestDetails);
    } else {
        customer = this.getCustomerFromURI(resourceId);
    }
    if (customer != null) {
        ServiceSubscription serviceSubscription = null;
        serviceSubscription = getServiceSubscription(requestDetails, customer);
        if (serviceSubscription == null) {
            serviceSubscription = getServiceSubscriptionFromURI(resourceId, customer);
        }
        customer.setServiceSubscription(serviceSubscription);
        return customer;
    } else {
        return null;
    }
}
Also used : ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)

Aggregations

Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)74 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)52 Test (org.junit.Test)40 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)37 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)25 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)23 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)23 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)22 HashMap (java.util.HashMap)21 SDNCRequest (org.onap.so.client.sdnc.beans.SDNCRequest)16 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)15 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)14 Service (org.onap.so.db.catalog.beans.Service)13 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)11 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)10 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)10 File (java.io.File)9 GenericResourceApiServiceOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation)9 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)9 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)8