Search in sources :

Example 51 with ServerApiException

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

the class ReconnectHostCmd method execute.

@Override
public void execute() {
    try {
        Host result = _resourceService.reconnectHost(this);
        if (result != null) {
            HostResponse response = _responseGenerator.createHostResponse(result);
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reconnect host");
        }
    } catch (Exception ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) HostResponse(com.cloud.api.response.HostResponse) Host(com.cloud.host.Host) ServerApiException(com.cloud.api.ServerApiException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException)

Example 52 with ServerApiException

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

the class RecoverVMCmd method execute.

@Override
public void execute() throws ResourceAllocationException {
    UserVm result = _userVmService.recoverVirtualMachine(this);
    if (result != null) {
        UserVmResponse recoverVmResponse = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
        recoverVmResponse.setResponseName(getCommandName());
        this.setResponseObject(recoverVmResponse);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to recover vm");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) ServerApiException(com.cloud.api.ServerApiException) UserVmResponse(com.cloud.api.response.UserVmResponse)

Example 53 with ServerApiException

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

the class UpdateNetworkServiceProviderCmd method execute.

@Override
public void execute() {
    PhysicalNetworkServiceProvider result = _networkService.updateNetworkServiceProvider(getId(), getState(), getEnabledServices());
    if (result != null) {
        ProviderResponse response = _responseGenerator.createNetworkServiceProviderResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service provider");
    }
}
Also used : ProviderResponse(com.cloud.api.response.ProviderResponse) ServerApiException(com.cloud.api.ServerApiException) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 54 with ServerApiException

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

the class UpdatePhysicalNetworkCmd method execute.

@Override
public void execute() {
    PhysicalNetwork result = _networkService.updatePhysicalNetwork(getId(), getNetworkSpeed(), getTags(), getVlan(), getState());
    if (result != null) {
        PhysicalNetworkResponse response = _responseGenerator.createPhysicalNetworkResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update physical network");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) PhysicalNetworkResponse(com.cloud.api.response.PhysicalNetworkResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork)

Example 55 with ServerApiException

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

the class UpdateResourceCountCmd method execute.

@Override
public void execute() {
    List<? extends ResourceCount> result = _resourceLimitService.recalculateResourceCount(finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), getResourceType());
    if ((result != null) && (result.size() > 0)) {
        ListResponse<ResourceCountResponse> response = new ListResponse<ResourceCountResponse>();
        List<ResourceCountResponse> countResponses = new ArrayList<ResourceCountResponse>();
        for (ResourceCount count : result) {
            ResourceCountResponse resourceCountResponse = _responseGenerator.createResourceCountResponse(count);
            resourceCountResponse.setObjectName("resourcecount");
            countResponses.add(resourceCountResponse);
        }
        response.setResponses(countResponses);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to recalculate resource counts");
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) ResourceCount(com.cloud.configuration.ResourceCount) ArrayList(java.util.ArrayList) ResourceCountResponse(com.cloud.api.response.ResourceCountResponse)

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