image: Add "id" filter for images
The Glance v2 API supports a range of operators [1] for the list-images API, allowing us to do things like: GET /v2/images?status=in:saving,queued While there's no good reason to filter images by a single ID, it would be helpful to be able to filter images by *multiple* IDs. Make this possible by adding "id" to the list of possible filters. [1] https://docs.openstack.org/api-ref/image/v2/index.html?expanded=list-images-detail#list-images Change-Id: I735188e20d4e6c3b326e9080e878e717564b057d Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
975cabbdd8
commit
6b2f555ade
openstack
releasenotes/notes
@ -34,13 +34,24 @@ class Image(resource.Resource, tag.TagMixin, _download.DownloadMixin):
|
|||||||
_store_unknown_attrs_as_properties = True
|
_store_unknown_attrs_as_properties = True
|
||||||
|
|
||||||
_query_mapping = resource.QueryParameters(
|
_query_mapping = resource.QueryParameters(
|
||||||
"name", "visibility",
|
"id",
|
||||||
"member_status", "owner",
|
"name",
|
||||||
"status", "size_min", "size_max",
|
"visibility",
|
||||||
"protected", "is_hidden",
|
"member_status",
|
||||||
"sort_key", "sort_dir", "sort", "tag",
|
"owner",
|
||||||
"created_at", "updated_at",
|
"status",
|
||||||
is_hidden="os_hidden")
|
"size_min",
|
||||||
|
"size_max",
|
||||||
|
"protected",
|
||||||
|
"is_hidden",
|
||||||
|
"sort_key",
|
||||||
|
"sort_dir",
|
||||||
|
"sort",
|
||||||
|
"tag",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
is_hidden="os_hidden",
|
||||||
|
)
|
||||||
|
|
||||||
# NOTE: Do not add "self" support here. If you've used Python before,
|
# NOTE: Do not add "self" support here. If you've used Python before,
|
||||||
# you know that self, while not being a reserved word, has special
|
# you know that self, while not being a reserved word, has special
|
||||||
|
@ -140,7 +140,10 @@ class TestImage(base.TestCase):
|
|||||||
self.assertTrue(sot.allow_delete)
|
self.assertTrue(sot.allow_delete)
|
||||||
self.assertTrue(sot.allow_list)
|
self.assertTrue(sot.allow_list)
|
||||||
|
|
||||||
self.assertDictEqual({'created_at': 'created_at',
|
self.assertDictEqual(
|
||||||
|
{
|
||||||
|
'created_at': 'created_at',
|
||||||
|
'id': 'id',
|
||||||
'is_hidden': 'os_hidden',
|
'is_hidden': 'os_hidden',
|
||||||
'limit': 'limit',
|
'limit': 'limit',
|
||||||
'marker': 'marker',
|
'marker': 'marker',
|
||||||
@ -158,7 +161,8 @@ class TestImage(base.TestCase):
|
|||||||
'updated_at': 'updated_at',
|
'updated_at': 'updated_at',
|
||||||
'visibility': 'visibility'
|
'visibility': 'visibility'
|
||||||
},
|
},
|
||||||
sot._query_mapping._mapping)
|
sot._query_mapping._mapping,
|
||||||
|
)
|
||||||
|
|
||||||
def test_make_it(self):
|
def test_make_it(self):
|
||||||
sot = image.Image(**EXAMPLE)
|
sot = image.Image(**EXAMPLE)
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
It is now possible to filter ``openstack.image.v2.Image`` resources by ID
|
||||||
|
using the ``id`` filter. While this is of little value when used with
|
||||||
|
single IDs, it can be useful when combined with operators like ``in:``
|
||||||
|
to e.g. filter by multiple image IDs.
|
Loading…
x
Reference in New Issue
Block a user