Search in sources :

Example 46 with ServerApiException

use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.

the class UpdateNetworkOfferingCmd method execute.

@Override
public void execute() {
    NetworkOffering result = _configService.updateNetworkOffering(this);
    if (result != null) {
        NetworkOfferingResponse response = _responseGenerator.createNetworkOfferingResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update network offering");
    }
}
Also used : NetworkOfferingResponse(com.cloud.api.response.NetworkOfferingResponse) ServerApiException(com.cloud.api.ServerApiException) NetworkOffering(com.cloud.offering.NetworkOffering)

Example 47 with ServerApiException

use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.

the class MigrateVolumeCmd method execute.

@Override
public void execute() {
    Volume result;
    try {
        result = _storageService.migrateVolume(getVolumeId(), getStoragePoolId());
        if (result != null) {
            VolumeResponse response = _responseGenerator.createVolumeResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        }
    } catch (ConcurrentOperationException e) {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to migrate volume: ");
    }
}
Also used : VolumeResponse(com.cloud.api.response.VolumeResponse) ServerApiException(com.cloud.api.ServerApiException) Volume(com.cloud.storage.Volume) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException)

Example 48 with ServerApiException

use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.

the class PreparePrimaryStorageForMaintenanceCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException {
    StoragePool result = _storageService.preparePrimaryStorageForMaintenance(getId());
    if (result != null) {
        StoragePoolResponse response = _responseGenerator.createStoragePoolResponse(result);
        response.setResponseName("storagepool");
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to prepare primary storage for maintenance");
    }
}
Also used : StoragePoolResponse(com.cloud.api.response.StoragePoolResponse) StoragePool(com.cloud.storage.StoragePool) ServerApiException(com.cloud.api.ServerApiException)

Example 49 with ServerApiException

use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.

the class RebootSystemVmCmd method execute.

@Override
public void execute() {
    UserContext.current().setEventDetails("Vm Id: " + getId());
    VirtualMachine result = _mgr.rebootSystemVM(this);
    if (result != null) {
        SystemVmResponse response = _responseGenerator.createSystemVmResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to reboot system vm");
    }
}
Also used : SystemVmResponse(com.cloud.api.response.SystemVmResponse) ServerApiException(com.cloud.api.ServerApiException) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 50 with ServerApiException

use of com.cloud.api.ServerApiException in project CloudStack-archive by CloudStack-extras.

the class RebootVMCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException {
    UserContext.current().setEventDetails("Vm Id: " + getId());
    UserVm result;
    if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
        result = _bareMetalVmService.rebootVirtualMachine(this);
    } else {
        result = _userVmService.rebootVirtualMachine(this);
    }
    if (result != null) {
        UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reboot vm instance");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) ServerApiException(com.cloud.api.ServerApiException) UserVmResponse(com.cloud.api.response.UserVmResponse)

Aggregations

ServerApiException (com.cloud.api.ServerApiException)170 SuccessResponse (com.cloud.api.response.SuccessResponse)46 UserVm (com.cloud.uservm.UserVm)15 UserVmResponse (com.cloud.api.response.UserVmResponse)14 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)12 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)12 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)12 Account (com.cloud.user.Account)9 Host (com.cloud.host.Host)8 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)8 ListResponse (com.cloud.api.response.ListResponse)7 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)7 HostResponse (com.cloud.api.response.HostResponse)6 TemplateResponse (com.cloud.api.response.TemplateResponse)6 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)6 AccountResponse (com.cloud.api.response.AccountResponse)5 SystemVmResponse (com.cloud.api.response.SystemVmResponse)5 UserResponse (com.cloud.api.response.UserResponse)5 VolumeResponse (com.cloud.api.response.VolumeResponse)5 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)5