Search in sources :

Example 1 with BBObjectNotFoundException

use of org.onap.so.client.exception.BBObjectNotFoundException in project so by onap.

the class NamingServiceCreateTasks method createInstanceGroupName.

public void createInstanceGroupName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
    String policyInstanceName = execution.getVariable("policyInstanceName");
    String nfNamingCode = execution.getVariable("nfNamingCode");
    String generatedInstanceGroupName = "";
    try {
        generatedInstanceGroupName = namingServiceResources.generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
    instanceGroup.setInstanceGroupName(generatedInstanceGroupName);
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Example 2 with BBObjectNotFoundException

use of org.onap.so.client.exception.BBObjectNotFoundException in project so by onap.

the class NamingServiceCreateTasks method createVpnBondingServiceName.

public void createVpnBondingServiceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
    L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
    VpnBinding vpnBinding = extractPojosForBB.extractByKey(execution, ResourceKey.VPN_ID);
    NamingRequestObject namingRequestObject = new NamingRequestObject();
    namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
    namingRequestObject.setPolicyInstanceNameValue(serviceInstance.getModelInfoServiceInstance().getNamingPolicy());
    namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
    namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName());
    namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion());
    namingRequestObject.setNetworkNameValue(network.getNetworkName());
    namingRequestObject.setVpnNameValue(vpnBinding.getVpnName());
    namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
    String generatedVpnBondingServiceName = "";
    try {
        generatedVpnBondingServiceName = namingServiceResources.generateServiceInstanceName(namingRequestObject);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
    serviceInstance.setServiceInstanceName(generatedVpnBondingServiceName);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) NamingRequestObject(org.onap.so.client.namingservice.NamingRequestObject) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 3 with BBObjectNotFoundException

use of org.onap.so.client.exception.BBObjectNotFoundException in project so by onap.

the class SDNCQueryTasks method queryVnf.

/**
 * BPMN access method to query the SDNC for fetching the vnf details.
 *
 * It will get the vnf details according to service instance id.
 *
 * @param execution
 * @throws Exception
 */
public void queryVnf(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
    GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
    String selfLink = "restconf/config/GENERIC-RESOURCE-API:services/service/" + serviceInstance.getServiceInstanceId() + "/service-data/vnfs/vnf/" + genericVnf.getVnfId() + "/vnf-data/vnf-topology/";
    try {
        if (genericVnf.getSelflink() == null) {
            genericVnf.setSelflink(selfLink);
        }
        String response = sdncVnfResources.queryVnf(genericVnf);
        execution.setVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId(), response);
    } catch (BadResponseException ex) {
        logger.error("Exception occurred", ex);
        if (!ex.getMessage().equals(NO_RESPONSE_FROM_SDNC)) {
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, ONAPComponents.SDNC);
        } else {
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, ONAPComponents.SO);
        }
    } catch (Exception ex) {
        logger.error("Exception occurred", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, ONAPComponents.SO);
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) BadResponseException(org.onap.so.client.exception.BadResponseException) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) BadResponseException(org.onap.so.client.exception.BadResponseException) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 4 with BBObjectNotFoundException

use of org.onap.so.client.exception.BBObjectNotFoundException in project so by onap.

the class NamingServiceDeleteTasks method deleteServiceInstanceName.

public void deleteServiceInstanceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
    NamingRequestObject namingRequestObject = new NamingRequestObject();
    namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
    try {
        namingServiceResources.deleteServiceInstanceName(namingRequestObject);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) NamingRequestObject(org.onap.so.client.namingservice.NamingRequestObject) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 5 with BBObjectNotFoundException

use of org.onap.so.client.exception.BBObjectNotFoundException 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)

Aggregations

BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)56 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)23 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)20 BpmnError (org.camunda.bpm.engine.delegate.BpmnError)18 Before (org.junit.Before)18 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)18 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)12 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)10 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)9 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)6 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)6 InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)5 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)5 Collection (org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)4 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)4 BadResponseException (org.onap.so.client.exception.BadResponseException)4 Test (org.junit.Test)3 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2