Search in sources :

Example 1 with NetworkDeviceResponse

use of org.apache.cloudstack.api.response.NetworkDeviceResponse in project cloudstack by apache.

the class AddNetworkDeviceCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        Host device = nwDeviceMgr.addNetworkDevice(this);
        NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(device);
        response.setObjectName("networkdevice");
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } catch (InvalidParameterValueException ipve) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
    } catch (CloudRuntimeException cre) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) NetworkDeviceResponse(org.apache.cloudstack.api.response.NetworkDeviceResponse) Host(com.cloud.host.Host)

Example 2 with NetworkDeviceResponse

use of org.apache.cloudstack.api.response.NetworkDeviceResponse in project cloudstack by apache.

the class ListNetworkDeviceCmd method execute.

@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    try {
        List<Host> devices = nwDeviceMgr.listNetworkDevice(this);
        List<NetworkDeviceResponse> nwdeviceResponses = new ArrayList<NetworkDeviceResponse>();
        ListResponse<NetworkDeviceResponse> listResponse = new ListResponse<NetworkDeviceResponse>();
        for (Host d : devices) {
            NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(d);
            response.setObjectName("networkdevice");
            response.setResponseName(getCommandName());
            nwdeviceResponses.add(response);
        }
        listResponse.setResponses(nwdeviceResponses);
        listResponse.setResponseName(getCommandName());
        this.setResponseObject(listResponse);
    } catch (InvalidParameterValueException ipve) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
    } catch (CloudRuntimeException cre) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
    }
}
Also used : 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) NetworkDeviceResponse(org.apache.cloudstack.api.response.NetworkDeviceResponse) Host(com.cloud.host.Host)

Aggregations

InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 Host (com.cloud.host.Host)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 NetworkDeviceResponse (org.apache.cloudstack.api.response.NetworkDeviceResponse)2 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1