use of org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule in project cloudstack by apache.
the class CreateApplicationLoadBalancerCmd method create.
@Override
public void create() {
try {
ApplicationLoadBalancerRule result = _appLbService.createApplicationLoadBalancer(getName(), getDescription(), getScheme(), getSourceIpNetworkId(), getSourceIp(), getSourcePort(), getInstancePort(), getAlgorithm(), getNetworkId(), getEntityOwnerId(), getDisplay());
this.setEntityId(result.getId());
this.setEntityUuid(result.getUuid());
} catch (NetworkRuleConflictException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
} catch (InsufficientAddressCapacityException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
} catch (InsufficientVirtualNetworkCapacityException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
}
}
use of org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule in project cloudstack by apache.
the class CreateApplicationLoadBalancerCmd method execute.
@Override
public void execute() throws ResourceAllocationException, ResourceUnavailableException {
ApplicationLoadBalancerRule rule = null;
try {
CallContext.current().setEventDetails("Load Balancer Id: " + getEntityId());
// State might be different after the rule is applied, so get new object here
rule = _entityMgr.findById(ApplicationLoadBalancerRule.class, getEntityId());
ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getEntityId()));
setResponseObject(lbResponse);
lbResponse.setResponseName(getCommandName());
} catch (Exception ex) {
s_logger.warn("Failed to create load balancer due to exception ", ex);
} finally {
if (rule == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create load balancer");
}
}
}
use of org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule in project cloudstack by apache.
the class ListApplicationLoadBalancersCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
Pair<List<? extends ApplicationLoadBalancerRule>, Integer> loadBalancers = _appLbService.listApplicationLoadBalancers(this);
ListResponse<ApplicationLoadBalancerResponse> response = new ListResponse<ApplicationLoadBalancerResponse>();
List<ApplicationLoadBalancerResponse> lbResponses = new ArrayList<ApplicationLoadBalancerResponse>();
for (ApplicationLoadBalancerRule loadBalancer : loadBalancers.first()) {
ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(loadBalancer, _lbService.getLbInstances(loadBalancer.getId()));
lbResponse.setObjectName("loadbalancer");
lbResponses.add(lbResponse);
}
response.setResponses(lbResponses, loadBalancers.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule in project cloudstack by apache.
the class UpdateApplicationLoadBalancerCmd method execute.
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public void execute() {
CallContext.current().setEventDetails("Load balancer ID: " + getId());
ApplicationLoadBalancerRule rule = _appLbService.updateApplicationLoadBalancer(getId(), this.getCustomId(), getDisplay());
ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getId()));
setResponseObject(lbResponse);
lbResponse.setResponseName(getCommandName());
}
Aggregations