throw new InvalidParameterValueException("Load balancer ID " + loadBalancer.getUuid() + " is not assigned"
+ " to global load balancer rule: " + gslbRule.getUuid());
}
}
Transaction txn = Transaction.currentTxn();
txn.start();
// update the mapping of gslb rule to Lb rule, to revoke state
for (Long lbRuleId : lbRuleIdsToremove) {
GlobalLoadBalancerLbRuleMapVO removeGslbLbMap = _gslbLbMapDao.findByGslbRuleIdAndLbRuleId(gslbRuleId, lbRuleId);
removeGslbLbMap.setRevoke(true);
_gslbLbMapDao.update(removeGslbLbMap.getId(), removeGslbLbMap);
}
// mark the gslb rule state as add
if (gslbRule.getState() == GlobalLoadBalancerRule.State.Staged) {
gslbRule.setState(GlobalLoadBalancerRule.State.Add);
_gslbRuleDao.update(gslbRule.getId(), gslbRule);
}
txn.commit();
boolean success = false;
try {
s_logger.debug("Attempting to configure global load balancer rule configuration on the gslb service providers ");
// apply the gslb rule on to the back end gslb service providers
if (!applyGlobalLoadBalancerRuleConfig(gslbRuleId, false)) {
s_logger.warn("Failed to remove load balancer rules " + lbRuleIdsToremove + " from global load balancer rule id "
+ gslbRuleId);
CloudRuntimeException ex = new CloudRuntimeException(
"Failed to remove load balancer rule ids from GSLB rule ");
throw ex;
}
txn.start();
// remove the mappings of gslb rule to Lb rule that are in revoked state
for (Long lbRuleId : lbRuleIdsToremove) {
GlobalLoadBalancerLbRuleMapVO removeGslbLbMap = _gslbLbMapDao.findByGslbRuleIdAndLbRuleId(gslbRuleId, lbRuleId);
_gslbLbMapDao.remove(removeGslbLbMap.getId());
}
// on success set state back to Active
gslbRule.setState(GlobalLoadBalancerRule.State.Active);
_gslbRuleDao.update(gslbRule.getId(), gslbRule);
txn.commit();
success = true;
} catch (ResourceUnavailableException e) {
throw new CloudRuntimeException("Failed to update removed load balancer details from gloabal load balancer");
}