14 November 2014


Here is official overview.

Glance architecture

What registry does? For code api, it providers CRUD access to images, communicating to DB.

Storage adapter at glance_store project. Cinder, filesystem, RBD, sheepdog, http are supported. There is general store interface at glance_store.driver.py::Store.

VM image: disk format vs container format, refer to here:

  • Disk format is the format of the VM’s disk image.
  • Container format is disk + metadata of actual virtual machine.

Glance does have a queuing system, also tasks and status. See here.

Glance image status transition

P.S. Best ways to gather information for installation & deployment of Openstack components

  • How to install: check Openstack official manuals. This is the BEST reference.
  • Config options: github source /etc/*.conf
  • Search config option name in source code.
  • Search in source code test cases for how to use example.

After play install and architecture diving, a complete review of config options will get you a good understanding on project status and problem to solve.

Nova use glance client to get image information for glance. Downloading image is handled by “download handlers”. Glance is not used in downloading.

# stable/juno
# nova is using glanceclient to communicate to glance
    sesion.download()   # session = GlanceImageService(client=glance_client)
        image = self.show() # using glanceclient
        ... # download image chunks, not using glance
        data = open(dst_path, 'wb')
        for chunk in image_chunks:

Other references

Install and Config

I’ve tried using glance + swift without keystone. Later found out that glance can only get swift address from keystone endpoints. It doesn’t even have a config option to fill in swift address alone. See config.

So in the end I decided to deploy glance alone using file stone. Following official developer doc, and installation manual.

mkdir workspace
cd workspace/
git clone https://github.com/openstack/glance
cd glance
git checkout stable/juno
pip install -r requirements.txt
python setup.py install
cd ..

Create user for glance

useradd -r -s /sbin/nologin glance

Create necessary directories.

# remember to change to proper permission
mkdir /etc/glance
mkdir /var/lib/glance
mkdir /var/lib/glance/image-cache/
mkdir /var/lib/glance/images/
mkdir /var/lib/glance/scrubber
chown -R glance:glance /var/lib/glance
mkdir /var/log/glance
chown -R glance:glance /var/log/glance
mkdir /var/run/glance
chown -R glance:glance /var/run/glance

# copy config files
cp -r glance/etc/* /etc/glance/

For configuration files, refer to github source etc. Below is config file for glance-api.conf. Actually, I recommend copy the modify on official config files, rather than overwrite them like what I do now.

echo '
debug = True
sql_connection = mysql://root:123work@localhost/glance
default_store = file
image_cache_dir = /var/lib/glance/image-cache/
log_file = /var/log/glance/api.log

# here I dont use keystone
flavor =

stores = glance.store.filesystem.Store
' > /etc/glance/glance-api.conf

Configuration file for glance-registry.conf

echo '
debug = True
sql_connection = mysql://root:123work@localhost/glance 
default_store = file
log_file = /var/log/glance/registry.log

# here I dont use keystone
flavor =
' > /etc/glance/glance-registry.conf

Need to create glance table in mysql

... # create table 'glance' in mysql, collation=utf8, and grant proper permission
glance-manage -v db_sync

Start Service

su -s /bin/bash glance -c '/bin/glance-control glance-api start'
su -s /bin/bash glance -c '/bin/glance-control glance-registry start'

# to stop
#su -s /bin/bash glance -c '/bin/glance-control glance-registry stop'
#su -s /bin/bash glance -c '/bin/glance-control glance-api stop'

Verify Operation

First, let’s download the image.

mkdir /tmp/images
cd /tmp/images/
wget http://cdn.download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img

I have to avoid using glanceclient, becuase it force me to authenticate on keystone, which I don’t have now. So I use curl.

# list images, I don't have auth on glance
curl -i -X GET

# send by base64 encode
base64 /root/cirros-0.3.2-x86_64-disk.img | curl --trace - -i -X POST -H 'Content-Transfer-Encoding: base64' -H 'Content-Type: application/octet-stream' -H 'x-image-meta-name: cirros' -H 'x-image-meta-disk_format: qcow2' -H 'x-image-meta-container_format: bare' --data-binary @-

# using glance without keystone, I cannot create public image, nor can I list them detail. So, change image to public in db
mysql -uroot -p -e "use glance; update glance.images set is_public=1;"

# list images again
curl -i -X GET

# to retrieve image metadata
curl -i -X HEAD

# to retrieve image metadata and image data
curl -i -X GET

Show the image data stored. It is in different size of the original one, because of the encoding when upload.

# show glance stored image
$ ll /var/lib/glance/images/
-rw-r----- 1 glance glance 20450682 Nov 14 09:14 7253b5ab-00a1-4bac-9bd4-1c66364a4265

# show original image file
$ ll cirros-0.3.2-x86_64-disk.img
-rw-rw-rw- 1 root root 15138816 Nov  6 09:12 cirros-0.3.2-x86_64-disk.img

API References:

Create an Issue or comment below