Sep 072015
 
OpenStack Logo
OpenStack Logo

This post guides you to configure OpenStack image service, code-named Glance, on the controller node. We will configure glance to store images locally on the controller node. Before going ahead make sure you have configured KeyStone service.

If you have not configured KeyStone yet, you can go through the below two posts.

OpenStack Kilo on Ubuntu 14.04.2- Configure KeyStone #1

OpenStack Kilo on Ubuntu 14.04.2- Configure KeyStone #2

Create a client environment script for admin and demo user, these scripts will help us to load appropriate credential for client operations.

Create the admin-openrc.sh file.

# nano admin-openrc.sh

Paste the following content onto the file.

export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=password
export OS_AUTH_URL=http://controller:35357/v3

Replace password with the password that you created for admin user in KeyStone #2

Create the demo-openrc.sh file.

# nano demo-openrc.sh

Paste the below content onto the file.

export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=demo
export OS_TENANT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=password
export OS_AUTH_URL=http://controller:5000/v3

Replace password with the password that you created for demo user in KeyStone #2.

Prerequisites:

Login as root into to MySQL database server.

# mysql -u root -p

Create the database for glance.

CREATE DATABASE glance;

Set proper access to the glance database.

GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'password';

Replace password with suitable password.

Load admin credentials.

# source admin-openrc.sh

Create the glance user.

# openstack user create --password-prompt glance
User Password:
Repeat User Password:
+----------+----------------------------------+
| Field    | Value                            |
+----------+----------------------------------+
| email    | None                             |
| enabled  | True                             |
| id       | f4bed648d59f44bfa31d9bb670fa7bc2 |
| name     | glance                           |
| username | glance                           |
+----------+----------------------------------+

Add the admin role to the glance user and service project.

# openstack role add --project service --user glance admin
+-------+----------------------------------+
| Field | Value                            |
+-------+----------------------------------+
| id    | 33af4f957aa34cc79451c23bf014af6f |
| name  | admin                            |
+-------+----------------------------------+

Create the glance service entity.

# openstack service create --name glance --description "OpenStack Image service" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image service          |
| enabled     | True                             |
| id          | f75a73447c504fceb4cdf898a9033d81 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

Create the API endpoint for glance.

# openstack endpoint create \
--publicurl http://controller:9292 \
--internalurl http://controller:9292 \
--adminurl http://controller:9292 \
--region RegionOne \
image

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| adminurl     | http://controller:9292           |
| id           | e38a6ecf4f9347a29026706719ef2988 |
| internalurl  | http://controller:9292           |
| publicurl    | http://controller:9292           |
| region       | RegionOne                        |
| service_id   | f75a73447c504fceb4cdf898a9033d81 |
| service_name | glance                           |
| service_type | image                            |
+--------------+----------------------------------+

Install and Configure glance:

Install the packages.

# apt-get install glance python-glanceclient

Edit the /etc/glance/glance-api.conf, modify the below settings and make sure to place a entries in the proper sections.

[DEFAULT]
...
notification_driver = noop
verbose = True

[database]
...
connection = mysql://glance:password@controller/glance
## Replace with the password you chose for glance database

[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = password
## Replace this with the password you chose for glance user in the identity service.

[paste_deploy]
...
flavor = keystone

[glance_store]
...
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

Edit the /etc/glance/glance-registry.conf file, modify the below settings and make sure to place a entries in the proper sections.

[DEFAULT]
...
notification_driver = noop
verbose = True

[database]
...
connection = mysql://glance:password@controller/glance
## Replace with the password you chose for glance database

[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = password
## Repalce this with the password you chose for glance user in the identity service

[paste_deploy]
...
flavor = keystone

Populate the glance database.

# su -s /bin/sh -c "glance-manage db_sync" glance

Restart the services.

# service glance-registry restart
# service glance-api restart

Delete the SQLite database file.

# rm -f /var/lib/glance/glance.sqlite

Verify operation:

In this, we will verify the image service by uploading cloud image of Fedora 22 on to our OpenStack environment.

In our client environment script, we will configure Image service client to use API version 2.0:

# echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh

Load admin credentials.

# source admin-openrc.sh

Download Fedora 22 cloud image on /tmp directory.

# cd /tmp

# wget https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.qcow2

Upload the image.

#  glance image-create --name "Fedora-Cloud-Base-22-20150521.x86_64" --file /tmp/Fedora-Cloud-Base-22-20150521.x86_64.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress

You will get a below output.

[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 18abc933d17f69d55ecea0d19f8f5c71     |
| container_format | bare                                 |
| created_at       | 2015-06-28T17:42:59Z                 |
| disk_format      | qcow2                                |
| id               | a1533d87-d6fa-4d9d-bf85-6b2ab8400712 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Fedora-Cloud-Base-22-20150521.x86_64 |
| owner            | 9b05e6bffdb94c8081d665561d05e31e     |
| protected        | False                                |
| size             | 228599296                            |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2015-06-28T17:43:27Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+

List the uploaded images.

# glance image-list
+--------------------------------------+--------------------------------------+
| ID                                   | Name                                 |
+--------------------------------------+--------------------------------------+
| a1533d87-d6fa-4d9d-bf85-6b2ab8400712 | Fedora-Cloud-Base-22-20150521.x86_64 |
+--------------------------------------+--------------------------------------+

That’s All!!!, you have successfully confugured Glance. Next is to configure Nova (Compute).