From c8cdba9fb48ea2ae2fb6ad28264f1749911a357c Mon Sep 17 00:00:00 2001 From: asarfaty Date: Thu, 28 May 2020 08:53:03 +0200 Subject: [PATCH] Add mp api to list router static routes Change-Id: I6f06c5e1ab4be2ddc429d4d9d2277a7273599a62 --- vmware_nsxlib/tests/unit/v3/test_resources.py | 9 +++++++++ vmware_nsxlib/v3/core_resources.py | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/vmware_nsxlib/tests/unit/v3/test_resources.py b/vmware_nsxlib/tests/unit/v3/test_resources.py index 85ff2beb..48ef7e9f 100644 --- a/vmware_nsxlib/tests/unit/v3/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/test_resources.py @@ -1130,6 +1130,15 @@ class LogicalRouterTestCase(BaseTestResource): data=jsonutils.dumps(expected_payload, sort_keys=True), headers=self.default_headers()) + def test_list_static_routes(self): + router = self.get_mocked_resource() + router.list_static_routes(test_constants.FAKE_ROUTER_UUID) + test_client.assert_json_call( + 'get', router, + ('https://1.2.3.4/api/v1/logical-routers/%s/routing/' + 'static-routes' % test_constants.FAKE_ROUTER_UUID), + headers=self.default_headers()) + def test_update_advertisement(self): router = self.get_mocked_resource() router_id = test_constants.FAKE_ROUTER_UUID diff --git a/vmware_nsxlib/v3/core_resources.py b/vmware_nsxlib/v3/core_resources.py index efa33366..7fbcdb48 100644 --- a/vmware_nsxlib/v3/core_resources.py +++ b/vmware_nsxlib/v3/core_resources.py @@ -665,6 +665,11 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase): kwargs['next_hops'] = [{"ip_address": nexthop}] return self._delete_resource_by_values(resource, **kwargs) + def list_static_routes(self, logical_router_id): + resource = ('logical-routers/%s/routing/static-routes' % + logical_router_id) + return self.client.list(resource) + def delete_nat_rule(self, logical_router_id, nat_rule_id): path = 'logical-routers/%s/nat/rules/%s' % (logical_router_id, nat_rule_id)