cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [1/2] git commit: refs/heads/gslb-wip - implements changes to 'SiteLoadBalancerConfig' details and implementation of UpdateGlobalLoadBalancerRule command in service layer
Date Tue, 05 Mar 2013 09:19:05 GMT
implements changes to 'SiteLoadBalancerConfig' details and
implementation of UpdateGlobalLoadBalancerRule command in service layer


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

Branch: refs/heads/gslb-wip
Commit: 54bff978feff2af796a49df2cafa35e984fe4731
Parents: 70e2eea
Author: Murali Reddy <murali.reddy@citrix.com>
Authored: Sun Mar 3 22:55:49 2013 +0530
Committer: Murali Reddy <murali.reddy@citrix.com>
Committed: Sun Mar 3 22:55:49 2013 +0530

----------------------------------------------------------------------
 .../agent/api/routing/SiteLoadBalancerConfig.java  |   25 +++----
 .../ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java |    2 +-
 .../ha/gslb/CreateGlobalLoadBalancerRuleCmd.java   |    2 +-
 .../ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java   |   32 +++++++-
 .../cloud/network/resource/NetscalerResource.java  |    6 +-
 .../gslb/GlobalLoadBalancingRulesServiceImpl.java  |   56 +++++++++++++-
 6 files changed, 97 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/54bff978/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java b/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java
index a1ee8f6..0b998f0 100644
--- a/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java
+++ b/api/src/com/cloud/agent/api/routing/SiteLoadBalancerConfig.java
@@ -17,9 +17,11 @@
 
 package com.cloud.agent.api.routing;
 
-// details of site participating in the GLSB service
+// details of site participating in the GLSB service, represents configuration load balancer
rule and the zone
+// in which the rule is configured
 public class SiteLoadBalancerConfig {
-// true if the site is local (GSLB provider receiving GlobalLoadBalancerConfigCommand is
in same site)
+
+    // true if the site details are local to the zone receiving 'GlobalLoadBalancerConfigCommand'
     boolean local;
 
     // true if the site needs to be removed from GSLB service
@@ -34,8 +36,8 @@ public class SiteLoadBalancerConfig {
     // port corresponding to the site load balanced service
     String port;
 
-    // IP corresponding to the GSLB service provider in the site.
-    String gslbProviderIp;
+    // Private IP corresponding to the GSLB service provider in the site.
+    String gslbProviderPrivateIp;
 
     // Public IP corresponding to the GSLB service provider in the site.
     String gslbProviderPublicIp;
@@ -47,15 +49,12 @@ public class SiteLoadBalancerConfig {
         this.port = port;
     }
 
-    public SiteLoadBalancerConfig(String gslbProviderIp, String gslbProviderPublicIP, boolean
local, boolean revoked,
-                                 String serviceType, String servicePublicIp, String port)
{
-        this.gslbProviderIp = gslbProviderIp;
+    public SiteLoadBalancerConfig(String gslbProviderPublicIP, String gslbProviderPrivateIp,
boolean local,
+                                  boolean revoked, String serviceType, String servicePublicIp,
String port) {
+        this(revoked, serviceType, servicePublicIp, port);
+        this.gslbProviderPrivateIp = gslbProviderPrivateIp;
         this.gslbProviderPublicIp = gslbProviderPublicIP;
         this.local = local;
-        this.revoked = revoked;
-        this.serviceType = serviceType;
-        this.servicePublicIp = servicePublicIp;
-        this.port = port;
     }
 
     public String getServiceType() {
@@ -83,11 +82,11 @@ public class SiteLoadBalancerConfig {
     }
 
     public String getGslbProviderPrivateIp() {
-        return gslbProviderIp;
+        return gslbProviderPrivateIp;
     }
 
     public void setGslbProviderPrivateIp(String privateIp) {
-        this.gslbProviderIp = privateIp;
+        this.gslbProviderPrivateIp = privateIp;
     }
 
     public String getGslbProviderPublicIp() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/54bff978/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java
b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java
index b93f849..15bbac9 100644
--- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java
@@ -47,7 +47,7 @@ public class AssignToGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
     /////////////////////////////////////////////////////
 
     @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = GlobalLoadBalancerResponse.class,
-            required=true, description="the ID of the load balancer rule")
+            required=true, description="the ID of the global load balancer rule")
     private Long id;
 
     @Parameter(name=ApiConstants.LOAD_BALANCER_RULE_LIST, type=CommandType.LIST, collectionType=CommandType.UUID,

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/54bff978/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
index d0f8935..cd559d8 100644
--- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java
@@ -60,7 +60,7 @@ public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd
{
     private Long domainId;
 
     @Parameter(name=ApiConstants.GSLB_LB_METHOD, type=CommandType.STRING, required=false,
description="load balancer algorithm (roundrobin, leastconn, proximity) " +
-            "that is used to distributed traffic across the zones participating in global
server load balancing, if not specified defaults to 'round robin'")
+            "that method is used to distribute traffic across the zones participating in
global server load balancing, if not specified defaults to 'round robin'")
     private String algorithm;
 
     @Parameter(name=ApiConstants.GSLB_STICKY_SESSION_METHOD, type=CommandType.STRING, required=false,
description="session sticky method (sourceip) if not specified defaults to sourceip")

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/54bff978/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java
b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java
index a5368f3..10694e1 100644
--- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java
@@ -22,7 +22,6 @@ import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
 import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.response.FirewallRuleResponse;
 import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
 import org.apache.cloudstack.api.response.LoadBalancerResponse;
 import org.apache.log4j.Logger;
@@ -33,16 +32,25 @@ import javax.inject.Inject;
 public class UpdateGlobalLoadBalancerRuleCmd extends BaseListTaggedResourcesCmd {
     public static final Logger s_logger = Logger.getLogger(GlobalLoadBalancerResponse.class.getName());
 
-    private static final String s_name = "updategloballoadbalancerrulesresponse";
+    private static final String s_name = "updategloballoadbalancerruleresponse";
 
     // ///////////////////////////////////////////////////
     // ////////////// API parameters /////////////////////
     // ///////////////////////////////////////////////////
 
-    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class,
-            description = "the ID of the load balancer rule")
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = GlobalLoadBalancerResponse.class,
+            required=true, description="the ID of the global load balancer rule")
     private Long id;
 
+    @Parameter(name=ApiConstants.DESCRIPTION, type=CommandType.STRING, description="the description
of the load balancer rule", length=4096)
+    private String description;
+
+    @Parameter(name=ApiConstants.GSLB_LB_METHOD, type=CommandType.STRING, required=false,
description="load balancer algorithm (roundrobin, leastconn, proximity) " +
+            "that is used to distributed traffic across the zones participating in global
server load balancing, if not specified defaults to 'round robin'")
+    private String algorithm;
+
+    @Parameter(name=ApiConstants.GSLB_STICKY_SESSION_METHOD, type=CommandType.STRING, required=false,
description="session sticky method (sourceip) if not specified defaults to sourceip")
+    private String stickyMethod;
 
     // ///////////////////////////////////////////////////
     // ///////////////// Accessors ///////////////////////
@@ -52,6 +60,22 @@ public class UpdateGlobalLoadBalancerRuleCmd extends BaseListTaggedResourcesCmd
         return id;
     }
 
+    public String getDescription() {
+        return description;
+    }
+
+    public String getAlgorithm() {
+        return algorithm;
+    }
+
+    public String getGslbMethod() {
+        return algorithm;
+    }
+
+    public String getStickyMethod() {
+        return stickyMethod;
+    }
+
     // ///////////////////////////////////////////////////
     // ///////////// API Implementation///////////////////
     // ///////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/54bff978/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
index 3a88738..da6464d 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
@@ -755,7 +755,7 @@ public class NetscalerResource implements ServerResource {
         String persistenceType = gslbCmd.getPersistenceType();
         String serviceType = gslbCmd.getServiceType();
         boolean forRevoke = gslbCmd.isForRevoke();
-        GlobalLoadBalancerConfigCommand.SiteLoadBalancer[] sites = gslbCmd.getSiteDetails();
+        List<SiteLoadBalancerConfig> sites = gslbCmd.getSiteDetails();
 
         String domainName = gslbCmd.getDomainName();
         String vserverName = GSLB.generateVirtualServerName(domainName);
@@ -768,7 +768,7 @@ public class NetscalerResource implements ServerResource {
                 GSLB.createVirtualServer(_netscalerService, vserverName, lbMethod, persistenceType,
serviceType);
 
                 if (sites != null) { // check if there are any sites that are participating
in global load balancing
-                    for (GlobalLoadBalancerConfigCommand.SiteLoadBalancer site : sites) {
+                    for (SiteLoadBalancerConfig site : sites) {
 
                         String sitePrivateIP = site.getGslbProviderPrivateIp();
                         String sitePublicIP =  site.getGslbProviderPublicIp();
@@ -822,7 +822,7 @@ public class NetscalerResource implements ServerResource {
                 GSLB.createVserverDomainBinding(_netscalerService, vserverName, domainName);
 
                 if (sites != null) {
-                    for (GlobalLoadBalancerConfigCommand.SiteLoadBalancer site : sites) {
+                    for (SiteLoadBalancerConfig site : sites) {
 
                         String sitePrivateIP = site.getGslbProviderPrivateIp();
                         String sitePublicIP =  site.getGslbProviderPublicIp();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/54bff978/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 104de5d..b55ccd7 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
@@ -311,7 +311,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
         Transaction txn = Transaction.currentTxn();
         txn.start();
 
-        // update the mapping of  gslb rule to Lb rule, to revoke state
+        // 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);
@@ -354,7 +354,41 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
 
     @Override
     public GlobalLoadBalancerRule updateGlobalLoadBalancerRule(UpdateGlobalLoadBalancerRuleCmd
updateGslbCmd) {
-        return null;
+
+        String algorithm = updateGslbCmd.getAlgorithm();
+        String stickyMethod = updateGslbCmd.getStickyMethod();
+        String description = updateGslbCmd.getDescription();
+
+        long gslbRuleId =  updateGslbCmd.getId();
+        GlobalLoadBalancerRuleVO gslbRule = _gslbRuleDao.findById(gslbRuleId);
+        if (gslbRule == null) {
+            throw new InvalidParameterValueException("Invalid global load balancer rule id:
" + gslbRuleId);
+        }
+
+        UserContext ctx = UserContext.current();
+        Account caller = ctx.getCaller();
+
+        _accountMgr.checkAccess(caller, SecurityChecker.AccessType.ModifyEntry, true, gslbRule);
+
+
+        if (!GlobalLoadBalancerRule.Algorithm.isValidAlgorithm(algorithm)) {
+            throw new InvalidParameterValueException("Invalid Algorithm: " + algorithm);
+        }
+
+        if (!GlobalLoadBalancerRule.Persistence.isValidPersistence(stickyMethod)) {
+            throw new InvalidParameterValueException("Invalid persistence: " + stickyMethod);
+        }
+
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        gslbRule.setAlgorithm(algorithm);
+        gslbRule.setPersistence(stickyMethod);
+        gslbRule.setDescription(description);
+        _gslbRuleDao.update(gslbRule.getId(), gslbRule);
+        txn.commit();
+
+        s_logger.debug("Updated global load balancer with id " + gslbRule.getUuid());
+        return gslbRule;
     }
 
     @Override
@@ -382,19 +416,31 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
         Map<Long, SiteLoadBalancerConfig> zoneSiteLoadbalancerMap = new HashMap<Long,
SiteLoadBalancerConfig>();
 
         List<GlobalLoadBalancerLbRuleMapVO> gslbLbMapVos = _gslbLbMapDao.listByGslbRuleId(gslbRuleId);
+
+        if (gslbLbMapVos == null || gslbLbMapVos.isEmpty()) {
+            return;
+        }
+
         for (GlobalLoadBalancerLbRuleMapVO gslbLbMapVo : gslbLbMapVos) {
+            // get the zone in which load balancer rule is deployed
             LoadBalancerVO loadBalancer = _lbDao.findById(gslbLbMapVo.getLoadBalancerId());
             Network network = _networkDao.findById(loadBalancer.getNetworkId());
+            long dataCenterId = network.getDataCenterId();
 
-            gslbSiteIds.add(network.getDataCenterId());
+            gslbSiteIds.add(dataCenterId);
 
             IPAddressVO ip = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId());
             SiteLoadBalancerConfig siteLb = new SiteLoadBalancerConfig(gslbLbMapVo.isRevoke(),
serviceType,
                     ip.getAddress().addr(), Integer.toString(loadBalancer.getDefaultPortStart()));
 
+            siteLb.setGslbProviderPublicIp(null);
+            siteLb.setGslbProviderPrivateIp(null);
+
             zoneSiteLoadbalancerMap.put(network.getDataCenterId(), siteLb);
         }
 
+        // loop through all the zones, participating in GSLB, and send GSLB config command
+        // to the GSLB service provider in the zone
         for (long zoneId: gslbSiteIds) {
 
             List<SiteLoadBalancerConfig> slbs = new ArrayList<SiteLoadBalancerConfig>();
@@ -405,9 +451,11 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
                 slbs.add(siteLb);
             }
 
+            gslbConfigCmd.setSiteLoadBalancers(slbs);
+
+            // get the host Id corresponding to GSLB service provider in the zone
             long zoneGslbProviderHosId = 0;
 
-            gslbConfigCmd.setSiteLoadBalancers(slbs);
             Answer answer = _agentMgr.easySend(zoneGslbProviderHosId, gslbConfigCmd);
             if (answer == null) {
 


Mime
View raw message