Merge "Support gateway which is not in subnet CIDR in ha_router" into stable/train
This commit is contained in:
commit
b11562b54c
|
@ -30,6 +30,7 @@ from neutron.agent.linux import keepalived
|
||||||
from neutron.common import utils as common_utils
|
from neutron.common import utils as common_utils
|
||||||
from neutron.extensions import revisions
|
from neutron.extensions import revisions
|
||||||
from neutron.extensions import timestamp
|
from neutron.extensions import timestamp
|
||||||
|
from neutron.ipam import utils as ipam_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
HA_DEV_PREFIX = 'ha-'
|
HA_DEV_PREFIX = 'ha-'
|
||||||
|
@ -274,6 +275,14 @@ class HaRouter(router.RouterInfo):
|
||||||
|
|
||||||
default_gw_rts = []
|
default_gw_rts = []
|
||||||
instance = self._get_keepalived_instance()
|
instance = self._get_keepalived_instance()
|
||||||
|
for subnet in ex_gw_port.get('subnets', []):
|
||||||
|
is_gateway_not_in_subnet = (subnet['gateway_ip'] and
|
||||||
|
not ipam_utils.check_subnet_ip(
|
||||||
|
subnet['cidr'],
|
||||||
|
subnet['gateway_ip']))
|
||||||
|
if is_gateway_not_in_subnet:
|
||||||
|
default_gw_rts.append(keepalived.KeepalivedVirtualRoute(
|
||||||
|
subnet['gateway_ip'], None, interface_name, scope='link'))
|
||||||
for gw_ip in gateway_ips:
|
for gw_ip in gateway_ips:
|
||||||
# TODO(Carl) This is repeated everywhere. A method would
|
# TODO(Carl) This is repeated everywhere. A method would
|
||||||
# be nice.
|
# be nice.
|
||||||
|
|
|
@ -84,6 +84,10 @@ class TestBasicRouterOperations(base.BaseTestCase):
|
||||||
ri._add_default_gw_virtual_route(ex_gw_port, 'qg-abc')
|
ri._add_default_gw_virtual_route(ex_gw_port, 'qg-abc')
|
||||||
self.assertEqual(0, len(mock_instance.virtual_routes.gateway_routes))
|
self.assertEqual(0, len(mock_instance.virtual_routes.gateway_routes))
|
||||||
|
|
||||||
|
subnets[1]['gateway_ip'] = '30.0.1.1'
|
||||||
|
ri._add_default_gw_virtual_route(ex_gw_port, 'qg-abc')
|
||||||
|
self.assertEqual(2, len(mock_instance.virtual_routes.gateway_routes))
|
||||||
|
|
||||||
@mock.patch.object(router_info.RouterInfo, 'remove_floating_ip')
|
@mock.patch.object(router_info.RouterInfo, 'remove_floating_ip')
|
||||||
def test_remove_floating_ip(self, super_remove_floating_ip):
|
def test_remove_floating_ip(self, super_remove_floating_ip):
|
||||||
ri = self._create_router(mock.MagicMock())
|
ri = self._create_router(mock.MagicMock())
|
||||||
|
|
Loading…
Reference in New Issue