When adding an actual virtual machine image to Glance, you use
the add command. You will pass metadata about
the VM image on the command line, and you will use a standard
shell redirect to stream the image data file to
glance.
Let's walk through a simple example. Suppose we have a virtual
disk image stored on our local filesystem that we wish to
"upload" to Glance. This image is stored on our local
filesystem in /tmp/images/myimage.iso.
We'd also like to tell Glance that this image should be called "My Image", and that the image should be public -- anyone should be able to fetch it.
Here is how we'd upload this image to Glance. Change example ip number to your server ip number.:
$> glance add name="My Image" is_public=true < /tmp/images/myimage.iso --host=65.114.169.29
If Glance was able to successfully upload and store your VM image data and metadata attributes, you would see something like this:
$> glance add name="My Image" is_public=true < /tmp/images/myimage.iso --host=65.114.169.29 Added new image with ID: 2
You can use the --verbose (or
-v) command-line option to print some more
information about the metadata that was saved with the image:
$> glance --verbose add name="My Image" is_public=true < /tmp/images/myimage.iso --host=65.114.169.29
Added new image with ID: 4
Returned the following metadata for the new image:
container_format => ovf
created_at => 2011-02-22T19:20:53.298556
deleted => False
deleted_at => None
disk_format => raw
id => 4
is_public => True
location => file:///tmp/images/4
name => My Image
properties => {}
size => 58520278
status => active
updated_at => None
Completed in 0.6141 sec.
If you are unsure about what will be added, you can use the
--dry-run command-line option, which will
simply show you what would have happened:
$> glance --dry-run add name="Foo" distro="Ubuntu" is_publi=True < /tmp/images/myimage.iso --host=65.114.169.29
Dry run. We would have done the following:
Add new image with metadata:
container_format => ovf
disk_format => raw
is_public => False
name => Foo
properties => {'is_publi': 'True', 'distro': 'Ubuntu'}
This is useful for detecting problems and for seeing what the
default field values supplied by glance are.
For instance, there was a typo in the command above (the
is_public field was incorrectly spelled
is_publi which resulted in the image having
an is_publi custom property added to the
image and the real
is_public field value being `False` (the
default) and not `True`...
