Search in sources :

Example 1 with ExternalLoadBalancerResponse

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

the class AddExternalLoadBalancerCmd method execute.

@Override
public void execute() {
    try {
        Host externalLoadBalancer = _f5DeviceManagerService.addExternalLoadBalancer(this);
        ExternalLoadBalancerResponse response = _f5DeviceManagerService.createExternalLoadBalancerResponse(externalLoadBalancer);
        response.setObjectName("externalloadbalancer");
        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) ExternalLoadBalancerResponse(org.apache.cloudstack.api.response.ExternalLoadBalancerResponse) Host(com.cloud.host.Host)

Example 2 with ExternalLoadBalancerResponse

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

the class ExternalLoadBalancerDeviceManagerImpl method createExternalLoadBalancerResponse.

public ExternalLoadBalancerResponse createExternalLoadBalancerResponse(Host externalLoadBalancer) {
    Map<String, String> lbDetails = _hostDetailDao.findDetails(externalLoadBalancer.getId());
    ExternalLoadBalancerResponse response = new ExternalLoadBalancerResponse();
    response.setId(externalLoadBalancer.getUuid());
    response.setIpAddress(externalLoadBalancer.getPrivateIpAddress());
    response.setUsername(lbDetails.get("username"));
    response.setPublicInterface(lbDetails.get("publicInterface"));
    response.setPrivateInterface(lbDetails.get("privateInterface"));
    response.setNumRetries(lbDetails.get("numRetries"));
    return response;
}
Also used : ExternalLoadBalancerResponse(org.apache.cloudstack.api.response.ExternalLoadBalancerResponse)

Example 3 with ExternalLoadBalancerResponse

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

the class ListExternalLoadBalancersCmd method execute.

@Override
public void execute() {
    List<? extends Host> externalLoadBalancers = _f5DeviceManagerService.listExternalLoadBalancers(this);
    ListResponse<ExternalLoadBalancerResponse> listResponse = new ListResponse<ExternalLoadBalancerResponse>();
    List<ExternalLoadBalancerResponse> responses = new ArrayList<ExternalLoadBalancerResponse>();
    for (Host externalLoadBalancer : externalLoadBalancers) {
        ExternalLoadBalancerResponse response = _f5DeviceManagerService.createExternalLoadBalancerResponse(externalLoadBalancer);
        response.setObjectName("externalloadbalancer");
        response.setResponseName(getCommandName());
        responses.add(response);
    }
    listResponse.setResponses(responses);
    listResponse.setResponseName(getCommandName());
    this.setResponseObject(listResponse);
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ExternalLoadBalancerResponse(org.apache.cloudstack.api.response.ExternalLoadBalancerResponse) ArrayList(java.util.ArrayList) Host(com.cloud.host.Host)

Aggregations

ExternalLoadBalancerResponse (org.apache.cloudstack.api.response.ExternalLoadBalancerResponse)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