Search in sources :

Example 41 with Pnf

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);
    }
}
Also used : PnfResourceCustomization(org.onap.so.db.catalog.beans.PnfResourceCustomization) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) VnfResourceCustomization(org.onap.so.db.catalog.beans.VnfResourceCustomization) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)

Example 42 with Pnf

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);
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) JsonObject(com.google.gson.JsonObject) Pnf(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf) ConfigureInstanceParamsForPnf(org.onap.so.client.cds.ConfigureInstanceParamsForPnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) Map(java.util.Map) PayloadGenerationException(org.onap.so.client.exception.PayloadGenerationException)

Aggregations

Pnf (org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf)42 Test (org.junit.Test)22 ModelInfoPnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf)11 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)8 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)5 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)5 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)4 ServiceProxy (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)3 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)3 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)3 OrchestrationStatus (org.onap.so.db.catalog.beans.OrchestrationStatus)3 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Objects (java.util.Objects)2