Search in sources :

Example 1 with TrafficMonitorResponse

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;
}
Also used : TrafficMonitorResponse(org.apache.cloudstack.api.response.TrafficMonitorResponse)

Example 2 with TrafficMonitorResponse

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());
    }
}
Also used : TrafficMonitorResponse(org.apache.cloudstack.api.response.TrafficMonitorResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Host(com.cloud.host.Host)

Example 3 with TrafficMonitorResponse

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);
}
Also used : TrafficMonitorResponse(org.apache.cloudstack.api.response.TrafficMonitorResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) Host(com.cloud.host.Host)

Aggregations

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