You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ya...@apache.org on 2014/02/22 04:14:39 UTC

[2/2] git commit: updated refs/heads/master to c0ed0b7

CLOUDSTACK-6047: Make VR LB script accept a file name

Rather than default filename everytime since in aggregated commands the file
would be overrided if the filename is same.


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

Branch: refs/heads/master
Commit: c0ed0b78198eef7bdf81637df3c2e2b23281adde
Parents: e5304d5
Author: Sheng Yang <sh...@citrix.com>
Authored: Fri Feb 21 16:46:08 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Fri Feb 21 18:26:42 2014 -0800

----------------------------------------------------------------------
 .../virtualnetwork/VirtualRoutingResource.java         |  4 ++--
 .../virtualnetwork/VirtualRoutingResourceTest.java     | 11 ++++++++---
 systemvm/patches/debian/config/opt/cloud/bin/ilb.sh    | 12 ++++++++----
 .../debian/config/opt/cloud/bin/loadbalancer.sh        |  7 +++----
 .../debian/config/opt/cloud/bin/vpc_loadbalancer.sh    | 13 +++++++++----
 systemvm/patches/debian/config/root/reconfigLB.sh      |  7 +++++--
 6 files changed, 35 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0ed0b78/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index ef0d739..9bebd4c 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -480,7 +480,7 @@ public class VirtualRoutingResource {
         }
 
         String tmpCfgFilePath = "/etc/haproxy/";
-        String tmpCfgFileName = "haproxy.cfg.new";
+        String tmpCfgFileName = "haproxy.cfg.new." + String.valueOf(System.currentTimeMillis());
         cfg.add(new ConfigItem(tmpCfgFilePath, tmpCfgFileName, tmpCfgFileContents));
 
         String[][] rules = cfgtr.generateFwRules(cmd);
@@ -489,7 +489,7 @@ public class VirtualRoutingResource {
         String[] removeRules = rules[LoadBalancerConfigurator.REMOVE];
         String[] statRules = rules[LoadBalancerConfigurator.STATS];
 
-        String args = "";
+        String args = " -f " + tmpCfgFilePath + tmpCfgFileName;
         StringBuilder sb = new StringBuilder();
         if (addRules.length > 0) {
             for (int i = 0; i < addRules.length; i++) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0ed0b78/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
----------------------------------------------------------------------
diff --git a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
index 509eb8b..c980c9d 100644
--- a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
+++ b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
@@ -80,6 +80,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
     VirtualRoutingResource _resource;
     NetworkElementCommand _currentCmd;
     int _count;
+    String _file;
 
     String ROUTERIP = "10.2.3.4";
 
@@ -703,6 +704,7 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
     @Test
     public void testLoadBalancerConfigCommand() {
         _count = 0;
+        _file = "";
 
         List<LoadBalancerTO> lbs = new ArrayList<>();
         List<LbDestination> dests = new ArrayList<>();
@@ -713,9 +715,11 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         lbs.toArray(arrayLbs);
         NicTO nic = new NicTO();
         LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, null, "1000", false);
+        cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, "10.1.10.2");
         Answer answer = _resource.executeRequest(cmd);
         assertTrue(answer.getResult());
 
+        nic.setIp("10.1.10.2");
         cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, Long.valueOf(1), "1000", false);
         answer = _resource.executeRequest(cmd);
         assertTrue(answer.getResult());
@@ -729,8 +733,9 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         switch (_count) {
             case 1:
             case 3:
+                _file = path + filename;
                 assertEquals(path, "/etc/haproxy/");
-                assertEquals(filename, "haproxy.cfg.new");
+                assertTrue(filename.startsWith("haproxy.cfg.new"));
                 assertEquals(content, "global\n" +
                         "\tlog 127.0.0.1:3914   local0 warning\n" +
                         "\tmaxconn 1000\n" +
@@ -779,11 +784,11 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         switch (_count) {
             case 2:
                 assertEquals(script, VRScripts.LB);
-                assertEquals(args, " -i null -a 64.10.1.10:80:, -s 10.1.10.2:8081:0/0:,,");
+                assertEquals(args, " -i 10.1.10.2 -f " + _file + " -a 64.10.1.10:80:, -s 10.1.10.2:8081:0/0:,,");
                 break;
             case 4:
                 assertEquals(script, VRScripts.VPC_LB);
-                assertEquals(args, " -i null -a 64.10.1.10:80:, -s 10.1.10.2:8081:0/0:,,");
+                assertEquals(args, " -i 10.1.10.2 -f " + _file + " -a 64.10.1.10:80:, -s 10.1.10.2:8081:0/0:,,");
                 break;
             default:
                 fail();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0ed0b78/systemvm/patches/debian/config/opt/cloud/bin/ilb.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/ilb.sh b/systemvm/patches/debian/config/opt/cloud/bin/ilb.sh
index 2a29892..86c261e 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/ilb.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/ilb.sh
@@ -113,7 +113,8 @@ fw_entry() {
 
 #Hot reconfigure HA Proxy in the routing domain
 reconfig_lb() {
-  /root/reconfigLB.sh
+  logger -t cloud "Reconfiguring ilb using $1"
+  /root/reconfigLB.sh $1
   return $?
 }
 
@@ -126,7 +127,7 @@ restore_lb() {
   if [ $? -eq 0 ]
   then
     # Run reconfigLB.sh again
-    /root/reconfigLB.sh
+    /root/reconfigLB.sh /etc/haproxy/haproxy.cfg.new
   fi
 }
 
@@ -136,9 +137,10 @@ logger -t cloud "$(basename $0): Entering $(dirname $0)/$(basename $0)"
 iflag=
 aflag=
 dflag=
+fflag=
 sflag=
 
-while getopts 'i:a:d:s:' OPTION
+while getopts 'i:a:d:f:s:' OPTION
 do
   case $OPTION in
   i)	iflag=1
@@ -150,7 +152,9 @@ do
   d)	dflag=1
 		removedIps="$OPTARG"
 		;;
-
+  f)	fflag=1
+		cfgfile="$OPTARG"
+		;;
   s)	sflag=1
 		statsIp="$OPTARG"
 		;;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0ed0b78/systemvm/patches/debian/config/opt/cloud/bin/loadbalancer.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/loadbalancer.sh b/systemvm/patches/debian/config/opt/cloud/bin/loadbalancer.sh
index 2c7f77a..e22bf94 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/loadbalancer.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/loadbalancer.sh
@@ -177,7 +177,8 @@ fw_entry() {
 
 #Hot reconfigure HA Proxy in the routing domain
 reconfig_lb() {
-  /root/reconfigLB.sh
+  logger -t cloud "Reconfiguring loadbalancer using $1"
+  /root/reconfigLB.sh $1
   return $?
 }
 
@@ -190,7 +191,7 @@ restore_lb() {
   if [ $? -eq 0 ]
   then
     # Run reconfigLB.sh again
-    /root/reconfigLB.sh
+    /root/reconfigLB.sh /etc/haproxy/haproxy.cfg.new
   fi
 }
 
@@ -234,7 +235,6 @@ do
   f)	fflag=1
 		cfgfile="$OPTARG"
 		;;
-
   s)	sflag=1
 		statsIp="$OPTARG"
 		;;
@@ -297,7 +297,6 @@ then
   # Restore the LB
   restore_lb
 
-
   logger -t cloud "Reverting firewall config"
   # Revert iptables rules on DomR
   fw_restore

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0ed0b78/systemvm/patches/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/vpc_loadbalancer.sh b/systemvm/patches/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
index 36a2347..b9b377c 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
@@ -146,7 +146,8 @@ fw_entry() {
 
 #Hot reconfigure HA Proxy in the routing domain
 reconfig_lb() {
-  /root/reconfigLB.sh
+  logger -t cloud "Reconfiguring loadbalancer using $1"
+  /root/reconfigLB.sh $1
   return $?
 }
 
@@ -159,16 +160,17 @@ restore_lb() {
   if [ $? -eq 0 ]
   then
     # Run reconfigLB.sh again
-    /root/reconfigLB.sh
+    /root/reconfigLB.sh /etc/haproxy/haproxy.cfg.new
   fi
 }
 
 iflag=
 aflag=
 dflag=
+fflag=
 sflag=
 
-while getopts 'i:a:d:s:' OPTION
+while getopts 'i:a:d:f:s:' OPTION
 do
   case $OPTION in
   i)	iflag=1
@@ -183,6 +185,9 @@ do
   s)	sflag=1
 		statsIp="$OPTARG"
 		;;
+  f)	fflag=1
+		cfgfile="$OPTARG"
+		;;
   ?)	usage
                 unlock_exit 2 $lock $locked
 		;;
@@ -203,7 +208,7 @@ then
 fi
 
 # hot reconfigure haproxy
-reconfig_lb
+reconfig_lb $cfgfile
 
 if [ $? -gt 0 ]
 then

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0ed0b78/systemvm/patches/debian/config/root/reconfigLB.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/root/reconfigLB.sh b/systemvm/patches/debian/config/root/reconfigLB.sh
index ab91a39..70a2912 100755
--- a/systemvm/patches/debian/config/root/reconfigLB.sh
+++ b/systemvm/patches/debian/config/root/reconfigLB.sh
@@ -18,11 +18,14 @@
 
 
 ret=0
+
+new_config=$1
+
 # save previous state
   mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.old
   mv /var/run/haproxy.pid /var/run/haproxy.pid.old
 
-  mv /etc/haproxy/haproxy.cfg.new /etc/haproxy/haproxy.cfg
+  mv $new_config /etc/haproxy/haproxy.cfg
   kill -TTOU $(cat /var/run/haproxy.pid.old)
   sleep 2
   if haproxy -D -p /var/run/haproxy.pid -f /etc/haproxy/haproxy.cfg; then
@@ -35,7 +38,7 @@ ret=0
     kill -TTIN $(cat /var/run/haproxy.pid.old)
     rm -f /var/run/haproxy.pid
     mv /var/run/haproxy.pid.old /var/run/haproxy.pid
-    mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.new
+    mv /etc/haproxy/haproxy.cfg $new_config
     mv /etc/haproxy/haproxy.cfg.old /etc/haproxy/haproxy.cfg
     ret=1
   fi