Cloud, OpenStack

Using Swift backend for Glance on Ubuntu Openstack

This took a bit for me to figure out with Juno so I thought I’d share if you’re interested.

If you use devstack, this happens pretty naturally.  I like to understand things a bit more fully and have been playing around with two old laptops running ubuntu 14.04 and openstack (one is a controller and compute/network, the other compute/network).

I only have one node running glance but both run swift.  Obviously your swift should be up and running. Openstack’s Ubuntu guide does this pretty well.  If you want to setup something a bit more fancy, you can also use the Ubuntu SecurityTeam TestingOpenStack guide (it’s a little dated but still good).

Once you have both swift and glance up, edit the /etc/glance/glance-api.conf

[DEFAULT]

default_store = swift #I don’t think this is needed but doesn’t hurt

[keystone_authtoken]
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = glance_pass
revocation_cache_time = 10

[glance_store]
stores = glance.store.swift.Store
#filesystem_store_datadir = /var/lib/glance/images/
swift_store_auth_version = 2
swift_store_auth_address = http://controller:35357/v2.0/
swift_store_user = service:glance
swift_store_key = glance_pass
swift_store_create_container_on_put = True
swift_store_large_object_size = 5120
swift_store_large_object_chunk_size = 200
swift_enable_snet = False

Notice the auth_address is 35357 for the admin keystone portal? Also note we commented out the filesystem_store_datadir

Also you’ll want to use the glance keystone account and tenant in the store_user section with the password (for the keystone glance account) in the store_key field.

The biggest thing I missed was the stores = glance.store.swift.Store field.  It’s new and not mentioned anywhere I could find except the commented config file.

Go ahead and modify the /etc/glance/glance-registry.conf

[keystone_authtoken]
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = glance
admin_password = glance_pass

and then modify the /etc/glance/glance-cache.conf (I don’t think this is needed but just in case)

swift_store_auth_version = 2
swift_store_auth_address = http://controller:35357/v2.0/
swift_store_user = service:glance
swift_store_key = glance_pass
swift_store_container = glance
swift_store_create_container_on_put = True
swift_store_large_object_size = 5120
swift_store_large_object_chunk_size = 200
swift_enable_snet = False

the glance container should get created automatically since we specified the create_container_on_put command

sudo service glance-api restart
sudo service glance-registry restart

go ahead and create an image and upload it to glance

mkdir -p /tmp/images

. ~/admin-openrc.sh #source the admin creds

wget -P /tmp/images https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
glance image-create --name ubuntu-trusty-x86_64 --disk-format=qcow2 --container-format=bare --file /tmp/images/trusty-server-cloudimg-amd64-disk1.img --progress

glance image-list

we should see the image returned

stack@dell:~$ . admin-openrc.sh
stack@dell:~$ glance image-list
+--------------------------------------+---------------------+-------------+------------------+-----------+--------+
| ID | Name | Disk Format | Container Format | Size | Status |
+--------------------------------------+---------------------+-------------+------------------+-----------+--------+
| db3d6070-0acb-4053-8c9d-277eb090496e | cirros-0.3.3-x86_64 | qcow2 | bare | 13200896 | active |
| 1e7b430c-4aee-43d7-a96e-8a6cab394959 | ubuntu-trusty-x86_64 | qcow2 | bare | 256639488 | active |
+--------------------------------------+---------------------+-------------+------------------+-----------+--------+
stack@dell:~$

Let’s make sure it went into swift though

source the glance user or just export the username/password/tenant and then look in swift

stack@dell:~$ export OS_USERNAME="glance"
stack@dell:~$ export OS_PASSWORD="glance_pass"
stack@dell:~$ export OS_TENANT_NAME="service"
stack@dell:~$ swift list
glance
stack@dell:~$ swift list glance
1e7b430c-4aee-43d7-a96e-8a6cab394959

And that’s it, you’ve now configured swift as your backend.  I’d encourage you to look into using Ceph but I’m holding out until I get another crappy laptop to make 3 nodes (I only have 2). Donations are always welcome!

One thought on “Using Swift backend for Glance on Ubuntu Openstack

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s