Search in sources :

Example 1 with NetworkDeviceResponse

use of com.cloud.api.response.NetworkDeviceResponse in project cosmic by MissionCriticalCloud.

the class AddNetworkDeviceCmd method execute.

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

Example 2 with NetworkDeviceResponse

use of com.cloud.api.response.NetworkDeviceResponse in project cosmic by MissionCriticalCloud.

the class ListNetworkDeviceCmd method execute.

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

Aggregations

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