cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject git commit: updated refs/heads/master to f441582
Date Thu, 16 May 2013 12:57:44 GMT
Updated Branches:
  refs/heads/master 33e683915 -> f441582e1


CLOUDSTACK-2378:  assignToGSLBRule or removeFromGlobalLoadBalancerRule APIs are failing when
there are multiple physical network in a zone

adding support for deployments where multiple physical networks are configured for guest traffic
in a zone


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f441582e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f441582e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f441582e

Branch: refs/heads/master
Commit: f441582e1b7747bba1385ecb48a7b7b34a9dded1
Parents: 33e6839
Author: Murali Reddy <muralimmreddy@gmail.com>
Authored: Thu May 16 18:26:14 2013 +0530
Committer: Murali Reddy <muralimmreddy@gmail.com>
Committed: Thu May 16 18:26:14 2013 +0530

----------------------------------------------------------------------
 .../cloud/network/element/NetscalerElement.java    |   39 +++++++++------
 .../gslb/GlobalLoadBalancingRulesServiceImpl.java  |   37 ++++++++------
 .../region/gslb/GslbServiceProvider.java           |    8 ++--
 .../GlobalLoadBalancingRulesServiceImplTest.java   |    3 +
 4 files changed, 52 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f441582e/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
index cc2bcc1..850962d 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
@@ -923,13 +923,13 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
     }
 
     @Override
-    public boolean applyGlobalLoadBalancerRule(long zoneId, GlobalLoadBalancerConfigCommand
gslbConfigCmd)
+    public boolean applyGlobalLoadBalancerRule(long zoneId, long physicalNetworkId, GlobalLoadBalancerConfigCommand
gslbConfigCmd)
             throws ResourceUnavailableException {
 
         long zoneGslbProviderHosId = 0;
 
         // find the NetScaler device configured as gslb service provider in the zone
-        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
+        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId, physicalNetworkId);
         if (nsGslbProvider == null) {
             String msg = "Unable to find a NetScaler configured as gslb service provider
in zone " + zoneId;
             s_logger.debug(msg);
@@ -950,28 +950,37 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
         return true;
     }
 
-    private ExternalLoadBalancerDeviceVO findGslbProvider(long zoneId) {
+    private ExternalLoadBalancerDeviceVO findGslbProvider(long zoneId, long physicalNetworkId)
{
         List<PhysicalNetworkVO> pNtwks = _physicalNetworkDao.listByZoneAndTrafficType(zoneId,
TrafficType.Guest);
-        if (pNtwks.isEmpty() || pNtwks.size() > 1) {
-            throw new InvalidParameterValueException("Unable to get physical network in zone
id = " + zoneId);
+
+        if (pNtwks == null || pNtwks.isEmpty()) {
+            throw new InvalidParameterValueException("Unable to get physical network: " +
physicalNetworkId +
+                    " in zone id = " + zoneId);
+        } else {
+            for (PhysicalNetwork physicalNetwork : pNtwks) {
+                if (physicalNetwork.getId() == physicalNetworkId) {
+                    PhysicalNetworkVO physNetwork = pNtwks.get(0);
+                    ExternalLoadBalancerDeviceVO nsGslbProvider = _externalLoadBalancerDeviceDao.findGslbServiceProvider(
+                            physNetwork.getId(), Provider.Netscaler.getName());
+                    return nsGslbProvider;
+                }
+            }
         }
-        PhysicalNetworkVO physNetwork = pNtwks.get(0);
-        ExternalLoadBalancerDeviceVO nsGslbProvider = _externalLoadBalancerDeviceDao.findGslbServiceProvider(
-                physNetwork.getId(), Provider.Netscaler.getName());
-        return nsGslbProvider;
+
+        return null;
     }
 
     @Override
-    public boolean isServiceEnabledInZone(long zoneId) {
+    public boolean isServiceEnabledInZone(long zoneId, long physicalNetworkId) {
 
-        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
+        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId, physicalNetworkId);
         //return true if a NetScaler device is configured in the zone
         return (nsGslbProvider != null);
     }
 
     @Override
-    public String getZoneGslbProviderPublicIp(long zoneId) {
-        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
+    public String getZoneGslbProviderPublicIp(long zoneId, long physicalNetworkId) {
+        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId, physicalNetworkId);
         if (nsGslbProvider != null) {
             return nsGslbProvider.getGslbSitePublicIP();
         }
@@ -979,8 +988,8 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
     }
 
     @Override
-    public String getZoneGslbProviderPrivateIp(long zoneId) {
-        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
+    public String getZoneGslbProviderPrivateIp(long zoneId, long physicalNetworkId) {
+        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId, physicalNetworkId);
         if (nsGslbProvider != null) {
             return nsGslbProvider.getGslbSitePrivateIP();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f441582e/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
index 56c46b0..0622f77 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
@@ -35,6 +35,7 @@ import com.cloud.region.ha.GlobalLoadBalancingRulesService;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.UserContext;
+import com.cloud.utils.Pair;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -173,6 +174,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
         List<Long> oldLbRuleIds = new ArrayList<Long>();
         List<Long> oldZones = new ArrayList<Long>();
         List<Long> newZones = new ArrayList<Long>(oldZones);
+        List<Pair<Long, Long>> physcialNetworks = new ArrayList<Pair<Long,
Long>>();
 
         // get the list of load balancer rules id's that are assigned currently to GSLB rule
and corresponding zone id's
         List<GlobalLoadBalancerLbRuleMapVO> gslbLbMapVos = _gslbLbMapDao.listByGslbRuleId(gslbRuleId);
@@ -217,12 +219,14 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
             }
 
             newZones.add(network.getDataCenterId());
+            physcialNetworks.add(new Pair<Long, Long>(network.getDataCenterId(), network.getPhysicalNetworkId()));
         }
 
-        // check each of the zone has a GSLB service provider configured
-        for (Long zoneId: newZones) {
-            if (!checkGslbServiceEnabledInZone(zoneId)) {
-                throw new InvalidParameterValueException("GSLB service is not enabled in
the Zone");
+        // for each of the physical network check if GSLB service provider configured
+        for (Pair<Long, Long> physicalNetwork: physcialNetworks) {
+            if (!checkGslbServiceEnabledInZone(physicalNetwork.first(), physicalNetwork.second()))
{
+                throw new InvalidParameterValueException("GSLB service is not enabled in
the Zone:" +
+                        physicalNetwork.first() + " and physical network " + physicalNetwork.second());
             }
         }
 
@@ -543,8 +547,8 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
         GlobalLoadBalancerConfigCommand gslbConfigCmd = new GlobalLoadBalancerConfigCommand(gslbFqdn,
                 lbMethod, persistenceMethod, serviceType, gslbRuleId, revoke);
 
-        // list of the zones participating in global load balancing
-        List<Long> gslbSiteIds = new ArrayList<Long>();
+        // list of the physical network participating in global load balancing
+        List<Pair<Long, Long>> gslbSiteIds = new ArrayList<Pair<Long, Long>>();
 
         // map of the zone and info corresponding to the load balancer configured in the
zone
         Map<Long, SiteLoadBalancerConfig> zoneSiteLoadbalancerMap = new HashMap<Long,
SiteLoadBalancerConfig>();
@@ -559,37 +563,38 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
             LoadBalancerVO loadBalancer = _lbDao.findById(gslbLbMapVo.getLoadBalancerId());
             Network network = _networkDao.findById(loadBalancer.getNetworkId());
             long dataCenterId = network.getDataCenterId();
+            long physicalNetworkId = network.getPhysicalNetworkId();
 
-            gslbSiteIds.add(dataCenterId);
+            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));
-            siteLb.setGslbProviderPrivateIp(_gslbProvider.getZoneGslbProviderPrivateIp(dataCenterId));
+            siteLb.setGslbProviderPublicIp(_gslbProvider.getZoneGslbProviderPublicIp(dataCenterId,
physicalNetworkId));
+            siteLb.setGslbProviderPrivateIp(_gslbProvider.getZoneGslbProviderPrivateIp(dataCenterId,
physicalNetworkId));
 
             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 (long zoneId: gslbSiteIds) {
+        for (Pair<Long,Long> zoneId: gslbSiteIds) {
 
             List<SiteLoadBalancerConfig> slbs = new ArrayList<SiteLoadBalancerConfig>();
 
             // set site as 'local' for the site in that zone
-            for (long innerLoopZoneId: gslbSiteIds) {
-                SiteLoadBalancerConfig siteLb = zoneSiteLoadbalancerMap.get(innerLoopZoneId);
-                siteLb.setLocal(zoneId == innerLoopZoneId);
+            for (Pair<Long,Long> innerLoopZoneId: gslbSiteIds) {
+                SiteLoadBalancerConfig siteLb = zoneSiteLoadbalancerMap.get(innerLoopZoneId.first());
+                siteLb.setLocal(zoneId.first() == innerLoopZoneId.first());
                 slbs.add(siteLb);
             }
 
             gslbConfigCmd.setSiteLoadBalancers(slbs);
 
             try {
-                _gslbProvider.applyGlobalLoadBalancerRule(zoneId, gslbConfigCmd);
+                _gslbProvider.applyGlobalLoadBalancerRule(zoneId.first(), zoneId.second(),
gslbConfigCmd);
             } catch (ResourceUnavailableException e) {
                 s_logger.warn("Failed to configure GSLB rul in the zone " + zoneId + " due
to " + e.getMessage());
                 throw new CloudRuntimeException("Failed to configure GSLB rul in the zone");
@@ -599,13 +604,13 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
         return true;
     }
 
-    private boolean checkGslbServiceEnabledInZone(long zoneId) {
+    private boolean checkGslbServiceEnabledInZone(long zoneId, long physicalNetworkId) {
 
         if (_gslbProvider == null) {
             throw new CloudRuntimeException("No GSLB provider is available");
         }
 
-        return _gslbProvider.isServiceEnabledInZone(zoneId);
+        return _gslbProvider.isServiceEnabledInZone(zoneId, physicalNetworkId);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f441582e/server/src/org/apache/cloudstack/region/gslb/GslbServiceProvider.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/gslb/GslbServiceProvider.java b/server/src/org/apache/cloudstack/region/gslb/GslbServiceProvider.java
index 4338d65..0413edf 100755
--- a/server/src/org/apache/cloudstack/region/gslb/GslbServiceProvider.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GslbServiceProvider.java
@@ -24,13 +24,13 @@ import org.apache.cloudstack.region.RegionServiceProvider;
 
 public interface GslbServiceProvider extends RegionServiceProvider {
 
-    public boolean isServiceEnabledInZone(long zoneId);
+    public boolean isServiceEnabledInZone(long zoneId, long physicalNetworkId);
 
-    public String getZoneGslbProviderPublicIp(long zoneId);
+    public String getZoneGslbProviderPublicIp(long zoneId, long physicalNetworkId);
 
-    public String getZoneGslbProviderPrivateIp(long zoneId);
+    public String getZoneGslbProviderPrivateIp(long zoneId, long physicalNetworkId);
 
-    public boolean applyGlobalLoadBalancerRule(long zoneId, GlobalLoadBalancerConfigCommand
gslbConfigCmd)
+    public boolean applyGlobalLoadBalancerRule(long zoneId, long physicalNetworkId, GlobalLoadBalancerConfigCommand
gslbConfigCmd)
             throws ResourceUnavailableException;
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f441582e/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
index 700fe8f..1c281a0 100644
--- a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
+++ b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
@@ -730,6 +730,9 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
         Field dcID = NetworkVO.class.getDeclaredField("dataCenterId");
         dcID.setAccessible(true);
         dcID.set(networkVo, new Long(1));
+        Field phyNetworkId = NetworkVO.class.getDeclaredField("physicalNetworkId");
+        phyNetworkId.setAccessible(true);
+        phyNetworkId.set(networkVo, new Long(200));
         when(gslbServiceImpl._networkDao.findById(new Long(1))).thenReturn(networkVo);
 
         GlobalLoadBalancerLbRuleMapVO gslbLbMap = new GlobalLoadBalancerLbRuleMapVO(1, 1);


Mime
View raw message