use of org.onap.so.bpmn.appc.payload.beans.RequestParametersConfigScaleOut 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);
}
}
Aggregations