Search in sources :

Example 1 with ConfigScaleOutPayload

use of org.onap.so.bpmn.appc.payload.beans.ConfigScaleOutPayload 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)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConfigScaleOutPayload (org.onap.so.bpmn.appc.payload.beans.ConfigScaleOutPayload)1 RequestParametersConfigScaleOut (org.onap.so.bpmn.appc.payload.beans.RequestParametersConfigScaleOut)1 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)1 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)1 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)1 ControllerSelectionReference (org.onap.so.db.catalog.beans.ControllerSelectionReference)1