use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class SDNCDeactivateTasks method deactivateVfModule.
/**
* This method is used to prepare a SDNC request and set it to the execution Object. Which is used for deactivate
* VfModule.
*
* @param execution
*/
public void deactivateVfModule(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
RequestContext requestContext = gBBInput.getRequestContext();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
Customer customer = gBBInput.getCustomer();
CloudRegion cloudRegion = gBBInput.getCloudRegion();
SDNCRequest sdncRequest = new SDNCRequest();
GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest));
sdncRequest.setSDNCPayload(req);
sdncRequest.setTopology(SDNCTopology.VFMODULE);
execution.setVariable(SDNC_REQUEST, sdncRequest);
} catch (Exception ex) {
logger.error("Exception occurred in SDNCDeactivateTasks deactivateVfModule", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule 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