My co-worker and best pal Kevin wrote a script to upload images into OpenStack’s Glance. He recently released the script as the ogler rubygem. It is a straight forward script, built on the ogle library. Our friends at Opscode contacted Kevin, and are planning to distribute it in some fashion.

Uploading directly into Glance allows the setting of metadata, it also avoids the unnecessary steps behind ‘euca-bundle-image’ (object store upload -> unbundle -> Glance upload).

Usage

Install the rubygem:

$ gem install ogler

To upload a x86_64 Ubuntu 11.04 ami and 2.6.35 aki:

$ ogler -i <ami> -k <aki> -a x86_64 -e 2.6.35 -d ubuntu -v 11.04 -h <Glance endpoint>

Attaching additional metadata is as simple as appending key/value pairs:

-c foo=bar,baz=qux

Glance uses decimal ids. Nova converts them to standard ami ids you’re used to, when queried through the EC2 API. To view the metadata we query Glance for the image id:

$ curl -i -X HEAD localhost:9292/v1.0/images/4
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 0
X-Image-Meta-Property-Distro: Ubuntu
X-Image-Meta-Id: 4
X-Image-Meta-Property-Arch: amd64
X-Image-Meta-Deleted: False
X-Image-Meta-Container_format: ami
X-Image-Meta-Property-Uploader: root@enc1b11
X-Image-Meta-Location: file:///var/lib/glance/images/4
X-Image-Meta-Deleted_at: 
X-Image-Meta-Created_at: 2011-05-11T15:48:02
X-Image-Meta-Size: 1476395008
X-Image-Meta-Status: active
X-Image-Meta-Property-Type: machine
X-Image-Meta-Property-Kernel_name: natty-server-uec-amd64-vmlinuz-virtual
X-Image-Meta-Is_public: True
X-Image-Meta-Property-Kernel_id: 3
X-Image-Meta-Updated_at: 2011-05-11T15:48:08
X-Image-Meta-Checksum: b6149317c554d2c335365e7bd43e9bf0
X-Image-Meta-Property-Version: 11.04
X-Image-Meta-Disk_format: ami
X-Image-Meta-Name: ubuntu_11.04-amd64
Location: http://localhost:9292/v1/images/4
Etag: b6149317c554d2c335365e7bd43e9bf0
Date: Sun, 14 Aug 2011 17:57:48 GMT