private boolean applyAutoScaleConfig(LoadBalancerVO lb, AutoScaleVmGroupVO vmGroup, String currentState) throws ResourceUnavailableException { LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup, currentState, lb); /* * Regular config like destinations need not be packed for applying * autoscale config as of today. */ List<LbStickinessPolicy> policyList = getStickinessPolicies(lb.getId()); Ip sourceIp = getSourceIp(lb); LoadBalancingRule rule = new LoadBalancingRule(lb, null, policyList, null, sourceIp, null, lb.getLbProtocol()); rule.setAutoScaleVmGroup(lbAutoScaleVmGroup); if (!isRollBackAllowedForProvider(lb)) { // this is for Netscaler type of devices. if their is failure the db // entries will be rollbacked. return false; } List<LoadBalancingRule> rules = Arrays.asList(rule); if (!applyLbRules(rules, false)) { s_logger.debug("LB rules' autoscale config are not completely applied"); return false; } return true; }
private LoadBalancingRule getLoadBalancerRuleToApply(LoadBalancerVO lb) { List<LbStickinessPolicy> policyList = getStickinessPolicies(lb.getId()); Ip sourceIp = getSourceIp(lb); LbSslCert sslCert = getLbSslCert(lb.getId()); LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, null, policyList, null, sourceIp, sslCert, lb.getLbProtocol()); if (_autoScaleVmGroupDao.isAutoScaleLoadBalancer(lb.getId())) { // Get the associated VmGroup AutoScaleVmGroupVO vmGroup = _autoScaleVmGroupDao.listByAll(lb.getId(), null).get(0); LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup, vmGroup.getState(), lb); loadBalancing.setAutoScaleVmGroup(lbAutoScaleVmGroup); } else { List<LbDestination> dstList = getExistingDestinations(lb.getId()); loadBalancing.setDestinations(dstList); List<LbHealthCheckPolicy> hcPolicyList = getHealthCheckPolicies(lb.getId()); loadBalancing.setHealthCheckPolicies(hcPolicyList); } return loadBalancing; }