You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mu...@apache.org on 2013/07/05 10:29:57 UTC

[2/3] git commit: updated refs/heads/master-6-17-stable to 27c59d0

CLOUDSTACK-3287: [GSLB] API "updateGlobalLoadBalancerRule" is not
recognised by CloudStack

added api to managementServerImpl and ensure glsb config is applied to
gslb service providers


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

Branch: refs/heads/master-6-17-stable
Commit: b2ac8f3b8d10dc6f9625e825e50b4ad6fce3052e
Parents: eb6b18d
Author: Murali Reddy <mu...@gmail.com>
Authored: Mon Jul 1 23:35:34 2013 +0530
Committer: Murali Reddy <mu...@gmail.com>
Committed: Fri Jul 5 13:32:03 2013 +0530

----------------------------------------------------------------------
 .../ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java | 14 +++++++++++---
 .../com/cloud/server/ManagementServerImpl.java   |  2 ++
 .../GlobalLoadBalancingRulesServiceImpl.java     | 19 +++++++++++++------
 3 files changed, 26 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b2ac8f3b/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 4e2c0fd..6671886 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
@@ -28,7 +28,7 @@ import org.apache.log4j.Logger;
 
 import javax.inject.Inject;
 
-@APICommand(name = "updateGlobalLoadBalancerRule", description = "update global load balancer rules.", responseObject = LoadBalancerResponse.class)
+@APICommand(name = "updateGlobalLoadBalancerRule", description = "update global load balancer rules.", responseObject=GlobalLoadBalancerResponse.class)
 public class UpdateGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
     public static final Logger s_logger = Logger.getLogger(GlobalLoadBalancerResponse.class.getName());
 
@@ -99,7 +99,15 @@ public class UpdateGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() {
-        _gslbService.updateGlobalLoadBalancerRule(this);
+        com.cloud.user.UserContext.current().setEventDetails("Global Load balancer Id: "+getId());
+        GlobalLoadBalancerRule gslbRule = _gslbService.updateGlobalLoadBalancerRule(this);
+        if (gslbRule != null) {
+            GlobalLoadBalancerResponse response = _responseGenerator.createGlobalLoadBalancerResponse(gslbRule);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update global load balancer rule");
+        }
     }
 
     @Override
@@ -109,6 +117,6 @@ public class UpdateGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
 
     @Override
     public String getEventDescription() {
-        return null;
+        return  "updating global load balancer rule";
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b2ac8f3b/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 7023687..682332c 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -311,6 +311,7 @@ import org.apache.cloudstack.api.command.user.region.ha.gslb.AssignToGlobalLoadB
 import org.apache.cloudstack.api.command.user.region.ha.gslb.CreateGlobalLoadBalancerRuleCmd;
 import org.apache.cloudstack.api.command.user.region.ha.gslb.DeleteGlobalLoadBalancerRuleCmd;
 import org.apache.cloudstack.api.command.user.region.ha.gslb.ListGlobalLoadBalancerRuleCmd;
+import org.apache.cloudstack.api.command.user.region.ha.gslb.UpdateGlobalLoadBalancerRuleCmd;
 import org.apache.cloudstack.api.command.user.region.ha.gslb.RemoveFromGlobalLoadBalancerRuleCmd;
 import org.apache.cloudstack.api.command.user.resource.GetCloudIdentifierCmd;
 import org.apache.cloudstack.api.command.user.resource.ListHypervisorsCmd;
@@ -2909,6 +2910,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         cmdList.add(CreateGlobalLoadBalancerRuleCmd.class);
         cmdList.add(DeleteGlobalLoadBalancerRuleCmd.class);
         cmdList.add(ListGlobalLoadBalancerRuleCmd.class);
+        cmdList.add(UpdateGlobalLoadBalancerRuleCmd.class);
         cmdList.add(AssignToGlobalLoadBalancerRuleCmd.class);
         cmdList.add(RemoveFromGlobalLoadBalancerRuleCmd.class);
         cmdList.add(ListStorageProvidersCmd.class);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b2ac8f3b/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 0642390..d6e8d2d 100644
--- a/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
+++ b/server/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImpl.java
@@ -494,24 +494,31 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
         _accountMgr.checkAccess(caller, SecurityChecker.AccessType.ModifyEntry, true, gslbRule);
 
 
-        if (!GlobalLoadBalancerRule.Algorithm.isValidAlgorithm(algorithm)) {
+        if (algorithm != null && !GlobalLoadBalancerRule.Algorithm.isValidAlgorithm(algorithm)) {
             throw new InvalidParameterValueException("Invalid Algorithm: " + algorithm);
         }
 
-        if (!GlobalLoadBalancerRule.Persistence.isValidPersistence(stickyMethod)) {
+        if (stickyMethod != null && !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);
+        if (algorithm != null) {
+            gslbRule.setAlgorithm(algorithm);
+        }
+        if (stickyMethod != null) {
+            gslbRule.setPersistence(stickyMethod);
+        }
+        if (description != null) {
+            gslbRule.setDescription(description);
+        }
+        gslbRule.setState(GlobalLoadBalancerRule.State.Add);
         _gslbRuleDao.update(gslbRule.getId(), gslbRule);
         txn.commit();
 
         try {
-            s_logger.debug("Updated global load balancer with id " + gslbRule.getUuid());
+            s_logger.debug("Updating global load balancer with id " + gslbRule.getUuid());
 
             // apply the gslb rule on to the back end gslb service providers on zones participating in gslb
             applyGlobalLoadBalancerRuleConfig(gslbRuleId, false);