Switch control interface for vrrp to guest network

Fix rRouter that was deleting the gateway interface
This commit is contained in:
Ian Southam 2015-02-03 17:21:11 +01:00 committed by wilderrodrigues
parent e350f1e76f
commit 7a9a356094
2 changed files with 10 additions and 6 deletions

View File

@ -502,10 +502,12 @@ class CsIP:
def is_guest_gateway(self, bag, ip):
""" Exclude the vrrp maintained addresses on a redundant router """
interface = CsInterface(bag, self.config)
if not self.config.cl.is_redundant():
return False
rip = ip.split('/')[0]
if bag['nw_type'] == "guest" and rip == bag['gateway']:
gw = interface.get_gateway()
if bag['nw_type'] == "guest" and rip == gw:
return True
return False

View File

@ -78,6 +78,11 @@ class CsRedundant(object):
CsHelper.rm(self.KEEPALIVED_CONF)
def _redundant_on(self):
guest = self.address.get_guest_if()
# No redundancy if there is no guest network
if guest is None:
self._redundant_off()
return
CsHelper.mkdir(self.CS_RAMDISK_DIR, 0755, False)
CsHelper.mount_tmpfs(self.CS_RAMDISK_DIR)
CsHelper.mkdir(self.CS_ROUTER_DIR, 0755, False)
@ -107,7 +112,8 @@ class CsRedundant(object):
i = i + 1
file.search(" router_id ", " router_id %s" % self.cl.get_name())
file.search(" priority ", " priority %s" % self.cl.get_priority())
file.search(" weight ", " weight %s" % 2)
file.search(" interface ", " interface %s" % guest.get_device())
#file.search(" weight ", " weight %s" % 2)
# file.search(" state ", " state %s" % self.cl.get_state())
file.search(" state ", " state %s" % "EQUAL")
# file.search(" virtual_router_id ", " virtual_router_id %s" % self.cl.get_router_id())
@ -116,7 +122,6 @@ class CsRedundant(object):
file.commit()
# conntrackd configuration
guest = self.address.get_guest_if()
connt = CsFile(self.CONNTRACKD_CONF)
if guest is not None:
connt.section("Multicast {", "}", [
@ -136,9 +141,6 @@ class CsRedundant(object):
if file.is_changed():
CsHelper.service("keepalived", "restart")
# FIXME
# enable/disable_pubip/master/slave etc. will need rewriting to use the new python config
# Configure heartbeat cron job
cron = CsFile("/etc/cron.d/heartbeat")
cron.add("SHELL=/bin/bash", 0)