Search in sources :

Example 41 with VnfResourceCustomization

use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.

the class BBInputSetupTest method testMapCatalogVfModule.

@Test
public void testMapCatalogVfModule() {
    String vnfModelCustomizationUUID = "vnfResourceCustUUID";
    String vfModuleCustomizationUUID = "vfModelCustomizationUUID";
    VfModule vfModule = new VfModule();
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationUuid(vfModuleCustomizationUUID);
    Service service = new Service();
    VnfResourceCustomization vnfResourceCust = new VnfResourceCustomization();
    vnfResourceCust.setModelCustomizationUUID(vnfModelCustomizationUUID);
    VfModuleCustomization vfModuleCust = new VfModuleCustomization();
    vfModuleCust.setModelCustomizationUUID(vfModuleCustomizationUUID);
    vnfResourceCust.getVfModuleCustomizations().add(vfModuleCust);
    service.getVnfCustomizations().add(vnfResourceCust);
    ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
    doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfModuleCust);
    SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
    assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
    modelInfo.setModelCustomizationUuid(null);
    modelInfo.setModelCustomizationId(vfModuleCustomizationUUID);
    SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
    assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) Service(org.onap.so.db.catalog.beans.Service) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ModelInfoVfModule(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) Test(org.junit.Test)

Example 42 with VnfResourceCustomization

use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.

the class ControllerExecution method setControllerActorScopeAction.

/**
 * Setting Controller Actor, Scope and Action Variables in BuildingBlockExecution object
 *
 * @param execution - BuildingBlockExecution object
 */
public void setControllerActorScopeAction(BuildingBlockExecution execution) {
    ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
    BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
    String scope = Optional.ofNullable(buildingBlock.getBpmnScope()).orElseThrow(() -> new NullPointerException("BPMN Scope is NULL in the orchestration_flow_reference table "));
    String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow(() -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table "));
    String controllerActor;
    try {
        if (String.valueOf(scope).equals("pnf")) {
            Pnf pnf = getPnf(execution);
            String pnfModelUUID = pnf.getModelInfoPnf().getModelCustomizationUuid();
            PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(pnfModelUUID);
            controllerActor = Optional.ofNullable(pnfResourceCustomization.getControllerActor()).orElse("APPC");
            execution.setVariable(MSO_REQUEST_ID, execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId());
            execution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion());
            execution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName());
        } else if ("service".equalsIgnoreCase(scope)) {
            GeneralBuildingBlock gbb = execution.getGeneralBuildingBlock();
            ModelInfoServiceInstance modelInfoServiceInstance = gbb.getServiceInstance().getModelInfoServiceInstance();
            controllerActor = Optional.ofNullable(modelInfoServiceInstance.getControllerActor()).orElse("CDS");
        } else {
            GenericVnf genericVnf = getGenericVnf(execution);
            String modelUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
            VnfResourceCustomization vnfResourceCustomization = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelUuid);
            controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC");
        }
        execution.setVariable(SCOPE, scope);
        execution.setVariable(ACTION, action);
        execution.setVariable(CONTROLLER_ACTOR, controllerActor);
        logger.debug("Executing Controller Execution for ControllerActor: {}, Scope: {} , Action: {}", controllerActor, scope, action);
    } catch (Exception ex) {
        logger.error("An exception occurred while fetching Controller Actor,Scope and Action ", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)

Example 43 with VnfResourceCustomization

use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.

the class ControllerExecutionDE method getControllerActor.

/**
 * this method is used to get the controller actor, there could be few places to get the actor(ordered by priority),
 *
 * <ol>
 * <li>Execution Context, i.e, DelegateExecution</li>
 * <li>Resource customization table, pnf_resource_customization for PNF or vnf_resource_customization for VNF</li>
 * <li>controller_selection_reference, resource_type and action will be used to fetch from this table</li>
 * </ol>
 *
 * @param execution DelegateExecution instance
 * @param controllerScope controller scope, e.g, pnf, vnf, vfModule
 * @param resourceCustomizationUuid resource customization UUID, e.g, pnfCustomizationUuid, vnfCustomizationUuid
 * @param controllerAction controller action, e.g, configAssign, configDeploy
 * @return controller actor
 */
protected String getControllerActor(DelegateExecution execution, String controllerScope, String resourceCustomizationUuid, String controllerAction) {
    /**
     * Firstly, check the execution context for actor parameter.
     */
    String controllerActor = getParameterFromExecution(execution, CONTROLLER_ACTOR_PARAM);
    /**
     * If no meaningful controller actor value found in the execution context and the value is not SO-REF-DATA.
     */
    if (Strings.isNullOrEmpty(controllerActor) && !isSoRefControllerActor(controllerActor)) {
        /**
         * secondly, if no meaningful actor from execution context, getting from resource table in database.
         */
        if (isPnfResourceScope(controllerScope)) {
            PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
            controllerActor = pnfResourceCustomization.getControllerActor();
        } else if (isVnfResourceScope(controllerScope)) {
            VnfResourceCustomization vnfResourceCustomization = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
            controllerActor = vnfResourceCustomization.getControllerActor();
        } else {
            logger.warn("Unrecognized scope: {}", controllerScope);
        }
    }
    /**
     * Lastly, can NOT find the controller actor information from resource customization table or value is
     * SO-REF-DATA
     */
    if (Strings.isNullOrEmpty(controllerActor) || isSoRefControllerActor(controllerActor)) {
        String resourceType = getParameterFromExecution(execution, RESOURCE_TYPE_PARAM);
        ControllerSelectionReference reference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(resourceType, controllerAction);
        controllerActor = reference.getControllerName();
    }
    return controllerActor;
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization)

Aggregations

VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)43 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)17 Service (org.onap.so.db.catalog.beans.Service)15 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)13 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)11 VnfResource (org.onap.so.db.catalog.beans.VnfResource)10 VfModule (org.onap.so.db.catalog.beans.VfModule)7 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)7 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)6 PnfResourceCustomization (org.onap.so.db.catalog.beans.PnfResourceCustomization)6 Transactional (org.springframework.transaction.annotation.Transactional)6 List (java.util.List)5 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)5 VnfcInstanceGroupCustomization (org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)4 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)4 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 NetworkResourceCustomization (org.onap.so.db.catalog.beans.NetworkResourceCustomization)4