@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()); } }
@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()); } }