long physicalNetworkId = network.getPhysicalNetworkId();
gslbSiteIds.add(new Pair<Long, Long>(dataCenterId, physicalNetworkId));
IPAddressVO ip = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId());
SiteLoadBalancerConfig siteLb =
new SiteLoadBalancerConfig(gslbLbMapVo.isRevoke(), serviceType, ip.getAddress().addr(), Integer.toString(loadBalancer.getDefaultPortStart()),
dataCenterId);
siteLb.setGslbProviderPublicIp(_gslbProvider.getZoneGslbProviderPublicIp(dataCenterId, physicalNetworkId));
siteLb.setGslbProviderPrivateIp(_gslbProvider.getZoneGslbProviderPrivateIp(dataCenterId, physicalNetworkId));
siteLb.setWeight(gslbLbMapVo.getWeight());
zoneSiteLoadbalancerMap.put(network.getDataCenterId(), siteLb);
}
// loop through all the zones, participating in GSLB, and send GSLB config command
// to the corresponding GSLB service provider in that zone
for (Pair<Long, Long> zoneId : gslbSiteIds) {
List<SiteLoadBalancerConfig> slbs = new ArrayList<SiteLoadBalancerConfig>();
// set site as 'local' for the site in that zone
for (Pair<Long, Long> innerLoopZoneId : gslbSiteIds) {
SiteLoadBalancerConfig siteLb = zoneSiteLoadbalancerMap.get(innerLoopZoneId.first());
siteLb.setLocal(zoneId.first() == innerLoopZoneId.first());
slbs.add(siteLb);
}
gslbConfigCmd.setSiteLoadBalancers(slbs);
gslbConfigCmd.setForRevoke(revoke);
// revoke GSLB configuration completely on the site GSLB provider for the sites that no longer
// are participants of a GSLB rule
SiteLoadBalancerConfig siteLb = zoneSiteLoadbalancerMap.get(zoneId.first());
if (siteLb.forRevoke()) {
gslbConfigCmd.setForRevoke(true);
}
try {
_gslbProvider.applyGlobalLoadBalancerRule(zoneId.first(), zoneId.second(), gslbConfigCmd);