Search in sources :

Example 76 with InsufficientCapacityException

use of com.cloud.exception.InsufficientCapacityException in project cloudstack by apache.

the class VirtualMachineManagerImpl method advanceReboot.

@Override
public void advanceReboot(final String vmUuid, final Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
    final AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext();
    if (jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
        // avoid re-entrance
        VmWorkJobVO placeHolder = null;
        final VirtualMachine vm = _vmDao.findByUuid(vmUuid);
        placeHolder = createPlaceHolderWork(vm.getId());
        try {
            orchestrateReboot(vmUuid, params);
        } finally {
            if (placeHolder != null) {
                _workJobDao.expunge(placeHolder.getId());
            }
        }
    } else {
        final Outcome<VirtualMachine> outcome = rebootVmThroughJobQueue(vmUuid, params);
        try {
            final VirtualMachine vm = outcome.get();
        } catch (final InterruptedException e) {
            throw new RuntimeException("Operation is interrupted", e);
        } catch (final java.util.concurrent.ExecutionException e) {
            throw new RuntimeException("Execution excetion", e);
        }
        final Object jobResult = _jobMgr.unmarshallResultObject(outcome.getJob());
        if (jobResult != null) {
            if (jobResult instanceof ResourceUnavailableException) {
                throw (ResourceUnavailableException) jobResult;
            } else if (jobResult instanceof ConcurrentOperationException) {
                throw (ConcurrentOperationException) jobResult;
            } else if (jobResult instanceof InsufficientCapacityException) {
                throw (InsufficientCapacityException) jobResult;
            } else if (jobResult instanceof RuntimeException) {
                throw (RuntimeException) jobResult;
            } else if (jobResult instanceof Throwable) {
                throw new RuntimeException("Unexpected exception", (Throwable) jobResult);
            }
        }
    }
}
Also used : AsyncJobExecutionContext(org.apache.cloudstack.framework.jobs.AsyncJobExecutionContext) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) VmWorkJobVO(org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 77 with InsufficientCapacityException

use of com.cloud.exception.InsufficientCapacityException in project cloudstack by apache.

the class CreateVPCCmdByAdmin method execute.

@Override
public void execute() {
    Vpc vpc = null;
    try {
        if (isStart()) {
            _vpcService.startVpc(getEntityId(), true);
        } else {
            s_logger.debug("Not starting VPC as " + ApiConstants.START + "=false was passed to the API");
        }
        vpc = _entityMgr.findById(Vpc.class, getEntityId());
    } catch (ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (InsufficientCapacityException ex) {
        s_logger.info(ex);
        s_logger.trace(ex);
        throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
    }
    if (vpc != null) {
        VpcResponse response = _responseGenerator.createVpcResponse(ResponseView.Full, vpc);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPC");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) VpcResponse(org.apache.cloudstack.api.response.VpcResponse) Vpc(com.cloud.network.vpc.Vpc) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Example 78 with InsufficientCapacityException

use of com.cloud.exception.InsufficientCapacityException in project cloudstack by apache.

the class DeleteStorageNetworkIpRangeCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        _storageNetworkService.deleteIpRange(this);
        SuccessResponse response = new SuccessResponse(getCommandName());
        this.setResponseObject(response);
    } catch (Exception e) {
        s_logger.warn("Failed to delete storage network ip range " + getId(), e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 79 with InsufficientCapacityException

use of com.cloud.exception.InsufficientCapacityException in project cloudstack by apache.

the class UpdateStorageNetworkIpRangeCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        StorageNetworkIpRange result = _storageNetworkService.updateIpRange(this);
        StorageNetworkIpRangeResponse response = _responseGenerator.createStorageNetworkIpRangeResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } catch (Exception e) {
        s_logger.warn("Update storage network IP range failed", e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) StorageNetworkIpRange(com.cloud.dc.StorageNetworkIpRange) StorageNetworkIpRangeResponse(org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 80 with InsufficientCapacityException

use of com.cloud.exception.InsufficientCapacityException in project cloudstack by apache.

the class RestartVPCCmd method execute.

@Override
public void execute() {
    try {
        final boolean result = _vpcService.restartVpc(getId(), getCleanup(), getMakeredundant());
        if (result) {
            final SuccessResponse response = new SuccessResponse(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to restart VPC");
        }
    } catch (final ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (final ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (final InsufficientCapacityException ex) {
        s_logger.info(ex);
        s_logger.trace(ex);
        throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Aggregations

InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)85 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)77 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)70 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)41 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)36 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)23 ServerApiException (org.apache.cloudstack.api.ServerApiException)23 Account (com.cloud.user.Account)18 ConfigurationException (javax.naming.ConfigurationException)17 ArrayList (java.util.ArrayList)15 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)14 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)14 TransactionCallbackWithException (com.cloud.utils.db.TransactionCallbackWithException)12 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)11 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)11 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)10 NetworkVO (com.cloud.network.dao.NetworkVO)10 DB (com.cloud.utils.db.DB)10 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)9 Network (com.cloud.network.Network)9