protected ApplicationLoadBalancerRule createApplicationLoadBalancer(String name, String description, Scheme scheme, Network sourceIpNtwk, String sourceIp,
int sourcePort, int instancePort, String algorithm, Account lbOwner, Network guestNtwk, Boolean forDisplay) throws NetworkRuleConflictException,
InsufficientVirtualNetworkCapacityException {
if (scheme != Scheme.Internal) {
throw new UnsupportedServiceException("Only scheme of type " + Scheme.Internal + " is supported");
}
validateLbRule(sourcePort, instancePort, algorithm, guestNtwk, scheme);
validateSourceIpNtwkForLbRule(sourceIpNtwk, scheme);
Ip sourceIpAddr = getSourceIp(scheme, sourceIpNtwk, sourceIp);
ApplicationLoadBalancerRuleVO newRule =
new ApplicationLoadBalancerRuleVO(name, description, sourcePort, instancePort, algorithm, guestNtwk.getId(), lbOwner.getId(), lbOwner.getDomainId(),
sourceIpAddr, sourceIpNtwk.getId(), scheme);
if (forDisplay != null) {
newRule.setDisplay(forDisplay);
}
LoadBalancingRule loadBalancing =
new LoadBalancingRule(newRule, new ArrayList<LbDestination>(), new ArrayList<LbStickinessPolicy>(), new ArrayList<LbHealthCheckPolicy>(), sourceIpAddr, null,
null);
if (!_lbMgr.validateLbRule(loadBalancing)) {
throw new InvalidParameterValueException("LB service provider cannot support this rule");
}
return persistLbRule(newRule);
}