Search in sources :

Example 96 with VfModule

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);
    }
}
Also used : CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) SDNCRequest(org.onap.so.client.sdnc.beans.SDNCRequest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) GenericResourceApiVfModuleOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation)

Example 97 with VfModule

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);
    }
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) HashMap(java.util.HashMap) ConfigScaleOutPayload(org.onap.so.bpmn.appc.payload.beans.ConfigScaleOutPayload) RequestParametersConfigScaleOut(org.onap.so.bpmn.appc.payload.beans.RequestParametersConfigScaleOut) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) HashMap(java.util.HashMap) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)97 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)74 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)53 Test (org.junit.Test)46 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)45 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)37 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)35 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)30 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)27 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)27 HashMap (java.util.HashMap)22 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)20 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)18 CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)14 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)14 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)13 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)12 Service (org.onap.so.db.catalog.beans.Service)12 Map (java.util.Map)11 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)11