From 41b0eb23516b2ac66f89a7d5f7e33968082a05cc Mon Sep 17 00:00:00 2001 From: Rajat Dhasmana Date: Tue, 21 Jan 2020 16:55:11 +0000 Subject: [PATCH] Support volume transfer `name` filters The `name` filter for volume transfer is not currently recognized by the API. Instead, it allowed filtering on 'display_name', which is not the actual name of any attribute of the resource. This patch adds the support for it while secretly continuing to support `display_name` as a valid filter so as not to break people who have figured out the workaround. Change-Id: I6a4d12d5dd55080e9aa73027ed82d3bf13855e28 Closes-Bug: #1860100 --- cinder/api/contrib/volume_transfer.py | 2 ++ cinder/api/v3/volume_transfer.py | 2 ++ releasenotes/notes/bug-1860100-8c542363def7d408.yaml | 6 ++++++ 3 files changed, 10 insertions(+) create mode 100644 releasenotes/notes/bug-1860100-8c542363def7d408.yaml diff --git a/cinder/api/contrib/volume_transfer.py b/cinder/api/contrib/volume_transfer.py index ceff8c82207..6e126ba4fbd 100644 --- a/cinder/api/contrib/volume_transfer.py +++ b/cinder/api/contrib/volume_transfer.py @@ -61,6 +61,8 @@ class VolumeTransferController(wsgi.Controller): context = req.environ['cinder.context'] filters = req.params.copy() LOG.debug('Listing volume transfers') + if 'name' in filters: + filters['display_name'] = filters.pop('name') transfers = self.transfer_api.get_all(context, filters=filters, sort_keys=['created_at', 'id'], sort_dirs=['asc', 'asc']) diff --git a/cinder/api/v3/volume_transfer.py b/cinder/api/v3/volume_transfer.py index 24fa4a357b1..9106ca4d505 100644 --- a/cinder/api/v3/volume_transfer.py +++ b/cinder/api/v3/volume_transfer.py @@ -46,6 +46,8 @@ class VolumeTransferController(volume_transfer_v2.VolumeTransferController): # as default order, but we should keep the compatible in here. sort_keys, sort_dirs = ['created_at', 'id'], ['asc', 'asc'] filters = params + if 'name' in filters: + filters['display_name'] = filters.pop('name') LOG.debug('Listing volume transfers') transfers = self.transfer_api.get_all(context, marker=marker, diff --git a/releasenotes/notes/bug-1860100-8c542363def7d408.yaml b/releasenotes/notes/bug-1860100-8c542363def7d408.yaml new file mode 100644 index 00000000000..12093ecdacf --- /dev/null +++ b/releasenotes/notes/bug-1860100-8c542363def7d408.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + The volume-transfers list calls (``GET /v3/{project_id}/volume-transfers``, + ``GET /v3/{project_id}/volume-transfers/detail``) were not recognizing ``name`` + as a filterable attribute. That has been fixed in the current release.