From 7988f51ac07782ad9b9873c32438fd7cdb24edba Mon Sep 17 00:00:00 2001 From: Wilder Rodrigues Date: Thu, 17 Dec 2015 14:20:59 +0100 Subject: [PATCH] CLOUDSTACK-9154 - Returns the guest iterface that is marked as added - Force a restart of keepalived if conntrackd is not running or configuration has changed --- .../debian/config/opt/cloud/bin/cs/CsAddress.py | 5 ++++- .../debian/config/opt/cloud/bin/cs/CsRedundant.py | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) 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 24d75e55e85..d320d0a1f1f 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py @@ -52,7 +52,7 @@ class CsAddress(CsDataBag): """ ipr = [] for ip in self.get_ips(): - if ip.is_guest(): + if ip.is_guest() and ip.is_added(): ipr.append(ip) if len(ipr) > 0: return sorted(ipr)[-1] @@ -189,6 +189,9 @@ class CsInterface: if "nw_type" in self.address and self.address['nw_type'] in ['public']: return True return False + + def is_added(self): + return self.get_attr("add") def to_str(self): pprint(self.address) 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 d853eb9f74d..f975871e0df 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py @@ -108,7 +108,6 @@ class CsRedundant(object): CsHelper.service("keepalived", "stop") return - CsHelper.mkdir(self.CS_RAMDISK_DIR, 0755, False) CsHelper.mount_tmpfs(self.CS_RAMDISK_DIR) CsHelper.mkdir(self.CS_ROUTER_DIR, 0755, False) @@ -148,7 +147,7 @@ class CsRedundant(object): conntrackd_temp_bkp = "%s/%s" % (self.CS_TEMPLATES_DIR, "conntrackd.conf.templ.bkp") CsHelper.copy(conntrackd_template_conf, conntrackd_temp_bkp) - + conntrackd_tmpl = CsFile(conntrackd_template_conf) conntrackd_tmpl.section("Multicast {", "}", [ "IPv4_address 225.0.0.50\n", @@ -164,10 +163,14 @@ class CsRedundant(object): conntrackd_conf = CsFile(self.CONNTRACKD_CONF) is_equals = conntrackd_tmpl.compare(conntrackd_conf) + + force_keepalived_restart = False proc = CsProcess(['/etc/conntrackd/conntrackd.conf']) - if not proc.find() or not is_equals: + + if not proc.find() and not is_equals: CsHelper.copy(conntrackd_template_conf, self.CONNTRACKD_CONF) CsHelper.service("conntrackd", "restart") + force_keepalived_restart = True # Restore the template file and remove the backup. CsHelper.copy(conntrackd_temp_bkp, conntrackd_template_conf) @@ -185,7 +188,7 @@ class CsRedundant(object): heartbeat_cron.commit() proc = CsProcess(['/usr/sbin/keepalived']) - if not proc.find() or keepalived_conf.is_changed(): + if not proc.find() or keepalived_conf.is_changed() or force_keepalived_restart: keepalived_conf.commit() CsHelper.service("keepalived", "restart")