use of com.cloud.api.response.LoadBalancerResponse 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.api.response.LoadBalancerResponse 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.api.response.LoadBalancerResponse in project cosmic by MissionCriticalCloud.
the class UpdateLoadBalancerRuleCmd method execute.
@Override
public void execute() {
CallContext.current().setEventDetails("Load balancer ID: " + getId());
final LoadBalancer result = _lbService.updateLoadBalancerRule(this);
if (result != null) {
final LoadBalancerResponse response = _responseGenerator.createLoadBalancerResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update load balancer rule");
}
}
use of com.cloud.api.response.LoadBalancerResponse in project cosmic by MissionCriticalCloud.
the class ListLoadBalancerRulesCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends LoadBalancer>, Integer> loadBalancers = _lbService.searchForLoadBalancers(this);
final ListResponse<LoadBalancerResponse> response = new ListResponse<>();
final List<LoadBalancerResponse> lbResponses = new ArrayList<>();
if (loadBalancers != null) {
for (final LoadBalancer loadBalancer : loadBalancers.first()) {
final LoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerResponse(loadBalancer);
lbResponse.setObjectName("loadbalancerrule");
lbResponses.add(lbResponse);
}
response.setResponses(lbResponses, loadBalancers.second());
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.LoadBalancerResponse in project cosmic by MissionCriticalCloud.
the class CreateLoadBalancerRuleCmd method execute.
@Override
public void execute() throws ResourceAllocationException, ResourceUnavailableException {
final CallContext callerContext = CallContext.current();
boolean success = true;
LoadBalancer rule = null;
try {
CallContext.current().setEventDetails("Rule Id: " + getEntityId());
if (getOpenFirewall()) {
success = success && _firewallService.applyIngressFirewallRules(getSourceIpAddressId(), callerContext.getCallingAccount());
}
// State might be different after the rule is applied, so get new object here
rule = _entityMgr.findById(LoadBalancer.class, getEntityId());
LoadBalancerResponse lbResponse = new LoadBalancerResponse();
if (rule != null) {
lbResponse = _responseGenerator.createLoadBalancerResponse(rule);
setResponseObject(lbResponse);
}
lbResponse.setResponseName(getCommandName());
} catch (final Exception ex) {
s_logger.warn("Failed to create LB rule due to exception ", ex);
}
if (!success || rule == null) {
if (getOpenFirewall()) {
_firewallService.revokeRelatedFirewallRule(getEntityId(), true);
}
// no need to apply the rule on the backend as it exists in the db only
_lbService.deleteLoadBalancerRule(getEntityId(), false);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create load balancer rule");
}
}
Aggregations