Search in sources :

Example 91 with ServerApiException

use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.

the class EnableNuageUnderlayVlanIpRangeCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        boolean result = _nuageVspManager.updateNuageUnderlayVlanIpRange(vlanIpRangeId, true);
        if (result) {
            SuccessResponse response = new SuccessResponse(getCommandName());
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable underlay, VLAN IP range is already pushed to the Nuage VSP device.");
        }
    } catch (InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
    } catch (CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 92 with ServerApiException

use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.

the class ListNuageVspDevicesCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        List<NuageVspDeviceVO> nuageDevices = _nuageVspManager.listNuageVspDevices(this);
        ListResponse<NuageVspDeviceResponse> response = new ListResponse<NuageVspDeviceResponse>();
        List<NuageVspDeviceResponse> nuageDevicesResponse = new ArrayList<NuageVspDeviceResponse>();
        if (nuageDevices != null && !nuageDevices.isEmpty()) {
            for (NuageVspDeviceVO nuageDeviceVO : nuageDevices) {
                NuageVspDeviceResponse nuageDeviceResponse = _nuageVspManager.createNuageVspDeviceResponse(nuageDeviceVO);
                nuageDevicesResponse.add(nuageDeviceResponse);
            }
        }
        response.setResponses(nuageDevicesResponse);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } catch (InvalidParameterValueException invalidParamExcp) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
    } catch (CloudRuntimeException runtimeExcp) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
    }
}
Also used : NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList) NuageVspDeviceResponse(com.cloud.api.response.NuageVspDeviceResponse)

Example 93 with ServerApiException

use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.

the class UpdateRolePermissionCmd method execute.

@Override
public void execute() {
    final Role role = roleService.findRole(getRoleId());
    if (role == null) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role id provided");
    }
    CallContext.current().setEventDetails("Reordering permissions for role id: " + role.getId());
    final List<RolePermission> rolePermissionsOrder = new ArrayList<>();
    for (Long rolePermissionId : getRulePermissionOrder()) {
        final RolePermission rolePermission = roleService.findRolePermission(rolePermissionId);
        if (rolePermission == null) {
            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Provided role permission(s) do not exist");
        }
        rolePermissionsOrder.add(rolePermission);
    }
    boolean result = roleService.updateRolePermission(role, rolePermissionsOrder);
    SuccessResponse response = new SuccessResponse(getCommandName());
    response.setSuccess(result);
    setResponseObject(response);
}
Also used : Role(org.apache.cloudstack.acl.Role) SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArrayList(java.util.ArrayList) RolePermission(org.apache.cloudstack.acl.RolePermission)

Example 94 with ServerApiException

use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.

the class UpdateClusterCmd method execute.

@Override
public void execute() {
    Cluster cluster = _resourceService.getCluster(getId());
    if (cluster == null) {
        throw new InvalidParameterValueException("Unable to find the cluster by id=" + getId());
    }
    Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate());
    if (result != null) {
        ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
        clusterResponse.setResponseName(getCommandName());
        this.setResponseObject(clusterResponse);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update cluster");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) Cluster(com.cloud.org.Cluster) ClusterResponse(org.apache.cloudstack.api.response.ClusterResponse)

Example 95 with ServerApiException

use of org.apache.cloudstack.api.ServerApiException in project cloudstack by apache.

the class UpdateHypervisorCapabilitiesCmd method execute.

@Override
public void execute() {
    HypervisorCapabilities result = _mgr.updateHypervisorCapabilities(getId(), getMaxGuestsLimit(), getSecurityGroupEnabled());
    if (result != null) {
        HypervisorCapabilitiesResponse response = _responseGenerator.createHypervisorCapabilitiesResponse(result);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update hypervisor capabilities");
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) HypervisorCapabilities(com.cloud.hypervisor.HypervisorCapabilities) HypervisorCapabilitiesResponse(org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse)

Aggregations

ServerApiException (org.apache.cloudstack.api.ServerApiException)513 SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)125 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)116 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)61 ArrayList (java.util.ArrayList)58 UserVm (com.cloud.uservm.UserVm)44 ListResponse (org.apache.cloudstack.api.response.ListResponse)44 UserVmResponse (org.apache.cloudstack.api.response.UserVmResponse)42 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)39 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)33 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)26 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)25 Account (com.cloud.user.Account)24 Host (com.cloud.host.Host)20 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)18 Volume (com.cloud.storage.Volume)16 Test (org.junit.Test)16 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)15 VolumeResponse (org.apache.cloudstack.api.response.VolumeResponse)15 UserAccount (com.cloud.user.UserAccount)13