Home / Openstack / glance / Openstack – Re-Configure Glance to use swift Storage

Openstack – Re-Configure Glance to use swift Storage

This article will demonstrates that how to re-configure the glance image-service to use backend store as swift object storage. By default , Image service will use the local filesystem to store the images when you are uploading it. The default local filesystem store directory is “/var/lib/glance/images/”  on the system where you have configured the glance image service. In UnixArena tutorial , we have configured the glance image service on Openstack controller node.  The local filesystem store will not be helpful when you try to scale up  your environment.

Glance API will support  the following back-end storage to store and retrieve the images quickly.

Glance backend Storage Description
glance.store.rbd.Store, Ceph Storage
glance.store.s3.Store, Amazon S3
glance.store.swift.Store, Swift Object Storage
glance.store.sheepdog.Store, Sheepdog  Storage
glance.store.cinder.Store, Cinder Volume Storage
glance.store.gridfs.Store, GridFS Storage
glance.store.vmware_datastore.Store, VMware Datastore
glance.store.filesystem.Store, Local filesystem (Default – /var/lib/glance/images/)
glance.store.http.Store HTTP store ( URL )

 

 

Re-configure Glance Image API service to use Swift Storage:

 

Environment Details :

  • Controller Node name – OSCTRL-UA
  • Glance service user – glance
  • Glance service users password – glance123
  • Operating System – Ubuntu 14.04 TLS
  • Openstack Version – Juno

 

root@OSCTRL-UA:~# keystone service-list
+----------------------------------+------------+----------------+--------------------------+
|                id                |    name    |      type      |       description        |
+----------------------------------+------------+----------------+--------------------------+
| d4371a7560d243bcb48e9db4d49ce7e1 | ceilometer |    metering    |        Telemetry         |
| 7a90b86b3aab43d2b1194172a14fed79 |   cinder   |     volume     | OpenStack Block Storage  |
| 716e7125e8e44414ad58deb9fc4ca682 |  cinderv2  |    volumev2    | OpenStack Block Storage  |
| ee22977db7d84566a4c2217d48859001 |   glance   |     image      | OpenStack Image Service  |
| 59585bbaa4e04d2394df4a66e13993bf |    heat    | orchestration  |      Orchestration       |
| eefe2c1b881d431f83a5411ac7bfb20c |  heat-cfn  | cloudformation |      Orchestration       |
| cfa2859138ae4549919cbf2bfd06346f |  keystone  |    identity    |    OpenStack Identity    |
| 1d40c9c73ee64522a181bd6310efdf0b |  neutron   |    network     |   OpenStack Networking   |
| 083b455a487647bbaa05a4a53b3a338f |    nova    |    compute     |    OpenStack Compute     |
| 233aa2e309a142e188424ecbb41d1e07 |   swift    |  object-store  | OpenStack Object Storage |
+----------------------------------+------------+----------------+--------------------------+
root@OSCTRL-UA:~# keystone endpoint-list
+----------------------------------+-----------+---------------------------------------------+---------------------------------------------+----------------------------------------+----------------------------------+
|                id                |   region  |                  publicurl                  |                 internalurl                 |                adminurl                |            service_id            |
+----------------------------------+-----------+---------------------------------------------+---------------------------------------------+----------------------------------------+----------------------------------+
| 4e2f418ef1eb4083a655e0a4eb60b736 | regionOne |    http://OSCTRL-UA:8774/v2/%(tenant_id)s   |    http://OSCTRL-UA:8774/v2/%(tenant_id)s   | http://OSCTRL-UA:8774/v2/%(tenant_id)s | 083b455a487647bbaa05a4a53b3a338f |
| 5f0dfb2bdbb7483fa2d6165cf4d86ccc | regionOne |            http://OSCTRL-UA:9696            |            http://OSCTRL-UA:9696            |         http://OSCTRL-UA:9696          | 1d40c9c73ee64522a181bd6310efdf0b |
| 6a86eec28e434481ba88a153f53bb8c2 | regionOne |    http://OSCTRL-UA:8776/v1/%(tenant_id)s   |    http://OSCTRL-UA:8776/v1/%(tenant_id)s   | http://OSCTRL-UA:8776/v1/%(tenant_id)s | 7a90b86b3aab43d2b1194172a14fed79 |
| 6b9825bbe27c4f978f17b3219c1579e4 | regionOne |    http://OSCTRL-UA:8776/v1/%(tenant_id)s   |    http://OSCTRL-UA:8776/v1/%(tenant_id)s   | http://OSCTRL-UA:8776/v1/%(tenant_id)s | 716e7125e8e44414ad58deb9fc4ca682 |
| 75117db38ebc4868a69fc6b7e14fc054 | regionOne |    http://OSCTRL-UA:8004/v1/%(tenant_id)s   |    http://OSCTRL-UA:8004/v1/%(tenant_id)s   | http://OSCTRL-UA:8004/v1/%(tenant_id)s | 59585bbaa4e04d2394df4a66e13993bf |
| 7dbbfe1b14c343048c01e672426154ed | regionOne |          http://OSCTRL-UA:5000/v2.0         |          http://OSCTRL-UA:5000/v2.0         |      http://OSCTRL-UA:35357/v2.0       | cfa2859138ae4549919cbf2bfd06346f |
| 7f9042c48a5f401c8dd734e4047ced96 | regionOne | http://OSCTRL-UA:8080/v1/AUTH_%(tenant_id)s | http://OSCTRL-UA:8080/v1/AUTH_%(tenant_id)s |         http://OSCTRL-UA:8080          | 233aa2e309a142e188424ecbb41d1e07 |
| 8a15369cd2e14aa199b4f60881169a1b | regionOne |           http://OSCTRL-UA:8000/v1          |           http://OSCTRL-UA:8000/v1          |        http://OSCTRL-UA:8000/v1        | eefe2c1b881d431f83a5411ac7bfb20c |
| b17e1f61815e4f83abf3606d1a7b3764 | regionOne |            http://OSCTRL-UA:9292            |            http://OSCTRL-UA:9292            |         http://OSCTRL-UA:9292          | ee22977db7d84566a4c2217d48859001 |
| b4534beb489d45af8af3aa62ede17053 | regionOne |            http://OSCTRL-UA:8777            |            http://OSCTRL-UA:8777            |         http://OSCTRL-UA:8777          | d4371a7560d243bcb48e9db4d49ce7e1 |
+----------------------------------+-----------+---------------------------------------------+---------------------------------------------+----------------------------------------+----------------------------------+
root@OSCTRL-UA:~#

 

1. Login to controller node. (Where you have configured the glance image service).

 

2. Edit the “/etc/glance/glance-api.conf” and update the sections like below.

  • In the [DEFAULT] section ,

Existing Value:

default_store = file

Change to the new value,

default_store = swift

 

  • In the “[glance_store]” section , enable the stores value as swift.

Existing Value:

#stores = glance.store.filesystem.Store,

Change to the new value,

stores = glance.store.swift.Store

 

  • Comment out “filesystem_store_datadir” option.

Existing Value:

filesystem_store_datadir = /var/lib/glance/images/

Change to the new value,

 # filesystem_store_datadir = /var/lib/glance/images/

 

  • Update the swift store options.

Existing Value: (Not used)

 swift_store_auth_address = 127.0.0.1:5000/v2.0/
 swift_store_user = jdoe:jdoe
 swift_store_key = a86850deb2742ec3cb41518e26aa2d89
 swift_store_create_container_on_put = False

Change to the new value,

swift_store_auth_address = http://OSCTRL-UA:35357/v2.0/ 
swift_store_user = service:glance                       
swift_store_key = glance123                             
swift_store_create_container_on_put = True

 

Here is the difference between previous configuration and new one.

root@OSCTRL-UA:~# sdiff -s /etc/glance/glance-api.conf /etc/glance/glance-api.conf.filesystem.Store
default_store = swift                                         | default_store = file
stores = glance.store.swift.Store                             | #stores = glance.store.filesystem.Store,
#          glance.store.filesystem.Store,                     <
#filesystem_store_datadir = /var/lib/glance/images/           | filesystem_store_datadir = /var/lib/glance/images/
swift_store_auth_address = http://OSCTRL-UA:35357/v2.0/       | swift_store_auth_address = 127.0.0.1:5000/v2.0/
swift_store_user = service:glance                             | swift_store_user = jdoe:jdoe
swift_store_key = glance123                                   | swift_store_key = a86850deb2742ec3cb41518e26aa2d89
swift_store_create_container_on_put = True                    | swift_store_create_container_on_put = False
root@OSCTRL-UA:~#

 

3. Restart the glance api and registry service.

root@OSCTRL-UA:~# service glance-registry restart
glance-registry stop/waiting
glance-registry start/running, process 50894

root@OSCTRL-UA:~# service glance-api restart
glance-api stop/waiting
glance-api start/running, process 50908
root@OSCTRL-UA:~#

 

4. Source the admin credentials to gain access to CLI commands.

root@OSCTRL-UA:~# cat admin.rc
export OS_USERNAME=admin
export OS_PASSWORD=admin123
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://OSCTRL-UA:35357/v2.0
root@OSCTRL-UA:~# source admin.rc
root@OSCTRL-UA:~#

 

5. Verify the operation by creating the new glance image.

root@OSCTRL-UA:~# ls -lrt cirros-0.3.4-x86_64-disk.img
-rw-r--r-- 1 root root 13287936 May  7 22:18 cirros-0.3.4-x86_64-disk.img
root@OSCTRL-UA:~# glance image-create --name="CIRROS-NEW5" --disk-format=qcow2 --container-format=bare --is-public=true < cirros-0.3.4-x86_64-disk.img
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6     |
| container_format | bare                                 |
| created_at       | 2015-10-23T02:07:14                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | c7f5c590-b6e8-4083-8648-2066cdc46348 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | CIRROS-NEW5                          |
| owner            | d14d6a07f862482398b3e3e4e8d581c6     |
| protected        | False                                |
| size             | 13287936                             |
| status           | active                               |
| updated_at       | 2015-10-23T02:07:15                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+

 

6. List the newly created image using glance command.

root@OSCTRL-UA:~# glance image-list
+--------------------------------------+-------------+-------------+------------------+----------+--------+
| ID                                   | Name        | Disk Format | Container Format | Size     | Status |
+--------------------------------------+-------------+-------------+------------------+----------+--------+
| c7f5c590-b6e8-4083-8648-2066cdc46348 | CIRROS-NEW5 | qcow2       | bare             | 13287936 | active |
+--------------------------------------+-------------+-------------+------------------+----------+--------+
root@OSCTRL-UA:~#

 

7. Do you would like to see the image file from swift storage ?  Here you go.  By default swift will create the container called “glance” for image service. (By using defined value “swift_store_create_container_on_put = True”)

root@OSCTRL-UA:~# swift --os-auth-url http://OSCTRL-UA:5000/v2.0 --os-tenant-name service --os-username glance --os-password glance123 list glance
c7f5c590-b6e8-4083-8648-2066cdc46348
root@OSCTRL-UA:~#

You can see that file name is  matching with glance image list ID.

 

Hope this article is informative to you . Share it ! Be Sociable !!!

VMTURBO-CLOUD-CAPACITY

One comment

  1. hi There,

    it’s not working for me getting below error in log file. suggest please.

    ERROR glance_store._drivers.swift.store [-] A value for swift_store_auth_address is required.
    2016-05-10 20:20:59.112 20091 WARNING glance_store.driver [-] Failed to configure store correctly: A value for swift_store_auth_address is required. Disabling add method.
    2016-05-10 20:21:00.155 20103 WARNING keystonemiddleware.auth_token [-] Use of the auth_admin_prefix, auth_host, auth_port, auth_protocol, identity_uri, admin_token, admin_user, admin_password, and admin_tenant_name configuration options is deprecated in favor of auth_plugin and related options and may be removed in a future release.

Leave a Reply

Your email address will not be published. Required fields are marked *