CLOUDSTACK-9287 - Make sure private gw interface is not used for default gw

This commit is contained in:
Remi Bergsma 2016-02-14 14:39:53 +01:00
parent 250be376e8
commit 057b54aa3e
2 changed files with 5 additions and 4 deletions

View File

@ -307,7 +307,7 @@ class CsIP:
# The code looks redundant here, but we actually have to cater for routers and
# VPC routers in a different manner. Please do not remove this block otherwise
# The VPC default route will be broken.
if self.get_type() in ["public"]:
if self.get_type() in ["public"] and address["device"] in PUBLIC_INTERFACE:
gateway = str(address["gateway"])
route.add_defaultroute(gateway)
else:

View File

@ -41,6 +41,7 @@ from CsRoute import CsRoute
import socket
from time import sleep
PUBLIC_INTERFACE = ['eth0', 'eth1']
class CsRedundant(object):
@ -228,7 +229,7 @@ class CsRedundant(object):
self.set_lock()
logging.info("Router switched to fault mode")
ips = [ip for ip in self.address.get_ips() if ip.is_public()]
ips = [ip for ip in self.address.get_ips() if ip.is_public() and ip.get_device() in PUBLIC_INTERFACE]
for ip in ips:
CsHelper.execute("ifconfig %s down" % ip.get_device())
@ -257,7 +258,7 @@ class CsRedundant(object):
logging.debug("Setting router to backup")
dev = ''
ips = [ip for ip in self.address.get_ips() if ip.is_public()]
ips = [ip for ip in self.address.get_ips() if ip.is_public() and ip.get_device() in PUBLIC_INTERFACE]
for ip in ips:
if dev == ip.get_device():
continue
@ -291,7 +292,7 @@ class CsRedundant(object):
logging.debug("Setting router to master")
dev = ''
ips = [ip for ip in self.address.get_ips() if ip.is_public()]
ips = [ip for ip in self.address.get_ips() if ip.is_public() and ip.get_device() in PUBLIC_INTERFACE]
route = CsRoute()
for ip in ips:
if dev == ip.get_device():