[glance] Listing all images with a set of custom properties

Brian Rosmaita rosmaita.fossdev at gmail.com
Thu Apr 11 13:41:50 UTC 2019

On 4/10/19 8:42 PM, Nadathur, Sundar wrote:
> I am looking for a way to programmatically get all images that have been
> associated with a set of custom properties. Ideally, I should be able to
> say 'give me all images that have key1=value1, key2=value2, etc.

Create a dict of the properties you are interested in, for example,

  filters = {'key1': 'value1', 'key2': 'value2'}

and then pass it as the value of the 'filters' argument to the 'list' call:

  image_list_generator = glance.list(filters=filters)

You can have both "regular" and custom image properties as keys in the
filters dict.

> Failing that, at least get all images that have the named keys key1,
> key2, etc. irrespective of their values, so I can filter for the values
> myself.

I don't think there's a way to do this, actually.  I'm pretty sure it's
not supported by the Images API.

> I was looking at [1], specifically [2], and came up short. Any
> recommendations?
> [1]
> https://github.com/openstack/python-glanceclient/tree/master/glanceclient/v2
> [2]
> https://github.com/openstack/python-glanceclient/blob/master/glanceclient/v2/images.py#L86

It shows up a bit later:

> Regards,
> Sundar


More information about the openstack-discuss mailing list