From b8c6e43cc3519d727508dc7ecb700338fa590568 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 20 Oct 2021 06:44:27 -0700 Subject: [PATCH] Remove trailing '/' in swiching profile operations When querying switching profiles including system owned, there is a trailing slash at the end of the URI. This change removes this slash. Change-Id: Iaa7d18fa8fdcd22c29baf2265259dfe843890213 --- vmware_nsxlib/tests/unit/v3/test_resources.py | 2 +- vmware_nsxlib/v3/core_resources.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/vmware_nsxlib/tests/unit/v3/test_resources.py b/vmware_nsxlib/tests/unit/v3/test_resources.py index 39b1e9f8..6322628a 100644 --- a/vmware_nsxlib/tests/unit/v3/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/test_resources.py @@ -325,7 +325,7 @@ class TestSwitchingProfileTestCase(BaseTestResource): mocked_resource.list() test_client.assert_json_call( 'get', mocked_resource, - 'https://1.2.3.4/api/v1/switching-profiles/' + 'https://1.2.3.4/api/v1/switching-profiles' '?include_system_owned=True', data=None, headers=self.default_headers()) diff --git a/vmware_nsxlib/v3/core_resources.py b/vmware_nsxlib/v3/core_resources.py index ac7c0421..3af3f3d1 100644 --- a/vmware_nsxlib/v3/core_resources.py +++ b/vmware_nsxlib/v3/core_resources.py @@ -285,9 +285,17 @@ class NsxLibSwitchingProfile(utils.NsxLibApiBase): def uri_segment(self): return 'switching-profiles' + def get_path(self, resource=None, query_params=None): + path = super().get_path(resource) + if query_params: + param_str = "&".join("%s=%s" % (k, v) for (k, v) in + query_params.items()) + path = '%s?%s' % (path, param_str) + return path + def list(self): return self.client.list( - self.get_path('?include_system_owned=True')) + self.get_path(query_params={'include_system_owned': True})) def create(self, profile_type, display_name=None, description=None, **api_args):