From 2b286ecd730763a472fff2071a8fd7166692e11f Mon Sep 17 00:00:00 2001 From: Wilder Rodrigues Date: Thu, 15 Oct 2015 16:43:29 +0200 Subject: [PATCH] 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. --- .../debian/config/opt/cloud/bin/configure.py | 4 ++-- .../debian/config/opt/cloud/bin/cs/CsAddress.py | 16 ---------------- .../debian/config/opt/cloud/bin/cs/CsApp.py | 2 +- .../config/opt/cloud/bin/cs/CsRedundant.py | 3 +-- 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/systemvm/patches/debian/config/opt/cloud/bin/configure.py b/systemvm/patches/debian/config/opt/cloud/bin/configure.py index 014e294bd38..8c39f75247c 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) 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 0b00397b625..b80187ab739 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": 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 de53fe0f342..a0b4c6e3628 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", 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 9e1f0734188..29f755ca1d5 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)