use of org.apache.cloudstack.api.response.TrafficMonitorResponse in project cloudstack by apache.
the class ApiResponseHelper method createTrafficMonitorResponse.
@Override
public TrafficMonitorResponse createTrafficMonitorResponse(Host trafficMonitor) {
Map<String, String> tmDetails = ApiDBUtils.findHostDetailsById(trafficMonitor.getId());
TrafficMonitorResponse response = new TrafficMonitorResponse();
response.setId(trafficMonitor.getUuid());
response.setIpAddress(trafficMonitor.getPrivateIpAddress());
response.setNumRetries(tmDetails.get("numRetries"));
response.setTimeout(tmDetails.get("timeout"));
return response;
}
use of org.apache.cloudstack.api.response.TrafficMonitorResponse in project cloudstack by apache.
the class AddTrafficMonitorCmd method execute.
@Override
public void execute() {
try {
Host trafficMonitor = _networkUsageService.addTrafficMonitor(this);
TrafficMonitorResponse response = _responseGenerator.createTrafficMonitorResponse(trafficMonitor);
response.setObjectName("trafficmonitor");
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());
}
}
use of org.apache.cloudstack.api.response.TrafficMonitorResponse in project cloudstack by apache.
the class ListTrafficMonitorsCmd method execute.
@Override
public void execute() {
List<? extends Host> trafficMonitors = _networkUsageService.listTrafficMonitors(this);
ListResponse<TrafficMonitorResponse> listResponse = new ListResponse<TrafficMonitorResponse>();
List<TrafficMonitorResponse> responses = new ArrayList<TrafficMonitorResponse>();
for (Host trafficMonitor : trafficMonitors) {
TrafficMonitorResponse response = _responseGenerator.createTrafficMonitorResponse(trafficMonitor);
response.setObjectName("trafficmonitor");
response.setResponseName(getCommandName());
responses.add(response);
}
listResponse.setResponses(responses);
listResponse.setResponseName(getCommandName());
this.setResponseObject(listResponse);
}
Aggregations