CLOUDSTACK-8616 - Installing KeepaliveD from Debian Wheezy backports

- preempt delay reverted on version 1.2.13 - from the backports
     - vrrp : Revert "Honor preempt_delay setting on startup.".
     - See changelog: http://www.keepalived.org/changelog.html
   - Refactoring some variable names to avoid misunderstanding

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
This commit is contained in:
wilderrodrigues 2015-07-10 08:41:28 +02:00
parent 12ee36a55f
commit f78a65c05a
3 changed files with 19 additions and 22 deletions

View File

@ -375,8 +375,10 @@ packages() {
chroot . apt-get --no-install-recommends -q -y --force-yes install open-vm-tools
#xenstore utils
chroot . apt-get --no-install-recommends -q -y --force-yes install xenstore-utils libxenstore3.0
#keepalived and conntrackd
chroot . apt-get --no-install-recommends -q -y --force-yes install keepalived conntrackd ipvsadm libnetfilter-conntrack3 libnl1
#keepalived - install version 1.2.13 from wheezy backports
chroot . apt-get --no-install-recommends -t wheezy-backports -q -y --force-yes install keepalived
#conntrackd
chroot . apt-get --no-install-recommends -q -y --force-yes install conntrackd ipvsadm libnetfilter-conntrack3 libnl1
#ipcalc
chroot . apt-get --no-install-recommends -q -y --force-yes install ipcalc
#irqbalance from wheezy-backports

View File

@ -35,10 +35,9 @@ class CsFile:
self.new_config.append(line)
except IOError:
logging.debug("File %s does not exist" % self.filename)
return
else:
logging.debug("Reading file %s" % self.filename)
self.config = copy.deepcopy(self.new_config)
self.config = list(self.new_config)
def is_changed(self):
if set(self.config) != set(self.new_config):
@ -58,6 +57,7 @@ class CsFile:
def commit(self):
if not self.is_changed():
logging.info("Nothing to commit. The %s file did not change" % self.filename)
return
handle = open(self.filename, "w+")
for line in self.new_config:

View File

@ -101,21 +101,19 @@ class CsRedundant(object):
CsHelper.execute('sed -i "s/--exec\ \$DAEMON;/--exec\ \$DAEMON\ --\ --vrrp;/g" /etc/init.d/keepalived')
# checkrouter.sh configuration
file = CsFile("/opt/cloud/bin/checkrouter.sh")
file.greplace("[RROUTER_LOG]", self.RROUTER_LOG)
file.commit()
check_router = CsFile("/opt/cloud/bin/checkrouter.sh")
check_router.greplace("[RROUTER_LOG]", self.RROUTER_LOG)
check_router.commit()
# keepalived configuration
file = CsFile(self.KEEPALIVED_CONF)
ads = [o for o in self.address.get_ips() if o.is_public()]
file.search(" router_id ", " router_id %s" % self.cl.get_name())
file.search(" interface ", " interface %s" % guest.get_device())
file.search(" virtual_router_id ", " virtual_router_id %s" % self.cl.get_router_id())
file.greplace("[RROUTER_BIN_PATH]", self.CS_ROUTER_DIR)
file.section("authentication {", "}", [" auth_type AH \n", " auth_pass %s\n" % self.cl.get_router_password()])
file.section("virtual_ipaddress {", "}", self._collect_ips())
file.commit()
keepalived_conf = CsFile(self.KEEPALIVED_CONF)
keepalived_conf.search(" router_id ", " router_id %s" % self.cl.get_name())
keepalived_conf.search(" interface ", " interface %s" % guest.get_device())
keepalived_conf.search(" virtual_router_id ", " virtual_router_id %s" % self.cl.get_router_id())
keepalived_conf.greplace("[RROUTER_BIN_PATH]", self.CS_ROUTER_DIR)
keepalived_conf.section("authentication {", "}", [" 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
connt = CsFile(self.CONNTRACKD_CONF)
@ -134,9 +132,6 @@ class CsRedundant(object):
if connt.is_changed():
CsHelper.service("conntrackd", "restart")
if file.is_changed():
CsHelper.service("keepalived", "reload")
# Configure heartbeat cron job - runs every 30 seconds
heartbeat_cron = CsFile("/etc/cron.d/heartbeat")
heartbeat_cron.add("SHELL=/bin/bash", 0)
@ -153,8 +148,8 @@ class CsRedundant(object):
keepalived_cron.commit()
proc = CsProcess(['/usr/sbin/keepalived', '--vrrp'])
if not proc.find():
CsHelper.service("keepalived", "start")
if not proc.find() or keepalived_conf.is_changed():
CsHelper.service("keepalived", "restart")
def release_lock(self):
try: