use of org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf in project so by onap.
the class ControllerExecution method setControllerActorScopeAction.
/**
* Setting Controller Actor, Scope and Action Variables in BuildingBlockExecution object
*
* @param execution - BuildingBlockExecution object
*/
public void setControllerActorScopeAction(BuildingBlockExecution execution) {
ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
String scope = Optional.ofNullable(buildingBlock.getBpmnScope()).orElseThrow(() -> new NullPointerException("BPMN Scope is NULL in the orchestration_flow_reference table "));
String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow(() -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table "));
String controllerActor;
try {
if (String.valueOf(scope).equals("pnf")) {
Pnf pnf = getPnf(execution);
String pnfModelUUID = pnf.getModelInfoPnf().getModelCustomizationUuid();
PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(pnfModelUUID);
controllerActor = Optional.ofNullable(pnfResourceCustomization.getControllerActor()).orElse("APPC");
execution.setVariable(MSO_REQUEST_ID, execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId());
execution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion());
execution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName());
} else if ("service".equalsIgnoreCase(scope)) {
GeneralBuildingBlock gbb = execution.getGeneralBuildingBlock();
ModelInfoServiceInstance modelInfoServiceInstance = gbb.getServiceInstance().getModelInfoServiceInstance();
controllerActor = Optional.ofNullable(modelInfoServiceInstance.getControllerActor()).orElse("CDS");
} else {
GenericVnf genericVnf = getGenericVnf(execution);
String modelUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
VnfResourceCustomization vnfResourceCustomization = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelUuid);
controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC");
}
execution.setVariable(SCOPE, scope);
execution.setVariable(ACTION, action);
execution.setVariable(CONTROLLER_ACTOR, controllerActor);
logger.debug("Executing Controller Execution for ControllerActor: {}, Scope: {} , Action: {}", controllerActor, scope, action);
} catch (Exception ex) {
logger.error("An exception occurred while fetching Controller Actor,Scope and Action ", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf in project so by onap.
the class GenericPnfCDSControllerRunnableBB method buildRequestPayload.
private String buildRequestPayload(String action, BuildingBlockExecution execution) {
final JsonObject pnfObject = new JsonObject();
String resolutionKey = null;
try {
final Pnf pnf = getPnf(execution);
final String modelCustomizationUuid = pnf.getModelInfoPnf().getModelCustomizationUuid();
final ServiceInstance serviceInstance = getServiceInstance(execution);
resolutionKey = pnf.getPnfName();
setExecutionVariable("service-instance-id", serviceInstance.getServiceInstanceId(), pnfObject);
setExecutionVariable("service-model-uuid", serviceInstance.getModelInfoServiceInstance().getModelUuid(), pnfObject);
setExecutionVariable("pnf-id", pnf.getPnfId(), pnfObject);
setExecutionVariable("pnf-name", resolutionKey, pnfObject);
setExecutionVariable("pnf-customization-uuid", modelCustomizationUuid, pnfObject);
final GeneralBuildingBlock generalBuildingBlock = execution.getGeneralBuildingBlock();
List<Map<String, Object>> userParamsFromRequest = generalBuildingBlock.getRequestContext().getRequestParameters().getUserParams();
if (userParamsFromRequest != null && userParamsFromRequest.size() != 0) {
configureInstanceParamsForPnf.populateInstanceParams(pnfObject, userParamsFromRequest, modelCustomizationUuid);
}
} catch (BBObjectNotFoundException | PayloadGenerationException exception) {
logger.error("An exception occurred when creating payload for CDS request", exception);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, exception);
}
final JsonObject cdsPropertyObject = new JsonObject();
cdsPropertyObject.addProperty(RESOLUTION_KEY, resolutionKey);
cdsPropertyObject.add(action + SEPARATOR + PROPERTIES, pnfObject);
return buildRequestJsonObject(cdsPropertyObject, action);
}
Aggregations