We want to retrieve that actual raw data for a specific virtual machine image that the Glance server knows about.

We have queried the Glance server for a list of public images and the data returned includes the `uri` field for each available image. This `uri` field value contains the exact location needed to get the metadata for a specific image.

Continuing the example from above, in order to get both the metadata about the first public image returned and its image data, we can use the following code

..code-block:: python

from glance.client import Client

c = Client("glance.example.com", 9292)

meta, image_file = c.get_image("http://glance.example.com/images/1")

print meta

f = open('some_local_file', 'wb') for chunk in image_<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="file:">file:</link> f.write(chunk) f.close()

[Note]Note

The return from Client.get_image() is a tuple of (`metadata`, `file`) where `metadata` is a mapping of metadata about the image and `file` is a generator that yields chunks of image data.



loading table of contents...