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
This commit is contained in:
Balazs Gibizer 2024-08-02 17:19:31 +02:00
parent 939ec03ab3
commit ef052e4880
2 changed files with 17 additions and 0 deletions

View File

@ -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
)

View File

@ -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):