Search in sources :

Example 1 with ResourceUnavailableException

use of com.cloud.exception.ResourceUnavailableException in project CloudStack-archive by CloudStack-extras.

the class CreateRemoteAccessVpnCmd method execute.

@Override
public void execute() {
    try {
        RemoteAccessVpn result = _ravService.startRemoteAccessVpn(publicIpId, getOpenFirewall());
        if (result != null) {
            RemoteAccessVpnResponse response = _responseGenerator.createRemoteAccessVpnResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create remote access vpn");
        }
    } catch (ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) RemoteAccessVpnResponse(com.cloud.api.response.RemoteAccessVpnResponse) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn)

Example 2 with ResourceUnavailableException

use of com.cloud.exception.ResourceUnavailableException in project CloudStack-archive by CloudStack-extras.

the class CreateStorageNetworkIpRangeCmd method execute.

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

Example 3 with ResourceUnavailableException

use of com.cloud.exception.ResourceUnavailableException in project CloudStack-archive by CloudStack-extras.

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(BaseCmd.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) StorageNetworkIpRange(com.cloud.dc.StorageNetworkIpRange) StorageNetworkIpRangeResponse(com.cloud.api.response.StorageNetworkIpRangeResponse) ServerApiException(com.cloud.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException)

Example 4 with ResourceUnavailableException

use of com.cloud.exception.ResourceUnavailableException in project CloudStack-archive by CloudStack-extras.

the class MigrateSystemVMCmd method execute.

@Override
public void execute() {
    Host destinationHost = _resourceService.getHost(getHostId());
    if (destinationHost == null) {
        throw new InvalidParameterValueException("Unable to find the host to migrate the VM, host id=" + getHostId());
    }
    try {
        UserContext.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
        VirtualMachine migratedVm = _userVmService.migrateVirtualMachine(getVirtualMachineId(), destinationHost);
        if (migratedVm != null) {
            // return the generic system VM instance response
            SystemVmInstanceResponse response = _responseGenerator.createSystemVmInstanceResponse(migratedVm);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to migrate the system vm");
        }
    } catch (ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (ConcurrentOperationException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
    } catch (ManagementServerException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
    } catch (VirtualMachineMigrationException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : SystemVmInstanceResponse(com.cloud.api.response.SystemVmInstanceResponse) ServerApiException(com.cloud.api.ServerApiException) ManagementServerException(com.cloud.exception.ManagementServerException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) Host(com.cloud.host.Host) VirtualMachineMigrationException(com.cloud.exception.VirtualMachineMigrationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 5 with ResourceUnavailableException

use of com.cloud.exception.ResourceUnavailableException in project CloudStack-archive by CloudStack-extras.

the class MigrateVMCmd method execute.

@Override
public void execute() {
    if (getHostId() == null && getStoragePoolId() == null) {
        throw new InvalidParameterValueException("either hostId or storageId must be specified");
    }
    if (getHostId() != null && getStoragePoolId() != null) {
        throw new InvalidParameterValueException("only one of hostId and storageId can be specified");
    }
    UserVm userVm = _userVmService.getUserVm(getVirtualMachineId());
    if (userVm == null) {
        throw new InvalidParameterValueException("Unable to find the VM by id=" + getVirtualMachineId());
    }
    Host destinationHost = null;
    if (getHostId() != null) {
        destinationHost = _resourceService.getHost(getHostId());
        if (destinationHost == null) {
            throw new InvalidParameterValueException("Unable to find the host to migrate the VM, host id=" + getHostId());
        }
        UserContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to host Id: " + getHostId());
    }
    StoragePool destStoragePool = null;
    if (getStoragePoolId() != null) {
        destStoragePool = _storageService.getStoragePool(getStoragePoolId());
        if (destStoragePool == null) {
            throw new InvalidParameterValueException("Unable to find the storage pool to migrate the VM");
        }
        UserContext.current().setEventDetails("VM Id: " + getVirtualMachineId() + " to storage pool Id: " + getStoragePoolId());
    }
    try {
        VirtualMachine migratedVm = null;
        if (getHostId() != null) {
            migratedVm = _userVmService.migrateVirtualMachine(getVirtualMachineId(), destinationHost);
        } else if (getStoragePoolId() != null) {
            migratedVm = _userVmService.vmStorageMigration(getVirtualMachineId(), destStoragePool);
        }
        if (migratedVm != null) {
            UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", (UserVm) migratedVm).get(0);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to migrate vm");
        }
    } catch (ResourceUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    } catch (ConcurrentOperationException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
    } catch (ManagementServerException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
    } catch (VirtualMachineMigrationException e) {
        s_logger.warn("Exception: ", e);
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) StoragePool(com.cloud.storage.StoragePool) ServerApiException(com.cloud.api.ServerApiException) ManagementServerException(com.cloud.exception.ManagementServerException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) Host(com.cloud.host.Host) VirtualMachineMigrationException(com.cloud.exception.VirtualMachineMigrationException) UserVmResponse(com.cloud.api.response.UserVmResponse) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) VirtualMachine(com.cloud.vm.VirtualMachine)

Aggregations

ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)446 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)191 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)175 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)153 ArrayList (java.util.ArrayList)99 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)91 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)74 Account (com.cloud.user.Account)62 DomainRouterVO (com.cloud.vm.DomainRouterVO)60 OperationTimedoutException (com.cloud.exception.OperationTimedoutException)59 ConfigurationException (javax.naming.ConfigurationException)53 DB (com.cloud.utils.db.DB)52 ServerApiException (org.apache.cloudstack.api.ServerApiException)51 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)47 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)47 ActionEvent (com.cloud.event.ActionEvent)46 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)46 DataCenter (com.cloud.dc.DataCenter)45 ServerApiException (com.cloud.api.ServerApiException)43 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)42