<div dir="ltr">Hi Jay.<div><br></div><div>The case is: When heat create a stack, it will first call our scheduler(will pass image_id), our scheduler will get image metadata by image_id.</div><div><br></div><div>Our scheduler will build a placement policy through image metadata, then start booting VM.</div>
<div><br></div><div><br></div><div>Thanks.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 14, 2014 at 10:28 AM, Jay Pipes <span dir="ltr"><<a href="mailto:jaypipes@gmail.com" target="_blank">jaypipes@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On 08/13/2014 10:22 PM, zhiwei wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks Jay.<br>
<br>
The scheduler plugin is not a scheduler filter.<br>
<br>
We implemented a scheduler instead of using nova native scheduler.<br>
</blockquote>
<br></div>
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.<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
One of our scheduler component need to fetch image metadata by image_id(<br>
at this time, there is not instance ).<br>
</blockquote>
<br></div>
Why? Again, the request_spec contains all the information you need about the image...<br>
<br>
Best,<br>
-jay<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
On Thu, Aug 14, 2014 at 9:29 AM, Jay Pipes <<a href="mailto:jaypipes@gmail.com" target="_blank">jaypipes@gmail.com</a><br></div><div class="">
<mailto:<a href="mailto:jaypipes@gmail.com" target="_blank">jaypipes@gmail.com</a>>> wrote:<br>
<br>
On 08/13/2014 08:31 PM, zhiwei wrote:<br>
<br>
Hi all,<br>
<br>
We wrote a nova schedule plugin that need to fetch image metadata by<br>
image_id, but encountered one thing, we did not have the glance<br>
context.<br>
<br>
Our solution is to configure OpenStack admin user and password to<br>
nova.conf, as you know this is not good.<br>
<br>
So, I want to ask if there are any other ways to do this?<br>
<br>
<br>
You should not have to do a separate fetch of image metadata in a<br>
scheduler filter (which is what I believe you meant by "plugin" above?).<br>
<br>
The filter object's host_passes() method has a filter_properties<br>
parameter that contains the request_spec, that in turn contains the<br>
image, which in turn contains the image "metadata". You can access<br>
it like so:<br>
<br>
def host_passes(self, host_state, filter_properties):<br></div>
request_spec = filter_properties['request___<u></u>spec']<div class=""><br>
image_info = request_spec['image']<br>
# Certain image attributes are accessed via top-level keys, like<br>
# size, disk_format, container_format and checksum<br>
image_size = image_info['size']<br>
# Other attributes can be accessed in the "properties" collection<br>
# of key/value pairs<br>
image_props = image.get('properties', {})<br>
for key, value in image_props.items():<br>
# do something...<br>
<br>
Best,<br>
-jay<br>
<br>
<br>
<br></div>
______________________________<u></u>___________________<br>
OpenStack-dev mailing list<br>
OpenStack-dev@lists.openstack.<u></u>__org<br>
<mailto:<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.<u></u>openstack.org</a>><br>
<a href="http://lists.openstack.org/__cgi-bin/mailman/listinfo/__openstack-dev" target="_blank">http://lists.openstack.org/__<u></u>cgi-bin/mailman/listinfo/__<u></u>openstack-dev</a> <<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/<u></u>cgi-bin/mailman/listinfo/<u></u>openstack-dev</a>><div class="">
<br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.<u></u>org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/<u></u>cgi-bin/mailman/listinfo/<u></u>openstack-dev</a><br>
<br>
</div></blockquote><div class="HOEnZb"><div class="h5">
<br>
<br>
______________________________<u></u>_________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.<u></u>org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/<u></u>cgi-bin/mailman/listinfo/<u></u>openstack-dev</a><br>
</div></div></blockquote></div><br></div>