Search in sources :

Example 1 with ServerApiException

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

the class DeleteNuageVspDeviceCmd method execute.

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        boolean result = _nuageVspManager.deleteNuageVspDevice(this);
        if (result) {
            SuccessResponse response = new SuccessResponse(getCommandName());
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete Nuage 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 2 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 3 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 4 with ServerApiException

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

the class CopyTemplateCmdByAdmin method execute.

@Override
public void execute() throws ResourceAllocationException {
    try {
        CallContext.current().setEventDetails(getEventDescription());
        VirtualMachineTemplate template = _templateService.copyTemplate(this);
        if (template != null) {
            List<TemplateResponse> listResponse = _responseGenerator.createTemplateResponses(ResponseView.Full, template, getDestinationZoneId(), false);
            TemplateResponse response = new TemplateResponse();
            if (listResponse != null && !listResponse.isEmpty()) {
                response = listResponse.get(0);
            }
            response.setResponseName(getCommandName());
            setResponseObject(response);
        } else {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to copy template");
        }
    } catch (StorageUnavailableException ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
    }
}
Also used : VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) ServerApiException(org.apache.cloudstack.api.ServerApiException) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) TemplateResponse(org.apache.cloudstack.api.response.TemplateResponse)

Example 5 with ServerApiException

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

the class AddNicToVMCmdByAdmin method execute.

@Override
public void execute() {
    CallContext.current().setEventDetails("Vm Id: " + getVmId() + " Network Id: " + getNetworkId());
    UserVm result = _userVmService.addNicToVirtualMachine(this);
    ArrayList<VMDetails> dc = new ArrayList<VMDetails>();
    dc.add(VMDetails.valueOf("nics"));
    EnumSet<VMDetails> details = EnumSet.copyOf(dc);
    if (result != null) {
        UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", details, result).get(0);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add NIC to vm. Refer to server logs for details.");
    }
}
Also used : UserVm(com.cloud.uservm.UserVm) VMDetails(org.apache.cloudstack.api.ApiConstants.VMDetails) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArrayList(java.util.ArrayList) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse)

Aggregations

ServerApiException (org.apache.cloudstack.api.ServerApiException)628 SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)154 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)143 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)104 ArrayList (java.util.ArrayList)74 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)55 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)51 ListResponse (org.apache.cloudstack.api.response.ListResponse)49 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)47 UserVm (com.cloud.uservm.UserVm)47 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)43 UserVmResponse (org.apache.cloudstack.api.response.UserVmResponse)42 Account (com.cloud.user.Account)32 Host (com.cloud.host.Host)30 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)29 Volume (com.cloud.storage.Volume)25 Test (org.junit.Test)23 VolumeResponse (org.apache.cloudstack.api.response.VolumeResponse)20 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)15 UserAccount (com.cloud.user.UserAccount)15