Search in sources :

Example 11 with ControllerSelectionReference

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

the class AppcRunTasksTest method mockReferenceResponse.

private void mockReferenceResponse() {
    ControllerSelectionReference reference = new ControllerSelectionReference();
    reference.setControllerName("TEST-CONTROLLER-NAME");
    when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(eq("TEST-VNF-TYPE"), eq(Action.Lock.toString()))).thenReturn(reference);
}
Also used : ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference)

Example 12 with ControllerSelectionReference

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

the class ControllerSelectionReferenceTest method controllerDataTest.

@Test
public final void controllerDataTest() {
    ControllerSelectionReference controller = new ControllerSelectionReference();
    controller.setVnfType("vnfType");
    assertTrue(controller.getVnfType().equalsIgnoreCase("vnfType"));
    controller.setControllerName("controllerName");
    assertTrue(controller.getControllerName().equalsIgnoreCase("controllerName"));
    controller.setActionCategory("actionCategory");
    assertTrue(controller.getActionCategory().equalsIgnoreCase("actionCategory"));
}
Also used : ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 13 with ControllerSelectionReference

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

the class GenericVnfHealthCheck method setParamsForGenericVnfHealthCheck.

public void setParamsForGenericVnfHealthCheck(BuildingBlockExecution execution) {
    GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
    try {
        ControllerSelectionReference controllerSelectionReference;
        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        String vnfId = vnf.getVnfId();
        String vnfName = vnf.getVnfName();
        String vnfType = vnf.getVnfType();
        String oamIpAddress = vnf.getIpv4OamAddress();
        String actionCategory = Action.HealthCheck.toString();
        controllerSelectionReference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, actionCategory);
        String controllerName = controllerSelectionReference.getControllerName();
        execution.setVariable("vnfId", vnfId);
        execution.setVariable(VNF_NAME, vnfName);
        execution.setVariable(OAM_IP_ADDRESS, oamIpAddress);
        execution.setVariable(VNF_HOST_IP_ADDRESS, oamIpAddress);
        execution.setVariable("msoRequestId", gBBInput.getRequestContext().getMsoRequestId());
        execution.setVariable("action", actionCategory);
        execution.setVariable("controllerType", controllerName);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)

Example 14 with ControllerSelectionReference

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

the class ConfigurationScaleOut method setParamsForConfigurationScaleOut.

public void setParamsForConfigurationScaleOut(BuildingBlockExecution execution) {
    GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
    try {
        List<Map<String, String>> jsonPathForCfgParams = gBBInput.getRequestContext().getConfigurationParameters();
        String key = null;
        String paramValue = null;
        ObjectMapper mapper = new ObjectMapper();
        String configScaleOutPayloadString = null;
        ControllerSelectionReference controllerSelectionReference;
        ConfigScaleOutPayload configPayload = new ConfigScaleOutPayload();
        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        String vnfId = vnf.getVnfId();
        String vnfName = vnf.getVnfName();
        String vnfType = vnf.getVnfType();
        String actionCategory = Action.ConfigScaleOut.toString();
        controllerSelectionReference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, actionCategory);
        String controllerName = controllerSelectionReference.getControllerName();
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        String sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId());
        Map<String, String> paramsMap = new HashMap<>();
        RequestParametersConfigScaleOut requestParameters = new RequestParametersConfigScaleOut();
        String configScaleOutParam = null;
        if (jsonPathForCfgParams != null) {
            for (Map<String, String> param : jsonPathForCfgParams) {
                for (Map.Entry<String, String> entry : param.entrySet()) {
                    key = entry.getKey();
                    paramValue = entry.getValue();
                    try {
                        configScaleOutParam = JsonPath.parse(sdncVfModuleQueryResponse).read(paramValue);
                    } catch (ClassCastException e) {
                        configScaleOutParam = null;
                        logger.warn("Incorrect JSON path. Path points to object rather than value causing: ", e);
                    }
                    paramsMap.put(key, configScaleOutParam);
                }
            }
        }
        requestParameters.setVfModuleId(vfModule.getVfModuleId());
        requestParameters.setVnfHostIpAddress(vnf.getIpv4OamAddress());
        configPayload.setConfigurationParameters(paramsMap);
        configPayload.setRequestParameters(requestParameters);
        configScaleOutPayloadString = mapper.writeValueAsString(configPayload);
        execution.setVariable(ACTION, actionCategory);
        execution.setVariable(MSO_REQUEST_ID, gBBInput.getRequestContext().getMsoRequestId());
        execution.setVariable(VNF_ID, vnfId);
        execution.setVariable(VNF_NAME, vnfName);
        execution.setVariable(VFMODULE_ID, vfModule.getVfModuleId());
        execution.setVariable(CONTROLLER_TYPE, controllerName);
        execution.setVariable(PAYLOAD, configScaleOutPayloadString);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) ConfigScaleOutPayload(org.onap.so.bpmn.appc.payload.beans.ConfigScaleOutPayload) RequestParametersConfigScaleOut(org.onap.so.bpmn.appc.payload.beans.RequestParametersConfigScaleOut) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) HashMap(java.util.HashMap) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 15 with ControllerSelectionReference

use of org.onap.so.db.catalog.beans.ControllerSelectionReference 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

ControllerSelectionReference (org.onap.so.db.catalog.beans.ControllerSelectionReference)15 Test (org.junit.Test)6 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)4 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)4 HashMap (java.util.HashMap)3 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Action (org.onap.appc.client.lcm.model.Action)2 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)2 RequestParameters (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)2 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)2 PnfResourceCustomization (org.onap.so.db.catalog.beans.PnfResourceCustomization)2 VnfResourceCustomization (org.onap.so.db.catalog.beans.VnfResourceCustomization)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 Map (java.util.Map)1 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)1 ApplicationControllerTaskRequest (org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest)1 ApplicationControllerVnf (org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf)1 ConfigScaleOutPayload (org.onap.so.bpmn.appc.payload.beans.ConfigScaleOutPayload)1