Use OpenStack Swift as a Backend Store for Glance

• Updated May 10, 2017


By default, OpenStack Glance saves images and OpenStack Instance snapshots to its local filesystem at /var/lib/glance/images/.

However, if you have a Swift Cluster, you can just as easily use it to save images and snapshots instead of to the local filesystem where Glance is running.

Begin by logging in to the node running the Glance services (probably your controller node also running Keystone) as root and source your OpenStack credentials (this is typically a file named openrc).

source ~/openrc

Verify the user glance is part of tenant service with role admin.

keystone user-role-list --user glance --tenant service

One of the roles returned should be admin.

Open /etc/glance/glance-api.conf and comment out the following two lines:

##### DEFAULT OPTIONS #####
#default_store = file
#filesystem_store_datadir = /var/lib/glance/images/

With /etc/glance/glance-api.conf still open, append the following lines to the DEFAULT OPTIONS section (be sure to set the values inside < > to match your environment):

default_store = swift
swift_store_auth_address = http://<IP_OF_KEYSTONE>:35357/v2.0/
swift_store_user = service:glance
swift_store_key = <VALUE OF __admin_password__ ATTRIBUTE IN __/etc/glance/glance-api.conf__>
swift_store_create_container_on_put = True

With the configuration changes in place, restart the Glance services.

If you are running CentOS/RHEL:

service openstack-glance-api restart

service openstack-glance-registry restart

If you are running Ubuntu:

service glance-api restart

service glance-registry restart

Now you should be able to upload an image to Glance through the Horizon Dashboard or using the glance command and instead of it being saved to /var/lib/glance/images, it will be saved in a Swift Container called glance in the service account.

Verify nothing is saved in /var/lib/glance/images by simply running ls /var/lib/glance/images on the server where Glance is running (if you did not delete any existing Glance Images, they will still be there).

Once the Horizon Dashboard or the glance image-list reports the image is active, you can verify the images are in Swift by running the following command (be sure to set the values inside < > to match your environment):

swift --os-auth-url http://<IP_OF_KEYSTONE>:5000/v2.0 --os-tenant-name service --os-username glance --os-password <PASSWORD USED IN swift_store_key ABOVE> list glance

References

If you found this post useful, you can help support this site and get something for yourself by signing up for any of the services listed below through the provided links.

The following links are part of affiliate programs, and I will receive a referral payment from any of the services you sign-up for.

  • Get Faster Shipping: Perhaps you're about to order some stuff on Amazon but want to get more value out of the money you would normally pay for shipping. Sign-up for a free, 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.
  • Start Investing Now: Are you looking to start investing some of your disposable saved income? Get started by opening an account with Webull, where upon sign-up and opening a brokerage account with an initial deposit of at least $100 you will receive 1 stock valued (subject to change based on normal market movement) between $8 and $1600.

Thanks for reading and take care.