Search in sources :

Example 1 with GlobalLoadBalancerRule

use of com.cloud.region.ha.GlobalLoadBalancerRule 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 GlobalLoadBalancerRule

use of com.cloud.region.ha.GlobalLoadBalancerRule 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 GlobalLoadBalancerRule

use of com.cloud.region.ha.GlobalLoadBalancerRule in project cloudstack by apache.

the class GlobalLoadBalancingRulesServiceImpl method revokeAllGslbRulesForAccount.

@Override
public boolean revokeAllGslbRulesForAccount(com.cloud.user.Account caller, long accountId) throws com.cloud.exception.ResourceUnavailableException {
    List<GlobalLoadBalancerRuleVO> gslbRules = _gslbRuleDao.listByAccount(accountId);
    if (gslbRules != null && !gslbRules.isEmpty()) {
        for (GlobalLoadBalancerRule gslbRule : gslbRules) {
            revokeGslbRule(gslbRule.getId(), caller);
        }
    }
    s_logger.debug("Successfully cleaned up GSLB rules for account id=" + accountId);
    return true;
}
Also used : GlobalLoadBalancerRule(com.cloud.region.ha.GlobalLoadBalancerRule)

Example 4 with GlobalLoadBalancerRule

use of com.cloud.region.ha.GlobalLoadBalancerRule 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)

Example 5 with GlobalLoadBalancerRule

use of com.cloud.region.ha.GlobalLoadBalancerRule in project cloudstack by apache.

the class CreateGlobalLoadBalancerRuleCmd method create.

@Override
public void create() {
    try {
        GlobalLoadBalancerRule gslbRule = _gslbService.createGlobalLoadBalancerRule(this);
        this.setEntityId(gslbRule.getId());
        this.setEntityUuid(gslbRule.getUuid());
        CallContext.current().setEventDetails("Rule Id: " + getEntityId());
    } catch (Exception ex) {
        s_logger.warn("Exception: ", ex);
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex.getMessage());
    } finally {
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) GlobalLoadBalancerRule(com.cloud.region.ha.GlobalLoadBalancerRule) ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) ResourceAllocationException(com.cloud.exception.ResourceAllocationException)

Aggregations

GlobalLoadBalancerRule (com.cloud.region.ha.GlobalLoadBalancerRule)6 GlobalLoadBalancerResponse (org.apache.cloudstack.api.response.GlobalLoadBalancerResponse)3 ArrayList (java.util.ArrayList)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 Account (com.cloud.user.Account)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 CallContext (org.apache.cloudstack.context.CallContext)1