use of com.cloud.network.rules.LoadBalancer in project CloudStack-archive by CloudStack-extras.
the class UpdateLoadBalancerRuleCmd method execute.
@Override
public void execute() {
UserContext.current().setEventDetails("Load balancer Id: " + getId());
LoadBalancer result = _lbService.updateLoadBalancerRule(this);
if (result != null) {
LoadBalancerResponse response = _responseGenerator.createLoadBalancerResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update load balancer rule");
}
}
use of com.cloud.network.rules.LoadBalancer in project CloudStack-archive by CloudStack-extras.
the class ListLoadBalancerRulesCmd method execute.
@Override
public void execute() {
List<? extends LoadBalancer> loadBalancers = _lbService.searchForLoadBalancers(this);
ListResponse<LoadBalancerResponse> response = new ListResponse<LoadBalancerResponse>();
List<LoadBalancerResponse> lbResponses = new ArrayList<LoadBalancerResponse>();
if (loadBalancers != null) {
for (LoadBalancer loadBalancer : loadBalancers) {
LoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerResponse(loadBalancer);
lbResponse.setObjectName("loadbalancerrule");
lbResponses.add(lbResponse);
}
}
response.setResponses(lbResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.network.rules.LoadBalancer in project CloudStack-archive by CloudStack-extras.
the class CreateLoadBalancerRuleCmd method create.
@Override
public void create() {
//cidr list parameter is deprecated
if (cidrlist != null) {
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
}
try {
LoadBalancer result = _lbService.createLoadBalancerRule(this, getOpenFirewall());
this.setEntityId(result.getId());
} catch (NetworkRuleConflictException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
} catch (InsufficientAddressCapacityException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
}
}
use of com.cloud.network.rules.LoadBalancer in project CloudStack-archive by CloudStack-extras.
the class DeleteLBStickinessPolicyCmd method getSyncObjId.
@Override
public Long getSyncObjId() {
StickinessPolicy policy = _entityMgr.findById(StickinessPolicy.class, getId());
if (policy == null) {
throw new InvalidParameterValueException("Unable to find LB stickiness rule: " + id);
}
LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
if (lb == null) {
throw new InvalidParameterValueException("Unable to find load balancer rule for stickiness rule: " + id);
}
return lb.getNetworkId();
}
use of com.cloud.network.rules.LoadBalancer in project cloudstack by apache.
the class ListLBHealthCheckPoliciesCmd method execute.
@Override
public void execute() {
List<LBHealthCheckResponse> hcpResponses = new ArrayList<LBHealthCheckResponse>();
ListResponse<LBHealthCheckResponse> response = new ListResponse<LBHealthCheckResponse>();
Long lbRuleId = getLbRuleId();
Long hId = getId();
if (lbRuleId == null) {
if (hId != null) {
lbRuleId = _lbService.findLBIdByHealtCheckPolicyId(hId);
} else {
throw new InvalidParameterValueException("Either load balancer rule ID or health check policy ID should be specified");
}
}
LoadBalancer lb = _lbService.findById(lbRuleId);
if (lb != null) {
List<? extends HealthCheckPolicy> healthCheckPolicies = _lbService.searchForLBHealthCheckPolicies(this);
LBHealthCheckResponse spResponse = _responseGenerator.createLBHealthCheckPolicyResponse(healthCheckPolicies, lb);
hcpResponses.add(spResponse);
response.setResponses(hcpResponses);
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations