Search in sources :

Example 1 with ConcurrentOperationException

use of com.cloud.legacymodel.exceptions.ConcurrentOperationException in project cosmic by MissionCriticalCloud.

the class MigrateSystemVMCmd method execute.

@Override
public void execute() {
    final Host destinationHost = _resourceService.getHost(getHostId());
    if (destinationHost == null) {
        throw new InvalidParameterValueException("Unable to find the host to migrate the VM, host id=" + getHostId());
    }
    try {
        CallContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to host Id: " + getHostId());
        // FIXME : Should not be calling UserVmService to migrate all types of VMs - need a generic VM layer
        final VirtualMachine migratedVm = _userVmService.migrateVirtualMachine(getVirtualMachineId(), destinationHost);
        if (migratedVm != null) {
            // return the generic system VM instance response
            final SystemVmResponse response = _responseGenerator.createSystemVmResponse(migratedVm);
            response.setResponseName(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate the system vm");
        }
    } catch (final ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (final ConcurrentOperationException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    } catch (final ManagementServerException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    } catch (final VirtualMachineMigrationException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : SystemVmResponse(com.cloud.api.response.SystemVmResponse) ServerApiException(com.cloud.api.ServerApiException) ManagementServerException(com.cloud.legacymodel.exceptions.ManagementServerException) InvalidParameterValueException(com.cloud.legacymodel.exceptions.InvalidParameterValueException) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) Host(com.cloud.legacymodel.dc.Host) VirtualMachineMigrationException(com.cloud.legacymodel.exceptions.VirtualMachineMigrationException) ConcurrentOperationException(com.cloud.legacymodel.exceptions.ConcurrentOperationException) VirtualMachine(com.cloud.legacymodel.vm.VirtualMachine)

Example 2 with ConcurrentOperationException

use of com.cloud.legacymodel.exceptions.ConcurrentOperationException in project cosmic by MissionCriticalCloud.

the class ScaleSystemVMCmd method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("SystemVm Id: " + getId());
    final ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId);
    if (serviceOffering == null) {
        throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId);
    }
    VirtualMachine result = null;
    try {
        result = _mgr.upgradeSystemVM(this);
    } 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 ManagementServerException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (final VirtualMachineMigrationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
    if (result != null) {
        final SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade system vm");
    }
}
Also used : SystemVmResponse(com.cloud.api.response.SystemVmResponse) ServerApiException(com.cloud.api.ServerApiException) ManagementServerException(com.cloud.legacymodel.exceptions.ManagementServerException) ServiceOffering(com.cloud.offering.ServiceOffering) InvalidParameterValueException(com.cloud.legacymodel.exceptions.InvalidParameterValueException) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) VirtualMachineMigrationException(com.cloud.legacymodel.exceptions.VirtualMachineMigrationException) ConcurrentOperationException(com.cloud.legacymodel.exceptions.ConcurrentOperationException) VirtualMachine(com.cloud.legacymodel.vm.VirtualMachine)

Example 3 with ConcurrentOperationException

use of com.cloud.legacymodel.exceptions.ConcurrentOperationException in project cosmic by MissionCriticalCloud.

the class StartVMCmdByAdmin method execute.

@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException {
    try {
        CallContext.current().setEventDetails("Vm Id: " + getId());
        final UserVm result;
        result = _userVmService.startVirtualMachine(this);
        if (result != null) {
            final UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0);
            response.setResponseName(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start a vm");
        }
    } catch (final ConcurrentOperationException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (final StorageUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (final ExecutionException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    } catch (final InsufficientCapacityException ex) {
        final StringBuilder message = new StringBuilder(ex.getMessage());
        if (ex instanceof InsufficientServerCapacityException) {
            if (((InsufficientServerCapacityException) ex).isAffinityApplied()) {
                message.append(", Please check the affinity groups provided, there may not be sufficient capacity to follow them");
            }
        }
        s_logger.info(ex.toString());
        s_logger.info(message.toString(), ex);
        throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, message.toString());
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) ServerApiException(com.cloud.api.ServerApiException) StorageUnavailableException(com.cloud.legacymodel.exceptions.StorageUnavailableException) InsufficientServerCapacityException(com.cloud.legacymodel.exceptions.InsufficientServerCapacityException) ExecutionException(com.cloud.legacymodel.exceptions.ExecutionException) InsufficientCapacityException(com.cloud.legacymodel.exceptions.InsufficientCapacityException) UserVmResponse(com.cloud.api.response.UserVmResponse) ConcurrentOperationException(com.cloud.legacymodel.exceptions.ConcurrentOperationException)

Example 4 with ConcurrentOperationException

use of com.cloud.legacymodel.exceptions.ConcurrentOperationException in project cosmic by MissionCriticalCloud.

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 (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.toString());
        throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
    }
    if (vpc != null) {
        final 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(com.cloud.api.ServerApiException) VpcResponse(com.cloud.api.response.VpcResponse) Vpc(com.cloud.legacymodel.network.vpc.Vpc) ResourceUnavailableException(com.cloud.legacymodel.exceptions.ResourceUnavailableException) InsufficientCapacityException(com.cloud.legacymodel.exceptions.InsufficientCapacityException) ConcurrentOperationException(com.cloud.legacymodel.exceptions.ConcurrentOperationException)

Example 5 with ConcurrentOperationException

use of com.cloud.legacymodel.exceptions.ConcurrentOperationException in project cosmic by MissionCriticalCloud.

the class CreateVlanIpRangeCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException {
    try {
        final Vlan result = _configService.createVlanAndPublicIpRange(this);
        if (result != null) {
            final VlanIpRangeResponse response = _responseGenerator.createVlanIpRangeResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vlan ip range");
        }
    } 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.toString());
        throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
    }
}
Also used : VlanIpRangeResponse(com.cloud.api.response.VlanIpRangeResponse) ServerApiException(com.cloud.api.ServerApiException) Vlan(com.cloud.legacymodel.dc.Vlan) InsufficientCapacityException(com.cloud.legacymodel.exceptions.InsufficientCapacityException) ConcurrentOperationException(com.cloud.legacymodel.exceptions.ConcurrentOperationException)

Aggregations

ConcurrentOperationException (com.cloud.legacymodel.exceptions.ConcurrentOperationException)101 ResourceUnavailableException (com.cloud.legacymodel.exceptions.ResourceUnavailableException)63 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)58 InsufficientCapacityException (com.cloud.legacymodel.exceptions.InsufficientCapacityException)50 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)37 ServerApiException (com.cloud.api.ServerApiException)30 ResourceAllocationException (com.cloud.legacymodel.exceptions.ResourceAllocationException)28 Account (com.cloud.legacymodel.user.Account)23 AsyncJobExecutionContext (com.cloud.framework.jobs.AsyncJobExecutionContext)20 VmWorkJobVO (com.cloud.framework.jobs.impl.VmWorkJobVO)20 VirtualMachine (com.cloud.legacymodel.vm.VirtualMachine)20 DB (com.cloud.utils.db.DB)19 InsufficientAddressCapacityException (com.cloud.legacymodel.exceptions.InsufficientAddressCapacityException)17 NoTransitionException (com.cloud.legacymodel.exceptions.NoTransitionException)17 ConfigurationException (javax.naming.ConfigurationException)16 OperationTimedoutException (com.cloud.legacymodel.exceptions.OperationTimedoutException)14 Network (com.cloud.legacymodel.network.Network)14 ActionEvent (com.cloud.event.ActionEvent)13 NetworkVO (com.cloud.network.dao.NetworkVO)13 VirtualMachineMigrationException (com.cloud.legacymodel.exceptions.VirtualMachineMigrationException)12