Search in sources :

Example 1 with GlobalLoadBalancerResponse

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

the class ListGlobalLoadBalancerRuleCmd method execute.

@Override
public void execute() {
    List<GlobalLoadBalancerRule> globalLoadBalancers = _gslbService.listGlobalLoadBalancerRule(this);
    ListResponse<GlobalLoadBalancerResponse> gslbRuleResponse = new ListResponse<GlobalLoadBalancerResponse>();
    List<GlobalLoadBalancerResponse> gslbResponses = new ArrayList<GlobalLoadBalancerResponse>();
    if (globalLoadBalancers != null) {
        for (GlobalLoadBalancerRule gslbRule : globalLoadBalancers) {
            GlobalLoadBalancerResponse gslbResponse = _responseGenerator.createGlobalLoadBalancerResponse(gslbRule);
            gslbResponse.setObjectName("globalloadbalancerrule");
            gslbResponses.add(gslbResponse);
        }
    }
    gslbRuleResponse.setResponses(gslbResponses);
    gslbRuleResponse.setResponseName(getCommandName());
    this.setResponseObject(gslbRuleResponse);
}
Also used : GlobalLoadBalancerResponse(org.apache.cloudstack.api.response.GlobalLoadBalancerResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) GlobalLoadBalancerRule(com.cloud.region.ha.GlobalLoadBalancerRule) ArrayList(java.util.ArrayList)

Example 2 with GlobalLoadBalancerResponse

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

the class UpdateGlobalLoadBalancerRuleCmd method execute.

@Override
public void execute() {
    org.apache.cloudstack.context.CallContext.current().setEventDetails("Global Load balancer Id: " + getId());
    GlobalLoadBalancerRule gslbRule = _gslbService.updateGlobalLoadBalancerRule(this);
    if (gslbRule != null) {
        GlobalLoadBalancerResponse response = _responseGenerator.createGlobalLoadBalancerResponse(gslbRule);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update global load balancer rule");
    }
}
Also used : GlobalLoadBalancerResponse(org.apache.cloudstack.api.response.GlobalLoadBalancerResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) GlobalLoadBalancerRule(com.cloud.region.ha.GlobalLoadBalancerRule)

Example 3 with GlobalLoadBalancerResponse

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

the class ApiResponseHelper method createGlobalLoadBalancerResponse.

@Override
public GlobalLoadBalancerResponse createGlobalLoadBalancerResponse(GlobalLoadBalancerRule globalLoadBalancerRule) {
    GlobalLoadBalancerResponse response = new GlobalLoadBalancerResponse();
    response.setAlgorithm(globalLoadBalancerRule.getAlgorithm());
    response.setStickyMethod(globalLoadBalancerRule.getPersistence());
    response.setServiceType(globalLoadBalancerRule.getServiceType());
    response.setServiceDomainName(globalLoadBalancerRule.getGslbDomain() + "." + ApiDBUtils.getDnsNameConfiguredForGslb());
    response.setName(globalLoadBalancerRule.getName());
    response.setDescription(globalLoadBalancerRule.getDescription());
    response.setRegionIdId(globalLoadBalancerRule.getRegion());
    response.setId(globalLoadBalancerRule.getUuid());
    populateOwner(response, globalLoadBalancerRule);
    response.setObjectName("globalloadbalancer");
    List<LoadBalancerResponse> siteLbResponses = new ArrayList<LoadBalancerResponse>();
    List<? extends LoadBalancer> siteLoadBalaners = ApiDBUtils.listSiteLoadBalancers(globalLoadBalancerRule.getId());
    for (LoadBalancer siteLb : siteLoadBalaners) {
        LoadBalancerResponse siteLbResponse = createLoadBalancerResponse(siteLb);
        siteLbResponses.add(siteLbResponse);
    }
    response.setSiteLoadBalancers(siteLbResponses);
    return response;
}
Also used : GlobalLoadBalancerResponse(org.apache.cloudstack.api.response.GlobalLoadBalancerResponse) GlobalLoadBalancerResponse(org.apache.cloudstack.api.response.GlobalLoadBalancerResponse) ApplicationLoadBalancerResponse(org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse) LoadBalancerResponse(org.apache.cloudstack.api.response.LoadBalancerResponse) ArrayList(java.util.ArrayList) LoadBalancer(com.cloud.network.rules.LoadBalancer)

Example 4 with GlobalLoadBalancerResponse

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

the class CreateGlobalLoadBalancerRuleCmd method execute.

@Override
public void execute() throws ResourceAllocationException, ResourceUnavailableException {
    GlobalLoadBalancerRule rule = _entityMgr.findById(GlobalLoadBalancerRule.class, getEntityId());
    if (rule != null) {
        GlobalLoadBalancerResponse response = _responseGenerator.createGlobalLoadBalancerResponse(rule);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    }
}
Also used : GlobalLoadBalancerResponse(org.apache.cloudstack.api.response.GlobalLoadBalancerResponse) GlobalLoadBalancerRule(com.cloud.region.ha.GlobalLoadBalancerRule)

Aggregations

GlobalLoadBalancerResponse (org.apache.cloudstack.api.response.GlobalLoadBalancerResponse)4 GlobalLoadBalancerRule (com.cloud.region.ha.GlobalLoadBalancerRule)3 ArrayList (java.util.ArrayList)2 LoadBalancer (com.cloud.network.rules.LoadBalancer)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ApplicationLoadBalancerResponse (org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 LoadBalancerResponse (org.apache.cloudstack.api.response.LoadBalancerResponse)1