You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by re...@apache.org on 2015/10/20 08:01:06 UTC

[01/13] git commit: updated refs/heads/master to 6fe5ae0

Repository: cloudstack
Updated Branches:
  refs/heads/master 0827e1f85 -> 6fe5ae0d6


CLOUDSTACK-8952 - Do not replace the conntrackd config file unless it's needed

   - With the new logic, the file will be replaced when the router starts, becasue the default
     conntrackd config file will be different.


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

Branch: refs/heads/master
Commit: 5a216056b5a325b8abbe6f7c20f98caf202a27bc
Parents: 08b983f
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Wed Oct 14 14:13:24 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 12:20:39 2015 +0200

----------------------------------------------------------------------
 .../config/opt/cloud/bin/cs/CsRedundant.py      | 21 ++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a216056/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index cdc66d8..5361c33 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -102,10 +102,6 @@ class CsRedundant(object):
             "%s/%s" % (self.CS_TEMPLATES_DIR, "keepalived.conf.templ"), self.KEEPALIVED_CONF)
         CsHelper.copy_if_needed(
             "%s/%s" % (self.CS_TEMPLATES_DIR, "checkrouter.sh.templ"), "/opt/cloud/bin/checkrouter.sh")
-        #The file is always copied so the RVR doesn't't get the wrong config.
-        #Concerning the r-VPC, the configuration will be applied in a different manner
-        CsHelper.copy(
-            "%s/%s" % (self.CS_TEMPLATES_DIR, "conntrackd.conf.templ"), self.CONNTRACKD_CONF)
 
         CsHelper.execute(
             'sed -i "s/--exec\ \$DAEMON;/--exec\ \$DAEMON\ --\ --vrrp;/g" /etc/init.d/keepalived')
@@ -130,7 +126,12 @@ class CsRedundant(object):
         keepalived_conf.commit()
 
         # conntrackd configuration
-        connt = CsFile(self.CONNTRACKD_CONF)
+        conntrackd_template_conf = "%s/%s" % (self.CS_TEMPLATES_DIR, "conntrackd.conf.templ")
+        conntrackd_temp_bkp = "%s/%s" % (self.CS_TEMPLATES_DIR, "conntrackd.conf.templ.bkp")
+        
+        CsHelper.copy(conntrackd_template_conf, conntrackd_temp_bkp)
+        
+        connt = CsFile(conntrackd_template_conf)
         if guest is not None:
             connt.section("Multicast {", "}", [
                           "IPv4_address 225.0.0.50\n",
@@ -143,9 +144,17 @@ class CsRedundant(object):
             connt.section("Address Ignore {", "}", self._collect_ignore_ips())
             connt.commit()
 
-        if connt.is_changed():
+        conntrackd_conf = CsFile(self.CONNTRACKD_CONF)
+
+        if not connt.compare(conntrackd_conf):
+            CsHelper.copy(conntrackd_template_conf, self.CONNTRACKD_CONF)
+            proc = CsProcess(['/etc/conntrackd/conntrackd.conf'])
             CsHelper.service("conntrackd", "restart")
 
+        # Restore the template file and remove the backup.
+        CsHelper.copy(conntrackd_temp_bkp, conntrackd_template_conf)
+        CsHelper.execute("rm -rf %s" % conntrackd_temp_bkp)
+
         # Configure heartbeat cron job - runs every 30 seconds
         heartbeat_cron = CsFile("/etc/cron.d/heartbeat")
         heartbeat_cron.add("SHELL=/bin/bash", 0)


[13/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
Merge pull request #940 from ekholabs/fix/rvr__keepalived_restart

CLOUDSTACK-8952 - The redundant routers are facing a race condition due to several KeepaliveD/ConntrackD restartsThis PR fixes the following issues:

* KeepAliveD being restarted for each action performed on the routers
* ConntrackD configuration being copied for each action performed on the routers, causing several restarts
* ACS Management Server relying in the JSON file to report which router is Master/Backup
* Public Interface on both routers are in UP state due to several places checking if the interface is UP/DOWN and trying to do KeepAliveD
* Removing all the sleeps from the test_vpc_redundant.py - those are no longer needed
* When KeepAliveD calls master.py during the election, update the cmdline.json to set the router in Backup mode: the election will take care of changing it afterwards.
* Add LB stats_rules to iptables INPUT chain
* The RVR public interface is set to eth2 instead of eth1 - as in the rVPC. Make sure the check works in both cases

Those fixes make all the routers very stable, with ACL, FW, PF and LB working just fine!

* pr/940:
  CLOUDSTACK-8952 - Make the checkrouter.sh compatible with RVR as well
  CLOUDSTACK-8952 - Make the tests rely on the interface state other than the json file
  CLOUDSTACK-8952 - Reduce retried from 20 to 5
  CLOUDSTACK-8952 - Do not rely in the router state on the json file to report back to ACS
  CLOUDSTACK-8952 - Make the check for master more reliable
  CLOUDSTACK-8952 - Restart dnsmasq everytime the configure.py runs
  CLOUDSTACK-8952 - Make sure the calls to CsFile use the new logic of commit/is_changed methods
  CLOUDSTACK-8952 - Make sure we restart dnsmasq if the configuration file changes
  CLOUDSTACK-8952 - The public interface was comming UP in the Backup router
  CLOUDSTACK-8952 - Do not restart conntrackd unless it's needed
  CLOUDSTACK-8952 - Do not replace the conntrackd config file unless it's needed
  CLOUDSTACK-8952 - Remove the '--vrrp' search criteria form the CsProcess constructor call

Signed-off-by: Remi Bergsma <gi...@remi.nl>


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

Branch: refs/heads/master
Commit: 6fe5ae0d609592c790848aa4249803904deb49cf
Parents: 0827e1f fb33cb2
Author: Remi Bergsma <gi...@remi.nl>
Authored: Tue Oct 20 08:00:03 2015 +0200
Committer: Remi Bergsma <gi...@remi.nl>
Committed: Tue Oct 20 08:00:04 2015 +0200

----------------------------------------------------------------------
 .../debian/config/opt/cloud/bin/checkrouter.sh  | 19 ++++--
 .../debian/config/opt/cloud/bin/configure.py    |  4 +-
 .../debian/config/opt/cloud/bin/cs/CsAddress.py | 23 +------
 .../debian/config/opt/cloud/bin/cs/CsApp.py     |  2 +-
 .../debian/config/opt/cloud/bin/cs/CsDhcp.py    | 14 ++--
 .../debian/config/opt/cloud/bin/cs/CsFile.py    |  7 +-
 .../config/opt/cloud/bin/cs/CsLoadBalancer.py   | 20 ++++--
 .../config/opt/cloud/bin/cs/CsRedundant.py      | 42 +++++++-----
 .../debian/config/opt/cloud/bin/master.py       |  3 +
 .../opt/cloud/templates/checkrouter.sh.templ    | 19 ++++--
 .../integration/component/test_vpc_redundant.py | 69 ++++++++++++++++----
 11 files changed, 147 insertions(+), 75 deletions(-)
----------------------------------------------------------------------



[03/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - Make sure the calls to CsFile use the new logic of commit/is_changed methods

   - We now have to check if the file changed before commiting. Doesn't make sense to write on disk if there was nono change.


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

Branch: refs/heads/master
Commit: 2b286ecd730763a472fff2071a8fd7166692e11f
Parents: 1886c4a
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Thu Oct 15 16:43:29 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 12:20:40 2015 +0200

----------------------------------------------------------------------
 .../debian/config/opt/cloud/bin/configure.py        |  4 ++--
 .../debian/config/opt/cloud/bin/cs/CsAddress.py     | 16 ----------------
 .../patches/debian/config/opt/cloud/bin/cs/CsApp.py |  2 +-
 .../debian/config/opt/cloud/bin/cs/CsRedundant.py   |  3 +--
 4 files changed, 4 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b286ecd/systemvm/patches/debian/config/opt/cloud/bin/configure.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/configure.py b/systemvm/patches/debian/config/opt/cloud/bin/configure.py
index 014e294..8c39f75 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/configure.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/configure.py
@@ -481,11 +481,11 @@ class CsSite2SiteVpn(CsDataBag):
             file.addeq("  dpddelay=30")
             file.addeq("  dpdtimeout=120")
             file.addeq("  dpdaction=restart")
-        file.commit()
         secret = CsFile(vpnsecretsfile)
         secret.search("%s " % leftpeer, "%s %s: PSK \"%s\"" % (leftpeer, rightpeer, obj['ipsec_psk']))
-        secret.commit()
         if secret.is_changed() or file.is_changed():
+            secret.commit()
+            file.commit()
             logging.info("Configured vpn %s %s", leftpeer, rightpeer)
             CsHelper.execute("ipsec auto --rereadall")
             CsHelper.execute("ipsec --add vpn-%s" % rightpeer)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b286ecd/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
index 0b00397..b80187a 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
@@ -95,22 +95,6 @@ class CsAddress(CsDataBag):
                 return ip
         return None
 
-    def check_if_link_exists(self,dev):
-        cmd="ip link show dev %s"%dev
-        result = CsHelper.execute(cmd)
-        if(len(result) != 0):
-           return True
-        else:
-           return False
-
-    def check_if_link_up(self,dev):
-        cmd="ip link show dev %s | tr '\n' ' ' | cut -d ' ' -f 9"%dev
-        result = CsHelper.execute(cmd)
-        if(result and result[0].lower() == "up"):
-            return True
-        else:
-            return False
-
     def process(self):
         for dev in self.dbag:
             if dev == "id":

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b286ecd/systemvm/patches/debian/config/opt/cloud/bin/cs/CsApp.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsApp.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsApp.py
index de53fe0..a0b4c6e 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsApp.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsApp.py
@@ -50,8 +50,8 @@ class CsApache(CsApp):
         file.search("Listen .*:80", "Listen %s:80" % (self.ip))
         file.search("Listen .*:443", "Listen %s:443" % (self.ip))
         file.search("ServerName.*", "\tServerName vhost%s.cloudinternal.com" % (self.dev))
-        file.commit()
         if file.is_changed():
+            file.commit()
             CsHelper.service("apache2", "restart")
 
         self.fw.append(["", "front",

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b286ecd/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index 9e1f073..29f755c 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -125,7 +125,6 @@ class CsRedundant(object):
                                 "        auth_type AH \n", "        auth_pass %s\n" % self.cl.get_router_password()])
         keepalived_conf.section(
             "virtual_ipaddress {", "}", self._collect_ips())
-        keepalived_conf.commit()
 
         # conntrackd configuration
         conntrackd_template_conf = "%s/%s" % (self.CS_TEMPLATES_DIR, "conntrackd.conf.templ")
@@ -187,6 +186,7 @@ class CsRedundant(object):
 
         proc = CsProcess(['/usr/sbin/keepalived'])
         if not proc.find() or keepalived_conf.is_changed():
+            keepalived_conf.commit()
             CsHelper.service("keepalived", "restart")
 
     def release_lock(self):
@@ -297,7 +297,6 @@ class CsRedundant(object):
                     route.add_defaultroute(gateway)
                 except:
                     logging.error("ERROR getting gateway from device %s" % dev)
-                    
             else:
                 logging.error("Device %s was not ready could not bring it up" % dev)
 


[12/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - Make the checkrouter.sh compatible with RVR as well


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

Branch: refs/heads/master
Commit: fb33cb28aba7bfc829651e8881a9a6afa6a70a76
Parents: 38d0357
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Sat Oct 17 14:48:08 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 15:52:28 2015 +0200

----------------------------------------------------------------------
 .../debian/config/opt/cloud/bin/checkrouter.sh        | 14 ++++++++++++--
 .../config/opt/cloud/templates/checkrouter.sh.templ   | 14 ++++++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fb33cb28/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
index 9579b11..f05b440 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
@@ -16,10 +16,20 @@
 # specific language governing permissions and limitations
 # under the License.
 
-STATUS=BACKUP
-ETH1_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}')
+STATUS=UNKNOWN
+INTERFACE=eth1
+ROUTER_TYPE=$(cat /etc/cloudstack/cmdline.json | grep type | awk '{print $2;}' | sed -e 's/[,\"]//g')
+if [ $ROUTER_TYPE = "router" ]
+then
+    INTERFACE=eth2
+fi
+
+ETH1_STATE=$(ip addr | grep $INTERFACE | grep state | awk '{print $9;}')
 if [ $ETH1_STATE = "UP" ]
 then
     STATUS=MASTER
+elif [ $ETH1_STATE = "DOWN" ]
+then
+    STATUS=BACKUP
 fi
 echo "Status: ${STATUS}"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fb33cb28/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ b/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
index 9579b11..f05b440 100755
--- a/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
+++ b/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
@@ -16,10 +16,20 @@
 # specific language governing permissions and limitations
 # under the License.
 
-STATUS=BACKUP
-ETH1_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}')
+STATUS=UNKNOWN
+INTERFACE=eth1
+ROUTER_TYPE=$(cat /etc/cloudstack/cmdline.json | grep type | awk '{print $2;}' | sed -e 's/[,\"]//g')
+if [ $ROUTER_TYPE = "router" ]
+then
+    INTERFACE=eth2
+fi
+
+ETH1_STATE=$(ip addr | grep $INTERFACE | grep state | awk '{print $9;}')
 if [ $ETH1_STATE = "UP" ]
 then
     STATUS=MASTER
+elif [ $ETH1_STATE = "DOWN" ]
+then
+    STATUS=BACKUP
 fi
 echo "Status: ${STATUS}"
\ No newline at end of file


[08/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - Make the check for master more reliable

   - Do not use the API call because it will read what is in the database, that might not have been updated yet
     * Check the status in the router directly instead
   - Remove all the sleeps


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

Branch: refs/heads/master
Commit: 41f4d8b58a337dc97526f2acb551c854b3432177
Parents: c7671f3
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Fri Oct 16 11:55:31 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 12:20:41 2015 +0200

----------------------------------------------------------------------
 .../config/opt/cloud/bin/cs/CsRedundant.py      |  5 +-
 .../debian/config/opt/cloud/bin/master.py       |  1 +
 .../integration/component/test_vpc_redundant.py | 64 +++++++++++++++++---
 3 files changed, 58 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/41f4d8b5/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index 29f755c..7ae1bd4 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -86,10 +86,6 @@ class CsRedundant(object):
             self._redundant_off()
             return
 
-        if self.cl.is_master():
-            for obj in [o for o in self.address.get_ips() if o.is_public()]:
-                self.check_is_up(obj.get_device())
-
         CsHelper.mkdir(self.CS_RAMDISK_DIR, 0755, False)
         CsHelper.mount_tmpfs(self.CS_RAMDISK_DIR)
         CsHelper.mkdir(self.CS_ROUTER_DIR, 0755, False)
@@ -311,6 +307,7 @@ class CsRedundant(object):
         ads = [o for o in self.address.get_ips() if o.needs_vrrp()]
         for o in ads:
             CsPasswdSvc(o.get_gateway()).restart()
+
         CsHelper.service("dnsmasq", "restart")
         self.cl.set_master_state(True)
         self.cl.save()

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/41f4d8b5/systemvm/patches/debian/config/opt/cloud/bin/master.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/master.py b/systemvm/patches/debian/config/opt/cloud/bin/master.py
index 41386f7..fb6ef6a 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/master.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/master.py
@@ -42,6 +42,7 @@ logging.basicConfig(filename=config.get_logger(),
                     format=config.get_format())
 config.cmdline()
 cl = CsCmdLine("cmdline", config)
+cl.set_master_state(False)
 
 config.set_address()
 red = CsRedundant(config)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/41f4d8b5/test/integration/component/test_vpc_redundant.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_redundant.py b/test/integration/component/test_vpc_redundant.py
index 68ce157..dfbf574 100644
--- a/test/integration/component/test_vpc_redundant.py
+++ b/test/integration/component/test_vpc_redundant.py
@@ -37,8 +37,11 @@ from marvin.lib.base import (stopRouter,
 from marvin.lib.common import (get_domain,
                                get_zone,
                                get_template,
-                               list_routers)
-from marvin.lib.utils import cleanup_resources
+                               list_routers,
+                               list_hosts)
+from marvin.lib.utils import (cleanup_resources,
+                              get_process_status,
+                              get_host_credentials)
 import socket
 import time
 import inspect
@@ -236,7 +239,10 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.routers = []
         self.networks = []
         self.ips = []
+
         self.apiclient = self.testClient.getApiClient()
+        self.hypervisor = self.testClient.getHypervisorInfo()
+
         self.account = Account.create(
             self.apiclient,
             self.services["account"],
@@ -288,13 +294,59 @@ class TestVPCRedundancy(cloudstackTestCase):
             len(self.routers), count,
             "Check that %s routers were indeed created" % count)
 
-    def check_master_status(self, count=2, showall=False):
+    def check_master_status(self,count=2, showall=False):
         vals = ["MASTER", "BACKUP", "UNKNOWN"]
         cnts = [0, 0, 0]
+
+        result = "UNKNOWN"
         self.query_routers(count, showall)
         for router in self.routers:
             if router.state == "Running":
-                cnts[vals.index(router.redundantstate)] += 1
+                hosts = list_hosts(
+                    self.apiclient,
+                    zoneid=router.zoneid,
+                    type='Routing',
+                    state='Up',
+                    id=router.hostid
+                )
+                self.assertEqual(
+                    isinstance(hosts, list),
+                    True,
+                    "Check list host returns a valid list"
+                )
+                host = hosts[0]
+
+                if self.hypervisor.lower() in ('vmware', 'hyperv'):
+                        result = str(get_process_status(
+                            self.apiclient.connection.mgtSvr,
+                            22,
+                            self.apiclient.connection.user,
+                            self.apiclient.connection.passwd,
+                            router.linklocalip,
+                            "grep MASTER /etc/cloudstack/cmdline.json",
+                            hypervisor=self.hypervisor
+                        ))
+                else:
+                    try:
+                        host.user, host.passwd = get_host_credentials(
+                            self.config, host.ipaddress)
+                        result = str(get_process_status(
+                            host.ipaddress,
+                            22,
+                            host.user,
+                            host.passwd,
+                            router.linklocalip,
+                            "grep MASTER /etc/cloudstack/cmdline.json"
+                        ))
+
+                    except KeyError:
+                        self.skipTest(
+                            "Marvin configuration has no host credentials to\
+                                    check router services")
+            
+                if result.count(vals[0]) == 1:
+                    cnts[vals.index(vals[0])] += 1
+
         if cnts[vals.index('MASTER')] != 1:
             self.fail("No Master or too many master routers found %s" % cnts[vals.index('MASTER')])
 
@@ -458,14 +510,11 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.query_routers()
         self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
         self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
-        time.sleep(10)
         self.check_master_status(2)
         self.add_nat_rules()
         self.do_vpc_test(False)
         
         self.stop_router_by_type("MASTER")
-        # wait for the backup router to transit to master state
-        time.sleep(10)
         self.check_master_status(1)
         self.do_vpc_test(False)
 
@@ -485,7 +534,6 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.query_routers()
         self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
         self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
-        time.sleep(10)
         self.check_master_status(2)
         self.add_nat_rules()
         self.do_default_routes_test()


[10/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - Reduce retried from 20 to 5

   - We do not need to retry that much


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

Branch: refs/heads/master
Commit: 2a747ca73538325fb24b3eefb95197bc1f8c6222
Parents: 5b3c990
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Sat Oct 17 12:09:26 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 12:20:42 2015 +0200

----------------------------------------------------------------------
 systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh        | 2 +-
 .../patches/debian/config/opt/cloud/templates/checkrouter.sh.templ | 2 +-
 test/integration/component/test_vpc_redundant.py                   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2a747ca7/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
index 1e4335c..9579b11 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
@@ -20,6 +20,6 @@ STATUS=BACKUP
 ETH1_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}')
 if [ $ETH1_STATE = "UP" ]
 then
-           STATUS=MASTER
+    STATUS=MASTER
 fi
 echo "Status: ${STATUS}"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2a747ca7/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ b/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
index 1e4335c..9579b11 100755
--- a/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
+++ b/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
@@ -20,6 +20,6 @@ STATUS=BACKUP
 ETH1_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}')
 if [ $ETH1_STATE = "UP" ]
 then
-           STATUS=MASTER
+    STATUS=MASTER
 fi
 echo "Status: ${STATUS}"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2a747ca7/test/integration/component/test_vpc_redundant.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_redundant.py b/test/integration/component/test_vpc_redundant.py
index dfbf574..a6032a1 100644
--- a/test/integration/component/test_vpc_redundant.py
+++ b/test/integration/component/test_vpc_redundant.py
@@ -555,7 +555,7 @@ class TestVPCRedundancy(cloudstackTestCase):
                     time.sleep(5)
 
     def do_vpc_test(self, expectFail):
-        retries = 20
+        retries = 5
         if expectFail:
             retries = 2
         for o in self.networks:


[04/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - Make sure we restart dnsmasq if the configuration file changes

   - It was working before because the Routers were restarting about 10 times for each operation
     e.g. adding a VM to a network ot acquiring a new IP.
   - Adding stat_rules of internal LB to iptables
     We needed one extra rule in the INPUT chain


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

Branch: refs/heads/master
Commit: 1886c4a1b33c2cd75bd5e49626943b5526894bc6
Parents: d762dc8
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Thu Oct 15 12:44:54 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 12:20:40 2015 +0200

----------------------------------------------------------------------
 .../patches/debian/config/opt/cloud/bin/cs/CsDhcp.py  | 14 +++++++++-----
 .../debian/config/opt/cloud/bin/cs/CsLoadBalancer.py  | 12 ++++++++++--
 test/integration/component/test_vpc_redundant.py      |  2 ++
 3 files changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1886c4a1/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py
index 234ed4c..75bc0e3 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py
@@ -36,22 +36,26 @@ class CsDhcp(CsDataBag):
         self.preseed()
         self.cloud = CsFile(DHCP_HOSTS)
         self.conf = CsFile(CLOUD_CONF)
-        length = len(self.conf)
+
         for item in self.dbag:
             if item == "id":
                 continue
             self.add(self.dbag[item])
         self.write_hosts()
+        
         if self.cloud.is_changed():
             self.delete_leases()
+
         self.configure_server()
-        self.conf.commit()
-        self.cloud.commit()
-        if self.conf.is_changed():
+
+        if self.conf.is_changed() or self.cloud.is_changed():
             CsHelper.service("dnsmasq", "restart")
         elif self.cloud.is_changed():
             CsHelper.hup_dnsmasq("dnsmasq", "dnsmasq")
 
+        self.conf.commit()
+        self.cloud.commit()
+
     def configure_server(self):
         # self.conf.addeq("dhcp-hostsfile=%s" % DHCP_HOSTS)
         for i in self.devinfo:
@@ -131,8 +135,8 @@ class CsDhcp(CsDataBag):
         file.repopulate()
         for ip in self.hosts:
             file.add("%s\t%s" % (ip, self.hosts[ip]))
-        file.commit()
         if file.is_changed():
+            file.commit()
             logging.info("Updated hosts file")
         else:
             logging.debug("Hosts file unchanged")

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1886c4a1/systemvm/patches/debian/config/opt/cloud/bin/cs/CsLoadBalancer.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsLoadBalancer.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsLoadBalancer.py
index 76f1cca..d8f39dc 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsLoadBalancer.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsLoadBalancer.py
@@ -55,13 +55,15 @@ class CsLoadBalancer(CsDataBag):
 
         add_rules = self.dbag['config'][0]['add_rules']
         remove_rules = self.dbag['config'][0]['remove_rules']
-        self._configure_firewall(add_rules, remove_rules)
+        stat_rules = self.dbag['config'][0]['stat_rules']
+        self._configure_firewall(add_rules, remove_rules, stat_rules)
 
-    def _configure_firewall(self, add_rules, remove_rules):
+    def _configure_firewall(self, add_rules, remove_rules, stat_rules):
         firewall = self.config.get_fw()
 
         logging.debug("CsLoadBalancer:: configuring firewall. Add rules ==> %s" % add_rules)
         logging.debug("CsLoadBalancer:: configuring firewall. Remove rules ==> %s" % remove_rules)
+        logging.debug("CsLoadBalancer:: configuring firewall. Stat rules ==> %s" % stat_rules)
 
         for rules in add_rules:
             path = rules.split(':')
@@ -74,3 +76,9 @@ class CsLoadBalancer(CsDataBag):
             ip = path[0]
             port = path[1]
             firewall.append(["filter", "", "-D INPUT -p tcp -m tcp -d %s --dport %s -m state --state NEW -j ACCEPT" % (ip, port)])
+
+        for rules in stat_rules:
+            path = rules.split(':')
+            ip = path[0]
+            port = path[1]
+            firewall.append(["filter", "", "-A INPUT -p tcp -m tcp -d %s --dport %s -m state --state NEW -j ACCEPT" % (ip, port)])

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1886c4a1/test/integration/component/test_vpc_redundant.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_redundant.py b/test/integration/component/test_vpc_redundant.py
index c158c20..68ce157 100644
--- a/test/integration/component/test_vpc_redundant.py
+++ b/test/integration/component/test_vpc_redundant.py
@@ -458,6 +458,7 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.query_routers()
         self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
         self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
+        time.sleep(10)
         self.check_master_status(2)
         self.add_nat_rules()
         self.do_vpc_test(False)
@@ -484,6 +485,7 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.query_routers()
         self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
         self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
+        time.sleep(10)
         self.check_master_status(2)
         self.add_nat_rules()
         self.do_default_routes_test()


[02/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - Remove the '--vrrp' search criteria form the CsProcess constructor call

   - There is no such process, which makes the CsProcess.find return false and restart keepalived all the time.


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

Branch: refs/heads/master
Commit: 08b983fe022d309c5f49f776cce7c2b4a3f01cfd
Parents: 9363be3
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Wed Oct 14 11:21:53 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 12:20:39 2015 +0200

----------------------------------------------------------------------
 systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/08b983fe/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index abe997c..cdc66d8 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -173,7 +173,7 @@ class CsRedundant(object):
         conntrackd_cron.add("@reboot root service conntrackd start", -1)
         conntrackd_cron.commit()
 
-        proc = CsProcess(['/usr/sbin/keepalived', '--vrrp'])
+        proc = CsProcess(['/usr/sbin/keepalived'])
         if not proc.find() or keepalived_conf.is_changed():
             CsHelper.service("keepalived", "restart")
 


[06/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - Do not restart conntrackd unless it's needed

   - With the keepalived fixed they should not be needed anymore. So first reducing them drasticaly
   - I am now making a backup of the template file, write to the template file and compare it with the existing configuration
   - The template file is recovered afer the process
   - I also check if the process is running
   - I fixed a bug in the compare method
   - I am now updating the configuration variable once the file content is flushed to disk


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

Branch: refs/heads/master
Commit: b4920aa028e75c64160988113ac268e5ea5ae69e
Parents: 5a21605
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Wed Oct 14 14:24:11 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 12:20:40 2015 +0200

----------------------------------------------------------------------
 .../patches/debian/config/opt/cloud/bin/cs/CsFile.py   |  7 ++++++-
 .../debian/config/opt/cloud/bin/cs/CsLoadBalancer.py   |  8 ++++----
 .../debian/config/opt/cloud/bin/cs/CsRedundant.py      | 13 +++++++------
 test/integration/component/test_vpc_redundant.py       |  7 +------
 4 files changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b4920aa0/systemvm/patches/debian/config/opt/cloud/bin/cs/CsFile.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsFile.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsFile.py
index 319b48e..7829c0a 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsFile.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsFile.py
@@ -64,6 +64,9 @@ class CsFile:
             handle.write(line)
         handle.close()
         logging.info("Wrote edited file %s" % self.filename)
+        self.config = list(self.new_config)
+        logging.info("Updated file in-cache configuration")
+        
 
     def dump(self):
         for line in self.new_config:
@@ -160,4 +163,6 @@ class CsFile:
 
 
     def compare(self, o):
-        return (isinstance(o, self.__class__) and set(self.config) == set(o.new_config))
+        result = (isinstance(o, self.__class__) and set(self.config) == set(o.config))
+        logging.debug("Comparison of CsFiles content is ==> %s" % result)
+        return result

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b4920aa0/systemvm/patches/debian/config/opt/cloud/bin/cs/CsLoadBalancer.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsLoadBalancer.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsLoadBalancer.py
index a288eac..76f1cca 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsLoadBalancer.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsLoadBalancer.py
@@ -17,7 +17,6 @@
 import logging
 import os.path
 import re
-import shutil
 from cs.CsDatabag import CsDataBag
 from CsProcess import CsProcess
 from CsFile import CsFile
@@ -37,13 +36,14 @@ class CsLoadBalancer(CsDataBag):
             return
         config = self.dbag['config'][0]['configuration']
         file1 = CsFile(HAPROXY_CONF_T)
-        file2 = CsFile(HAPROXY_CONF_P)
         file1.empty()
         for x in config:
             [file1.append(w, -1) for w in x.split('\n')]
+
+        file1.commit()
+        file2 = CsFile(HAPROXY_CONF_P)
         if not file2.compare(file1):
-            file1.commit()
-            shutil.copy2(HAPROXY_CONF_T, HAPROXY_CONF_P)
+            CsHelper.copy(HAPROXY_CONF_T, HAPROXY_CONF_P)
 
             proc = CsProcess(['/var/run/haproxy.pid'])
             if not proc.find():

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b4920aa0/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index 5361c33..5dec749 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -131,9 +131,9 @@ class CsRedundant(object):
         
         CsHelper.copy(conntrackd_template_conf, conntrackd_temp_bkp)
         
-        connt = CsFile(conntrackd_template_conf)
+        conntrackd_tmpl = CsFile(conntrackd_template_conf)
         if guest is not None:
-            connt.section("Multicast {", "}", [
+            conntrackd_tmpl.section("Multicast {", "}", [
                           "IPv4_address 225.0.0.50\n",
                           "Group 3780\n",
                           "IPv4_interface %s\n" % guest.get_ip(),
@@ -141,14 +141,15 @@ class CsRedundant(object):
                           "SndSocketBuffer 1249280\n",
                           "RcvSocketBuffer 1249280\n",
                           "Checksum on\n"])
-            connt.section("Address Ignore {", "}", self._collect_ignore_ips())
-            connt.commit()
+            conntrackd_tmpl.section("Address Ignore {", "}", self._collect_ignore_ips())
+            conntrackd_tmpl.commit()
 
         conntrackd_conf = CsFile(self.CONNTRACKD_CONF)
 
-        if not connt.compare(conntrackd_conf):
+        is_equals = conntrackd_tmpl.compare(conntrackd_conf)
+        proc = CsProcess(['/etc/conntrackd/conntrackd.conf'])
+        if not proc.find() or not is_equals:
             CsHelper.copy(conntrackd_template_conf, self.CONNTRACKD_CONF)
-            proc = CsProcess(['/etc/conntrackd/conntrackd.conf'])
             CsHelper.service("conntrackd", "restart")
 
         # Restore the template file and remove the backup.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b4920aa0/test/integration/component/test_vpc_redundant.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_redundant.py b/test/integration/component/test_vpc_redundant.py
index 6f82aec..c158c20 100644
--- a/test/integration/component/test_vpc_redundant.py
+++ b/test/integration/component/test_vpc_redundant.py
@@ -458,26 +458,22 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.query_routers()
         self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
         self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
-        time.sleep(30)
         self.check_master_status(2)
         self.add_nat_rules()
         self.do_vpc_test(False)
-        time.sleep(30)
         
         self.stop_router_by_type("MASTER")
         # wait for the backup router to transit to master state
-        time.sleep(30)
+        time.sleep(10)
         self.check_master_status(1)
         self.do_vpc_test(False)
 
         self.delete_nat_rules()
-        time.sleep(45)
         self.check_master_status(1)
         self.do_vpc_test(True)
 
         self.start_routers()
         self.add_nat_rules()
-        time.sleep(30)
         self.check_master_status(2)
         self.do_vpc_test(False)
 
@@ -488,7 +484,6 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.query_routers()
         self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
         self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
-        time.sleep(30)
         self.check_master_status(2)
         self.add_nat_rules()
         self.do_default_routes_test()


[05/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - The public interface was comming UP in the Backup router

   - There were too many places trying to put the pub interface UP. I centralised it now.


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

Branch: refs/heads/master
Commit: d762dc8579a3ee40c762559d62affdf44194e853
Parents: b4920aa
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Thu Oct 15 12:44:28 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 12:20:40 2015 +0200

----------------------------------------------------------------------
 .../patches/debian/config/opt/cloud/bin/cs/CsAddress.py |  7 +------
 .../debian/config/opt/cloud/bin/cs/CsRedundant.py       | 12 +++++++-----
 2 files changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d762dc85/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
index 074a63f..0b00397 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
@@ -118,11 +118,6 @@ class CsAddress(CsDataBag):
             ip = CsIP(dev, self.config)
 
             for address in self.dbag[dev]:
-                #check if link is up
-                if not self.check_if_link_up(dev):
-                   cmd="ip link set %s up" % dev
-                   CsHelper.execute(cmd)
-
                 ip.setAddress(address)
 
                 if ip.configured():
@@ -328,7 +323,7 @@ class CsIP:
             if " DOWN " in i:
                 cmd2 = "ip link set %s up" % self.getDevice()
                 # If redundant do not bring up public interfaces
-                # master.py and keepalived deal with tham
+                # master.py and keepalived will deal with them
                 if self.cl.is_redundant() and not self.is_public():
                     CsHelper.execute(cmd2)
                 # if not redundant bring everything up

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d762dc85/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index 5dec749..9e1f073 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -82,12 +82,14 @@ class CsRedundant(object):
     def _redundant_on(self):
         guest = self.address.get_guest_if()
         # No redundancy if there is no guest network
-        if self.cl.is_master() or guest is None:
-            for obj in [o for o in self.address.get_ips() if o.is_public()]:
-                self.check_is_up(obj.get_device())
         if guest is None:
             self._redundant_off()
             return
+
+        if self.cl.is_master():
+            for obj in [o for o in self.address.get_ips() if o.is_public()]:
+                self.check_is_up(obj.get_device())
+
         CsHelper.mkdir(self.CS_RAMDISK_DIR, 0755, False)
         CsHelper.mount_tmpfs(self.CS_RAMDISK_DIR)
         CsHelper.mkdir(self.CS_ROUTER_DIR, 0755, False)
@@ -336,7 +338,7 @@ class CsRedundant(object):
 
         In a DomR there will only ever be one address in a VPC there can be many
         The new code also gives the possibility to cloudstack to have a hybrid device
-        thet could function as a router and VPC router at the same time
+        that could function as a router and VPC router at the same time
         """
         lines = []
         for o in self.address.get_ips():
@@ -347,12 +349,12 @@ class CsRedundant(object):
                 else:
                     str = "        %s brd %s dev %s\n" % (o.get_gateway_cidr(), o.get_broadcast(), o.get_device())
                 lines.append(str)
-                self.check_is_up(o.get_device())
         return lines
 
     def check_is_up(self, device):
         """ Ensure device is up """
         cmd = "ip link show %s | grep 'state DOWN'" % device
+
         for i in CsHelper.execute(cmd):
             if " DOWN " in i:
                 cmd2 = "ip link set %s up" % device


[07/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - Restart dnsmasq everytime the configure.py runs


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

Branch: refs/heads/master
Commit: c7671f3cdd4cb1b52ff44b44288cb843098bccde
Parents: 2b286ec
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Thu Oct 15 18:31:03 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 12:20:41 2015 +0200

----------------------------------------------------------------------
 systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7671f3c/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py
index 75bc0e3..02e7bd7 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py
@@ -48,10 +48,8 @@ class CsDhcp(CsDataBag):
 
         self.configure_server()
 
-        if self.conf.is_changed() or self.cloud.is_changed():
-            CsHelper.service("dnsmasq", "restart")
-        elif self.cloud.is_changed():
-            CsHelper.hup_dnsmasq("dnsmasq", "dnsmasq")
+        # We restart DNSMASQ every time the configure.py is called in order to avoid lease problems.
+        CsHelper.service("dnsmasq", "restart")
 
         self.conf.commit()
         self.cloud.commit()


[09/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - Do not rely in the router state on the json file to report back to ACS

   - If we stop/start a router, the state in the file will still say MASTER, when it is actually not
   - Checking the state based on the interface (eth1) state
   - Once master.py is called by keepalived, save the state in the json file to BACKUP just to make sure it's also written there


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

Branch: refs/heads/master
Commit: 5b3c99031ffa1e2f73fc839d054cb88f6abd802b
Parents: 41f4d8b
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Sat Oct 17 08:09:52 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 12:20:41 2015 +0200

----------------------------------------------------------------------
 systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh | 9 +++++----
 systemvm/patches/debian/config/opt/cloud/bin/master.py      | 2 ++
 .../debian/config/opt/cloud/templates/checkrouter.sh.templ  | 9 +++++----
 3 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5b3c9903/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
index 12b2da4..1e4335c 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
@@ -16,9 +16,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
-STATUS=$(cat /etc/cloudstack/cmdline.json | grep redundant_state | awk '{print $2;}' | sed -e 's/[,\"]//g')
-if [ "$?" -ne "0" ]
+STATUS=BACKUP
+ETH1_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}')
+if [ $ETH1_STATE = "UP" ]
 then
-	   STATUS=MASTER
+           STATUS=MASTER
 fi
-echo "Status: ${STATUS}"
+echo "Status: ${STATUS}"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5b3c9903/systemvm/patches/debian/config/opt/cloud/bin/master.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/master.py b/systemvm/patches/debian/config/opt/cloud/bin/master.py
index fb6ef6a..c3a1539 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/master.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/master.py
@@ -42,7 +42,9 @@ logging.basicConfig(filename=config.get_logger(),
                     format=config.get_format())
 config.cmdline()
 cl = CsCmdLine("cmdline", config)
+#Update the configuration to set state as backup and let keepalived decide who is the real Master
 cl.set_master_state(False)
+cl.save()
 
 config.set_address()
 red = CsRedundant(config)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5b3c9903/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ b/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
index 12b2da4..1e4335c 100755
--- a/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
+++ b/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ
@@ -16,9 +16,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
-STATUS=$(cat /etc/cloudstack/cmdline.json | grep redundant_state | awk '{print $2;}' | sed -e 's/[,\"]//g')
-if [ "$?" -ne "0" ]
+STATUS=BACKUP
+ETH1_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}')
+if [ $ETH1_STATE = "UP" ]
 then
-	   STATUS=MASTER
+           STATUS=MASTER
 fi
-echo "Status: ${STATUS}"
+echo "Status: ${STATUS}"
\ No newline at end of file


[11/13] git commit: updated refs/heads/master to 6fe5ae0

Posted by re...@apache.org.
CLOUDSTACK-8952 - Make the tests rely on the interface state other than the json file


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

Branch: refs/heads/master
Commit: 38d03576d61d1ddac8f29b962d9d30bc45d7a39b
Parents: 2a747ca
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Sat Oct 17 14:47:05 2015 +0200
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Sat Oct 17 14:47:05 2015 +0200

----------------------------------------------------------------------
 test/integration/component/test_vpc_redundant.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38d03576/test/integration/component/test_vpc_redundant.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_redundant.py b/test/integration/component/test_vpc_redundant.py
index a6032a1..600850b 100644
--- a/test/integration/component/test_vpc_redundant.py
+++ b/test/integration/component/test_vpc_redundant.py
@@ -323,7 +323,7 @@ class TestVPCRedundancy(cloudstackTestCase):
                             self.apiclient.connection.user,
                             self.apiclient.connection.passwd,
                             router.linklocalip,
-                            "grep MASTER /etc/cloudstack/cmdline.json",
+                            "sh /opt/cloud/bin/checkrouter.sh ",
                             hypervisor=self.hypervisor
                         ))
                 else:
@@ -336,7 +336,7 @@ class TestVPCRedundancy(cloudstackTestCase):
                             host.user,
                             host.passwd,
                             router.linklocalip,
-                            "grep MASTER /etc/cloudstack/cmdline.json"
+                            "sh /opt/cloud/bin/checkrouter.sh "
                         ))
 
                     except KeyError: