[openstack-dev] Is there a way to let nova schedule plugin fetch glance image metadata

Jay Pipes jaypipes at gmail.com
Thu Aug 14 02:28:15 UTC 2014


On 08/13/2014 10:22 PM, zhiwei wrote:
> Thanks Jay.
>
> The scheduler plugin is not a scheduler filter.
>
> We implemented a scheduler instead of using nova native scheduler.

OK. Any reason why you did this? Without any details on what your 
scheduler does, it's tough to give advice on how to solve your problems.

> One of our scheduler component need to fetch image metadata by image_id(
> at this time, there is not instance ).

Why? Again, the request_spec contains all the information you need about 
the image...

Best,
-jay

> On Thu, Aug 14, 2014 at 9:29 AM, Jay Pipes <jaypipes at gmail.com
> <mailto:jaypipes at gmail.com>> 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
>     OpenStack-dev at lists.openstack.__org
>     <mailto:OpenStack-dev at lists.openstack.org>
>     http://lists.openstack.org/__cgi-bin/mailman/listinfo/__openstack-dev <http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev>
>
>
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>




More information about the OpenStack-dev mailing list