cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [49/50] [abbrv] git commit: refs/heads/gslb-wip - logic to get the NetScaler configured as gslb servce provider in the zone
Date Wed, 20 Mar 2013 01:41:17 GMT
logic to get the NetScaler configured as gslb servce provider in the
zone


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

Branch: refs/heads/gslb-wip
Commit: e601272679b1fb17ec7bd1f897c406fb9de66a2f
Parents: dc25e9f
Author: Murali Reddy <murali.reddy@citrix.com>
Authored: Wed Mar 20 00:43:03 2013 +0530
Committer: Murali Reddy <murali.reddy@citrix.com>
Committed: Wed Mar 20 00:43:03 2013 +0530

----------------------------------------------------------------------
 .../cloud/network/element/NetscalerElement.java    |   83 +++++++++++----
 .../gslb/GlobalLoadBalancingRulesServiceImpl.java  |    1 +
 2 files changed, 62 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e6012726/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 f896957..860665a 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
@@ -119,6 +119,8 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
     NetScalerPodDao _netscalerPodDao;
     @Inject
     DataCenterIpAddressDao _privateIpAddressDao;
+    @Inject
+    ExternalLoadBalancerDeviceDao _externalLoadBalancerDeviceDao;
 
     private boolean canHandle(Network config, Service service) {
         DataCenter zone = _dcDao.findById(config.getDataCenterId());
@@ -805,21 +807,6 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
         return null;
     }
 
-    @Override
-    public boolean isServiceEnabledInZone(long zoneId) {
-        return false;
-    }
-
-    @Override
-    public String getZoneGslbProviderPublicIp(long zoneId) {
-        return null;
-    }
-
-    @Override
-    public String getZoneGslbProviderPrivateIp(long zoneId) {
-        return null;
-    }
-
     public List<LoadBalancerTO> updateHealthChecks(Network network, List<LoadBalancingRule>
lbrules) {
 
         if (canHandle(network, Service.Lb)) {
@@ -834,21 +821,73 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
         return null;
     }
 
+    public List<LoadBalancerTO> getLBHealthChecks(Network network, List<? extends
FirewallRule> rules)
+            throws ResourceUnavailableException {
+        return super.getLBHealthChecks(network, rules);
+    }
+
     @Override
-    public boolean applyGlobalLoadBalancerRule(long zoneId, GlobalLoadBalancerConfigCommand
gslbConfigCmd) {
+    public boolean applyGlobalLoadBalancerRule(long zoneId, GlobalLoadBalancerConfigCommand
gslbConfigCmd)
+            throws ResourceUnavailableException {
 
-        // get the host Id corresponding to GSLB service provider in the zone
         long zoneGslbProviderHosId = 0;
 
+        // find the NetScaler device configured as gslb service provider in the zone
+        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
+        if (nsGslbProvider == null) {
+            String msg = "Unable to find a NetScaler configred as gslb service provider in
zone " + zoneId;
+            s_logger.error(msg);
+            throw new ResourceUnavailableException(msg, DataCenter.class, zoneId);
+        }
+
+        // get the host Id corresponding to GSLB service provider in the zone
+        zoneGslbProviderHosId =  nsGslbProvider.getHostId();
+
+        // send gslb configuration to NetScaler device
         Answer answer = _agentMgr.easySend(zoneGslbProviderHosId, gslbConfigCmd);
-        if (answer == null) {
+        if (answer == null || !answer.getResult()) {
+            String msg = "Unable to apply global load balancer rule to the gslb service provider
in zone " + zoneId;
+            s_logger.error(msg);
+            throw new ResourceUnavailableException(msg, DataCenter.class, zoneId);
+        }
 
+        return true;
+    }
+
+    private ExternalLoadBalancerDeviceVO findGslbProvider(long zoneId) {
+        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);
         }
-        return false;
+        PhysicalNetworkVO physNetwork = pNtwks.get(0);
+        ExternalLoadBalancerDeviceVO nsGslbProvider = _externalLoadBalancerDeviceDao.findGslbServiceProvider(
+                physNetwork.getId(), Provider.Netscaler.getName());
+        return nsGslbProvider;
     }
 
-    public List<LoadBalancerTO> getLBHealthChecks(Network network, List<? extends
FirewallRule> rules)
-            throws ResourceUnavailableException {
-        return super.getLBHealthChecks(network, rules);
+    @Override
+    public boolean isServiceEnabledInZone(long zoneId) {
+
+        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
+        //return true if a NetScaler device is configured in the zone
+        return (nsGslbProvider == null);
+    }
+
+    @Override
+    public String getZoneGslbProviderPublicIp(long zoneId) {
+        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
+        if (nsGslbProvider != null) {
+            nsGslbProvider.getGslbSitePublicIP();
+        }
+        return null;
+    }
+
+    @Override
+    public String getZoneGslbProviderPrivateIp(long zoneId) {
+        ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
+        if (nsGslbProvider != null) {
+            nsGslbProvider.getGslbSitePrivateIP();
+        }
+        return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e6012726/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 8042b64..c70fa67 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
@@ -540,6 +540,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
             }
 
             gslbConfigCmd.setSiteLoadBalancers(slbs);
+
             try {
                 _gslbProvider.applyGlobalLoadBalancerRule(zoneId, gslbConfigCmd);
             } catch (ResourceUnavailableException e) {


Mime
View raw message