Merge "Refactor _process_routers to handle a single router"
This commit is contained in:
commit
de83037a10
@ -130,15 +130,15 @@ class VPNAgent(l3_agent.L3NATAgentWithStateReport):
|
|||||||
for device in self.devices:
|
for device in self.devices:
|
||||||
device.destroy_router(router_id)
|
device.destroy_router(router_id)
|
||||||
|
|
||||||
def _process_routers(self, routers):
|
def _process_router_if_compatible(self, router):
|
||||||
"""Router sync event.
|
"""Router sync event.
|
||||||
|
|
||||||
This method overwrites parent class method.
|
This method overwrites parent class method.
|
||||||
:param routers: list of routers
|
:param router: a router
|
||||||
"""
|
"""
|
||||||
super(VPNAgent, self)._process_routers(routers)
|
super(VPNAgent, self)._process_router_if_compatible(router)
|
||||||
for device in self.devices:
|
for device in self.devices:
|
||||||
device.sync(self.context, routers)
|
device.sync(self.context, [router])
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -183,15 +183,14 @@ class TestVPNAgent(base.BaseTestCase):
|
|||||||
self.agent._router_removed(router_id)
|
self.agent._router_removed(router_id)
|
||||||
device.destroy_router.assert_called_once_with(router_id)
|
device.destroy_router.assert_called_once_with(router_id)
|
||||||
|
|
||||||
def test_process_routers(self):
|
def test_process_router_if_compatible(self):
|
||||||
self.plugin_api.get_external_network_id.return_value = None
|
self.plugin_api.get_external_network_id.return_value = None
|
||||||
routers = [
|
router = {'id': _uuid(),
|
||||||
{'id': _uuid(),
|
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'routes': [],
|
'routes': [],
|
||||||
'external_gateway_info': {}}]
|
'external_gateway_info': {}}
|
||||||
|
|
||||||
device = mock.Mock()
|
device = mock.Mock()
|
||||||
self.agent.devices = [device]
|
self.agent.devices = [device]
|
||||||
self.agent._process_routers(routers)
|
self.agent._process_router_if_compatible(router)
|
||||||
device.sync.assert_called_once_with(mock.ANY, routers)
|
device.sync.assert_called_once_with(mock.ANY, [router])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user