From 2656e4335704fc846028807b9696a980cd886983 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Mon, 5 Feb 2018 21:10:43 +0200 Subject: [PATCH] Fix rate-limit attribute name Backend NSX changed it. Change-Id: Id5a04538c9416af2640d941715106f768e6bd1aa --- vmware_nsxlib/tests/unit/v3/test_resources.py | 8 +++++--- vmware_nsxlib/v3/resources.py | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vmware_nsxlib/tests/unit/v3/test_resources.py b/vmware_nsxlib/tests/unit/v3/test_resources.py index 08764c84..fa65a433 100644 --- a/vmware_nsxlib/tests/unit/v3/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/test_resources.py @@ -1692,7 +1692,7 @@ class NodeHttpServicePropertiesTestCase(BaseTestResource): def test_get_rate_limit(self): mocked_resource = self.get_mocked_resource() rate_limit = 40 - body = {'service_properties': {'api_rate_limit': rate_limit}} + body = {'service_properties': {'client_api_rate_limit': rate_limit}} with mock.patch("vmware_nsxlib.v3.NsxLib.get_version", return_value='2.2.0'),\ mock.patch.object(mocked_resource.client, "url_get", @@ -1704,13 +1704,15 @@ class NodeHttpServicePropertiesTestCase(BaseTestResource): mocked_resource = self.get_mocked_resource() old_rate_limit = 40 new_rate_limit = 50 - body = {'service_properties': {'api_rate_limit': old_rate_limit}} + body = {'service_properties': { + 'client_api_rate_limit': old_rate_limit}} with mock.patch("vmware_nsxlib.v3.NsxLib.get_version", return_value='2.2.0'),\ mock.patch.object(mocked_resource.client, "url_get", return_value=body): mocked_resource.update_rate_limit(new_rate_limit) - body['service_properties']['api_rate_limit'] = new_rate_limit + body['service_properties'][ + 'client_api_rate_limit'] = new_rate_limit test_client.assert_json_call( 'put', mocked_resource, 'https://1.2.3.4/api/v1/node/services/http', diff --git a/vmware_nsxlib/v3/resources.py b/vmware_nsxlib/v3/resources.py index ec05ab22..a289e053 100644 --- a/vmware_nsxlib/v3/resources.py +++ b/vmware_nsxlib/v3/resources.py @@ -627,7 +627,8 @@ class NodeHttpServiceProperties(utils.NsxLibApiBase): raise exceptions.ManagerError(details=msg) properties = self.get_properties() - return properties.get('service_properties', {}).get('api_rate_limit') + return properties.get('service_properties', {}).get( + 'client_api_rate_limit') def update_rate_limit(self, value): """update the NSX rate limit. default value is 40. 0 means no limit""" @@ -640,7 +641,8 @@ class NodeHttpServiceProperties(utils.NsxLibApiBase): properties = self.get_properties() if 'service_properties' in properties: - properties['service_properties']['api_rate_limit'] = int(value) + properties['service_properties'][ + 'client_api_rate_limit'] = int(value) # update the value using a PUT command, which is expected to return 202 expected_results = [requests.codes.accepted]