[openstack-dev] Is there a way to let nova schedule plugin fetch glance image metadata
Jay Pipes
jaypipes at gmail.com
Thu Aug 14 01:29:36 UTC 2014
On 08/13/2014 08:31 PM, zhiwei wrote:
> Hi all,
>
> We wrote a nova schedule plugin that need to fetch image metadata by
> image_id, but encountered one thing, we did not have the glance context.
>
> Our solution is to configure OpenStack admin user and password to
> nova.conf, as you know this is not good.
>
> So, I want to ask if there are any other ways to do this?
You should not have to do a separate fetch of image metadata in a
scheduler filter (which is what I believe you meant by "plugin" above?).
The filter object's host_passes() method has a filter_properties
parameter that contains the request_spec, that in turn contains the
image, which in turn contains the image "metadata". You can access it
like so:
def host_passes(self, host_state, filter_properties):
request_spec = filter_properties['request_spec']
image_info = request_spec['image']
# Certain image attributes are accessed via top-level keys, like
# size, disk_format, container_format and checksum
image_size = image_info['size']
# Other attributes can be accessed in the "properties" collection
# of key/value pairs
image_props = image.get('properties', {})
for key, value in image_props.items():
# do something...
Best,
-jay
More information about the OpenStack-dev
mailing list