use of org.onap.so.db.catalog.beans.VnfResourceCustomization in project so by onap.
the class BBInputSetupTest method testMapCatalogVfModule.
@Test
public void testMapCatalogVfModule() {
String vnfModelCustomizationUUID = "vnfResourceCustUUID";
String vfModuleCustomizationUUID = "vfModelCustomizationUUID";
VfModule vfModule = new VfModule();
ModelInfo modelInfo = new ModelInfo();
modelInfo.setModelCustomizationUuid(vfModuleCustomizationUUID);
Service service = new Service();
VnfResourceCustomization vnfResourceCust = new VnfResourceCustomization();
vnfResourceCust.setModelCustomizationUUID(vnfModelCustomizationUUID);
VfModuleCustomization vfModuleCust = new VfModuleCustomization();
vfModuleCust.setModelCustomizationUUID(vfModuleCustomizationUUID);
vnfResourceCust.getVfModuleCustomizations().add(vfModuleCust);
service.getVnfCustomizations().add(vnfResourceCust);
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfModuleCust);
SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
modelInfo.setModelCustomizationUuid(null);
modelInfo.setModelCustomizationId(vfModuleCustomizationUUID);
SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
}
use of org.onap.so.db.catalog.beans.VnfResourceCustomization 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.db.catalog.beans.VnfResourceCustomization 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