use of com.cloud.legacymodel.network.LoadBalancer in project cosmic by MissionCriticalCloud.
the class CreateLBHealthCheckPolicyCmd method execute.
@Override
public void execute() throws ResourceAllocationException, ResourceUnavailableException {
HealthCheckPolicy policy = null;
boolean success = false;
try {
CallContext.current().setEventDetails("Load balancer health check policy ID : " + getEntityId());
success = _lbService.applyLBHealthCheckPolicy(this);
if (success) {
// State might be different after the rule is applied, so get new object here
policy = _entityMgr.findById(HealthCheckPolicy.class, getEntityId());
final LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
final LBHealthCheckResponse hcResponse = _responseGenerator.createLBHealthCheckPolicyResponse(policy, lb);
setResponseObject(hcResponse);
hcResponse.setResponseName(getCommandName());
}
} finally {
if (!success || (policy == null)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create health check policy");
}
}
}
use of com.cloud.legacymodel.network.LoadBalancer in project cosmic by MissionCriticalCloud.
the class CreateLBStickinessPolicyCmd method execute.
@Override
public void execute() throws ResourceAllocationException, ResourceUnavailableException {
StickinessPolicy policy = null;
boolean success = false;
try {
CallContext.current().setEventDetails("Rule Id: " + getEntityId());
success = _lbService.applyLBStickinessPolicy(this);
if (success) {
// State might be different after the rule is applied, so get new object here
policy = _entityMgr.findById(StickinessPolicy.class, getEntityId());
final LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
final LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(policy, lb);
setResponseObject(spResponse);
spResponse.setResponseName(getCommandName());
}
} finally {
if (!success || (policy == null)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create stickiness policy");
}
}
}
use of com.cloud.legacymodel.network.LoadBalancer in project cosmic by MissionCriticalCloud.
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");
}
if (lbProtocol != null && !lbProtocol.toLowerCase().startsWith("tcp")) {
throw new InvalidParameterValueException("Only TCP protocol is supported because HAProxy can only do TCP.");
}
if (getAlgorithm() != null && !NetUtils.isValidAlgorithm(getAlgorithm())) {
throw new InvalidParameterValueException("Only source/roundrobin/leastconn are supported loadbalance algorithms.");
}
try {
final LoadBalancer result = _lbService.createPublicLoadBalancerRule(getXid(), getName(), getDescription(), getSourcePortStart(), getSourcePortEnd(), getDefaultPortStart(), getDefaultPortEnd(), getSourceIpAddressId(), getProtocol(), getAlgorithm(), getNetworkId(), getEntityOwnerId(), getOpenFirewall(), getLbProtocol(), isDisplay(), getClientTimeout(), getServerTimeout());
this.setEntityId(result.getId());
this.setEntityUuid(result.getUuid());
} catch (final NetworkRuleConflictException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
} catch (final InsufficientAddressCapacityException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
} catch (final InvalidParameterValueException e) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, e.getMessage());
}
}
use of com.cloud.legacymodel.network.LoadBalancer in project cosmic by MissionCriticalCloud.
the class DeleteLBHealthCheckPolicyCmd method getSyncObjId.
@Override
public Long getSyncObjId() {
final HealthCheckPolicy policy = _entityMgr.findById(HealthCheckPolicy.class, getId());
if (policy == null) {
throw new InvalidParameterValueException("Unable to find load balancer health check rule: " + id);
}
final LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
if (lb == null) {
throw new InvalidParameterValueException("Unable to find load balancer rule for health check rule: " + id);
}
return lb.getNetworkId();
}
use of com.cloud.legacymodel.network.LoadBalancer in project cosmic by MissionCriticalCloud.
the class DeleteLBStickinessPolicyCmd method getSyncObjId.
@Override
public Long getSyncObjId() {
final StickinessPolicy policy = _entityMgr.findById(StickinessPolicy.class, getId());
if (policy == null) {
throw new InvalidParameterValueException("Unable to find LB stickiness rule: " + id);
}
final 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();
}
Aggregations