From ef052e48807e0811859d8a5fc720846ea93d0f2c Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Fri, 2 Aug 2024 17:19:31 +0200 Subject: [PATCH] Fix parameter name clashing in resource lock query TODO: * add test coverage * look at other methods taking resource_type as kwargs Closes-Bug: #2075347 Change-Id: I2a48a3793ebd2db9dd9ca02b75b599c266ad1c24 --- openstack/proxy.py | 8 ++++++++ openstack/shared_file_system/v2/_proxy.py | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/openstack/proxy.py b/openstack/proxy.py index 5768fc9f8..41bb93fa9 100644 --- a/openstack/proxy.py +++ b/openstack/proxy.py @@ -744,6 +744,14 @@ class Proxy(adapter.Adapter): :class:`~openstack.resource.Resource` that doesn't match the ``resource_type``. """ + # Check for attributes whose names conflict with the parameters + # specified in the method. + conflicting_attrs = attrs.get('__conflicting_attrs', {}) + if conflicting_attrs: + for k, v in conflicting_attrs.items(): + attrs[k] = v + attrs.pop('__conflicting_attrs') + data = resource_type.list( self, paginated=paginated, base_path=base_path, **attrs ) diff --git a/openstack/shared_file_system/v2/_proxy.py b/openstack/shared_file_system/v2/_proxy.py index 836b2d3da..b64ad87ea 100644 --- a/openstack/shared_file_system/v2/_proxy.py +++ b/openstack/shared_file_system/v2/_proxy.py @@ -1129,6 +1129,15 @@ class Proxy(proxy.Proxy): :rtype: :class:`~openstack.shared_file_system.v2. resource_locks.ResourceLock` """ + + if query.get('resource_type'): + # The _create method has a parameter named resource_type, which + # refers to the type of resource to be created, so we need to avoid + # a conflict of parameters we are sending to the method. + query['__conflicting_attrs'] = { + 'resource_type': query.get('resource_type') + } + query.pop('resource_type') return self._list(_resource_locks.ResourceLock, **query) def get_resource_lock(self, resource_lock):