OpenStack Liberty on Ubuntu 14.04 LTS – Configure Glance

0
OpenStack Liberty on Ubuntu 14.04 LTS – Configure Glance
OpenStack Liberty on Ubuntu 14.04 LTS – Configure Glance

Glance accepts API requests for disk or server images, and image metadata from end users or OpenStack Compute. It also supports the storage of disk or server images on various repository types, including OpenStack Object Storage.

This post guides you to configure OpenStack image service (Glance) on the controller node. We will configure a 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=PASS_ADMIN
export OS_AUTH_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3

Replace PASS_ADMIN 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=PASS_DEMO
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3

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

Create Glance Database:

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.

Exit from the MySQL prompt.

Create service credentials, and API endpoints:

Load admin credentials.

# source admin-openrc.sh

Create the glance user.

# openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | default                          |
| enabled   | True                             |
| id        | ca01105cf73945ce9e93dae68158a86e |
| name      | glance                           |
+-----------+----------------------------------+

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

# openstack role add --project service --user glance 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          | 728c9fe5ae474c6dbd943aa8f1727a49 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

Create the API endpoint for glance.

# openstack endpoint create --region RegionOne image public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 5125e46d88f047f7944c86224576b3a3 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 728c9fe5ae474c6dbd943aa8f1727a49 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

# openstack endpoint create --region RegionOne image internal http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 7ade8b978fc2498eabf6d5ca62f1cdb7 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 728c9fe5ae474c6dbd943aa8f1727a49 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

# openstack endpoint create --region RegionOne image admin http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | d9933de493c44e8c9d3b2a515b400cb3 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 728c9fe5ae474c6dbd943aa8f1727a49 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

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 an entries in the proper sections.

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

[database]
...
## Comment out below sqlite_db
#sqlite_db = /var/lib/glance/glance.sqlite
connection = mysql+pymysql://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]
...
## Comment out below sqlite_db
#sqlite_db = /var/lib/glance/glance.sqlite
connection = mysql+pymysql://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

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 Ubuntu cloud image on /tmp directory.

# cd /tmp

# wget http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img

Upload the image.

# glance image-create --name "Ubuntu_Trusty_Cloud_x86_64" --file /tmp/trusty-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare --visibility public --progress

You will get a below output.

[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | fefdbde09433b879198e58ef69471fab     |
| container_format | bare                                 |
| created_at       | 2015-11-02T16:27:39Z                 |
| disk_format      | qcow2                                |
| id               | 489ece19-2ab3-4105-9a3a-befa974dff38 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Ubuntu_Trusty_Cloud_x86_64           |
| owner            | fe858f6a43f84c26b994f0be74c928e6     |
| protected        | False                                |
| size             | 258540032                            |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2015-11-02T16:27:47Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+

List the uploaded images.

# glance image-list
+--------------------------------------+----------------------------+
| ID                                   | Name                       |
+--------------------------------------+----------------------------+
| 489ece19-2ab3-4105-9a3a-befa974dff38 | Ubuntu_Trusty_Cloud_x86_64 |
+--------------------------------------+----------------------------+

That’s All!!!, you have successfully configured Glance.

You might also like