Thanks Jay. The scheduler plugin is not a scheduler filter.
We implemented a scheduler instead of using nova native scheduler. One of our scheduler component need to fetch image metadata by image_id( at this time, there is not instance ). On Thu, Aug 14, 2014 at 9:29 AM, Jay Pipes <[email protected]> wrote: > 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 > > > > _______________________________________________ > OpenStack-dev mailing list > [email protected] > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev >
_______________________________________________ OpenStack-dev mailing list [email protected] http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
