Add a new method get_router_info to L3 agent extension API

This can be useful for VPNaaS agent extension. [1]

[1] I0b86c432e4b2210e5f2a73a7e3ba16d10467f0f2

Related-Bug: #1692128
Change-Id: I5cfeb8db501b0cdba95c003ec6281c6a55a73b49
This commit is contained in:
YAMAMOTO Takashi 2017-09-08 14:45:41 +09:00
parent 765f76ae36
commit b2a6b9087b
4 changed files with 20 additions and 0 deletions

View File

@ -36,3 +36,4 @@ router information to L3 agent extensions::
#. get_routers_in_project #. get_routers_in_project
#. get_router_hosting_port #. get_router_hosting_port
#. is_router_in_namespace #. is_router_in_namespace
#. get_router_info

View File

@ -65,3 +65,7 @@ class L3AgentExtensionAPI(object):
local_namespaces = self._local_namespaces() local_namespaces = self._local_namespaces()
ri = self._router_info.get(router_id) ri = self._router_info.get(router_id)
return ri and ri.ns_name in local_namespaces return ri and ri.ns_name in local_namespaces
def get_router_info(self, router_id):
"""Return RouterInfo for the given router id."""
return self._router_info.get(router_id)

View File

@ -94,3 +94,14 @@ class TestL3AgentExtensionApi(base.BaseTestCase):
api_object = l3_agent_api.L3AgentExtensionAPI(router_info) api_object = l3_agent_api.L3AgentExtensionAPI(router_info)
router_in_ns = api_object.is_router_in_namespace(ri.router_id) router_in_ns = api_object.is_router_in_namespace(ri.router_id)
self.assertFalse(router_in_ns) self.assertFalse(router_in_ns)
def test_get_router_info(self):
router_info, ri = self._prepare_router_data()
api_object = l3_agent_api.L3AgentExtensionAPI(router_info)
self.assertEqual(ri, api_object.get_router_info(self.router_id))
def test_get_router_info_nonexistent(self):
router_info, ri = self._prepare_router_data()
api_object = l3_agent_api.L3AgentExtensionAPI(router_info)
self.assertIsNone(
api_object.get_router_info(uuidutils.generate_uuid()))

View File

@ -0,0 +1,4 @@
---
features:
- A new method ``get_router_info`` has been added to
``L3AgentExtensionAPI``.