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);
}
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"));
}
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);
}
}
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);
}
}
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;
}
Aggregations