Search in sources :

Example 1 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class SDNCActivateTasks method activateVfModule.

/**
 * This method is used to prepare a SDNC request and set it to the execution Object.
 *
 * Which is used for activate the activateVfModule.
 *
 * @param execution
 */
public void activateVfModule(BuildingBlockExecution execution) {
    GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
    RequestContext requestContext = gBBInput.getRequestContext();
    ServiceInstance serviceInstance = null;
    GenericVnf vnf = null;
    VfModule vfModule = null;
    try {
        serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        Customer customer = gBBInput.getCustomer();
        CloudRegion cloudRegion = gBBInput.getCloudRegion();
        SDNCRequest sdncRequest = new SDNCRequest();
        GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.activateVfModule(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 SDNCActivateTasks activateVfModule process", 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) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) GenericResourceApiVfModuleOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation)

Example 2 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class SDNCChangeAssignTasks method changeAssignModelVfModule.

public void changeAssignModelVfModule(BuildingBlockExecution execution) throws Exception {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        RequestContext requestContext = gBBInput.getRequestContext();
        CloudRegion cloudRegion = gBBInput.getCloudRegion();
        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();
        SDNCRequest sdncRequest = new SDNCRequest();
        GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest));
        sdncRequest.setSDNCPayload(req);
        sdncRequest.setTopology(SDNCTopology.VFMODULE);
        execution.setVariable(SDNC_REQUEST, sdncRequest);
    } catch (Exception 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 3 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class SDNCUnassignTasks method unassignVfModule.

/**
 * This method is used to prepare a SDNC request and set it to the execution Object.
 *
 * Which is used for unassign the VfModule.
 *
 * @param execution
 */
public void unassignVfModule(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        RequestContext requestContext = gBBInput.getRequestContext();
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        SDNCRequest sdncRequest = new SDNCRequest();
        GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance, requestContext, buildCallbackURI(sdncRequest));
        sdncRequest.setSDNCPayload(req);
        sdncRequest.setTopology(SDNCTopology.VFMODULE);
        execution.setVariable(SDNC_REQUEST, sdncRequest);
    } catch (Exception ex) {
        logger.error("Exception occurred in SDNCUnassignTasks unassignVfModule", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : SDNCRequest(org.onap.so.client.sdnc.beans.SDNCRequest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) 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 4 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class AppcRunTasks method runAppcCommand.

public void runAppcCommand(BuildingBlockExecution execution, Action action) {
    logger.trace("Start runAppcCommand ");
    String appcCode = "1002";
    String appcMessage = "";
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        GenericVnf vnf = null;
        try {
            vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        } catch (BBObjectNotFoundException e) {
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "No valid VNF exists");
        }
        String vnfId = null;
        String vnfName = null;
        String vnfType = null;
        String vnfHostIpAddress = null;
        if (vnf != null) {
            vnfId = vnf.getVnfId();
            vnfName = vnf.getVnfName();
            vnfType = vnf.getVnfType();
            vnfHostIpAddress = vnf.getIpv4OamAddress();
        }
        String msoRequestId = gBBInput.getRequestContext().getMsoRequestId();
        String aicIdentity = execution.getVariable("aicIdentity");
        String vmIdList = execution.getVariable("vmIdList");
        String vserverIdList = execution.getVariable("vserverIdList");
        String identityUrl = execution.getVariable("identityUrl");
        ControllerSelectionReference controllerSelectionReference = catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString());
        String controllerType;
        if (controllerSelectionReference != null) {
            controllerType = controllerSelectionReference.getControllerName();
        } else {
            controllerType = CONTROLLER_TYPE_DEFAULT;
        }
        String vfModuleId = null;
        VfModule vfModule = null;
        try {
            vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        } catch (BBObjectNotFoundException e) {
        }
        if (vfModule != null) {
            vfModuleId = vfModule.getVfModuleId();
        }
        HashMap<String, String> payloadInfo = buildPayloadInfo(vnfName, aicIdentity, vnfHostIpAddress, vmIdList, vserverIdList, identityUrl, vfModuleId);
        Optional<String> payload = Optional.empty();
        RequestParameters requestParameters = gBBInput.getRequestContext().getRequestParameters();
        if (requestParameters != null) {
            String pay = requestParameters.getPayload();
            if (pay != null) {
                payload = Optional.of(pay);
            } else {
                String payloadFromUserParams = buildPayloadFromUserParams(gBBInput.getRequestContext().getUserParams());
                payload = Optional.of(payloadFromUserParams);
            }
        }
        logger.debug("Running APP-C action: {}", action.toString());
        logger.debug("VNFID: {}", vnfId);
        appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
        appcCode = appCClient.getErrorCode();
        appcMessage = appCClient.getErrorMessage();
        mapRollbackVariables(execution, action, appcCode);
    } catch (Exception e) {
        logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "Caught exception in runAppcCommand", "BPMN", ErrorCode.UnknownError.getValue(), "Error on request to APPC", e);
        appcCode = GENERIC_APPC_ERROR_CODE;
        appcMessage = e.getMessage();
    }
    logger.error("Error Message: {}", appcMessage);
    logger.error("ERROR CODE: {}", appcCode);
    logger.trace("End of runAppCommand ");
    if (appcCode != null && !"0".equals(appcCode)) {
        exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
    }
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ControllerSelectionReference(org.onap.so.db.catalog.beans.ControllerSelectionReference) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) RequestParameters(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters)

Example 5 with VfModule

use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.

the class AAICreateTasks method createVfModule.

/**
 * This method is used for creating the vfModule in A&AI.
 *
 * @param execution
 * @throws @return
 */
public void createVfModule(BuildingBlockExecution execution) {
    try {
        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        int moduleIndex = 0;
        if (vfModule.getModelInfoVfModule() != null && !Boolean.TRUE.equals(vfModule.getModelInfoVfModule().getIsBaseBoolean())) {
            moduleIndex = this.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, vfModule);
        }
        vfModule.setModuleIndex(moduleIndex);
        aaiVfModuleResources.createVfModule(vfModule, vnf);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

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