Browse Source

Merge "HA-non-DVR router don't need manually add static route" into stable/victoria

changes/02/790702/2
Zuul 6 days ago
committed by Gerrit Code Review
parent
commit
90caa0778e
2 changed files with 28 additions and 1 deletions
  1. +3
    -1
      neutron/agent/l3/ha_router.py
  2. +25
    -0
      neutron/tests/unit/agent/l3/test_ha_router.py

+ 3
- 1
neutron/agent/l3/ha_router.py View File

@ -271,7 +271,9 @@ class HaRouter(router.RouterInfo):
keepalived.KeepalivedVirtualRoute(
route['destination'], route['nexthop'])
for route in new_routes]
super(HaRouter, self).routes_updated(old_routes, new_routes)
if self.router.get('distributed', False):
super(HaRouter, self).routes_updated(old_routes, new_routes)
self.keepalived_manager.get_process().reload_cfg()
def _add_default_gw_virtual_route(self, ex_gw_port, interface_name):
gateway_ips = self._get_external_gw_ips(ex_gw_port)


+ 25
- 0
neutron/tests/unit/agent/l3/test_ha_router.py View File

@ -55,6 +55,31 @@ class TestBasicRouterOperations(base.BaseTestCase):
ri._get_cidrs_from_keepalived = mock.MagicMock(return_value=addresses)
self.assertEqual(set(addresses), ri.get_router_cidrs(device))
def test_routes_updated_with_dvr(self):
ri = self._create_router(router={'distributed': True})
ri.keepalived_manager = mock.Mock()
base_routes_updated = mock.patch(
'neutron.agent.l3.router_info.'
'RouterInfo.routes_updated').start()
mock_instance = mock.Mock()
mock_instance.virtual_routes.gateway_routes = []
ri._get_keepalived_instance = mock.Mock(
return_value=mock_instance)
ri.routes_updated([], [])
self.assertTrue(base_routes_updated.called)
def test_routes_updated_with_non_dvr(self):
ri = self._create_router(router={'distributed': False})
ri.keepalived_manager = mock.Mock()
base_routes_updated = mock.patch(
'neutron.agent.l3.router_info.'
'RouterInfo.routes_updated').start()
mock_instance = mock.Mock()
mock_instance.virtual_routes.gateway_routes = []
ri._get_keepalived_instance = mock.Mock(return_value=mock_instance)
ri.routes_updated([], [])
self.assertFalse(base_routes_updated.called)
def test__add_default_gw_virtual_route(self):
ri = self._create_router()
mock_instance = mock.Mock()


Loading…
Cancel
Save