New api: list logical routers by type

Change-Id: If2642bd480743774e32cc663dd5e1db4f955f727
This commit is contained in:
Adit Sarfaty 2017-08-28 11:58:13 +03:00
parent de76f60c55
commit f505cc251f
2 changed files with 24 additions and 0 deletions

View File

@ -484,6 +484,22 @@ class LogicalRouterTestCase(nsxlib_testcase.NsxClientTestCase):
'delete', router,
'https://1.2.3.4/api/v1/logical-routers/%s?force=True' % uuid)
def test_list_logical_router(self):
router = self._mocked_lrouter()
router.list()
test_client.assert_json_call(
'get', router,
'https://1.2.3.4/api/v1/logical-routers')
def test_list_logical_router_by_type(self):
router = self._mocked_lrouter()
router_type = 'TIER0'
router.list(router_type=router_type)
test_client.assert_json_call(
'get', router,
'https://1.2.3.4/api/v1/logical-routers?router_type=%s' %
router_type)
def test_get_logical_router_fw_section(self):
fake_router = test_constants.FAKE_ROUTER.copy()

View File

@ -642,6 +642,14 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase):
sec.get('target_type') == "FirewallSection"):
return firewall_sections[0].get('target_id')
def list(self, router_type=None):
"""List all/by type logical routers."""
if router_type:
resource = '%s?router_type=%s' % (self.get_path(), router_type)
else:
resource = self.get_path()
return self.client.list(resource)
class NsxLibEdgeCluster(utils.NsxLibApiBase):