(Last Updated On: June 27, 2016)

Glance is image service which enables users to discover, register, and retrieve virtual machine images.
I assume you installed glance openstack image service in Part one of this Lab series, if you didn’t, go back and do it first.The link can be found from what we’ve covered so far:

Openstack Liberty Lab PART ONE: Setup Networking and all Prerequisites

Openstack Liberty Lab PART TWO: Install Openstack Packages

Openstack Liberty Lab PART THREE: Configuring Keystone identity service

Steps for configuring Glance image service are:

  1. Add user and database required by glance service.
[[email protected] ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 17
Server version: 5.5.44-MariaDB MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. 
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. 
MariaDB [(none)]> create database glance;
Query OK, 1 row affected (0.00 sec) 
MariaDB [(none)]> grant all privileges on glance.* to [email protected]'localhost' identified by 'moonstack';
Query OK, 0 rows affected (0.00 sec) 
MariaDB [(none)]> grant all privileges on glance.* to [email protected]'%' identified by 'moonstack';
Query OK, 0 rows affected (0.00 sec) 
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye

moonstack : Replace with desired glance user password.

  1. Add glance user and assign user Admin role:
[[email protected] ~]# openstack user create --domain default --project service --password moonstack glance
+--------------------+----------------------------------+
| Field | Value | 
+--------------------+----------------------------------+
| default_project_id | 9c3ec09f5e08442eb211612f99cd22ad |
| domain_id | default |
| enabled | True |
| id | 468470e8892343779e638e97d151197f | 
| name | glance |
+--------------------+----------------------------------+
[[email protected] ~]# openstack role add --project service --user glance admin 
[[email protected] ~]#
  1. Crete Glance service entry
[[email protected] ~]# openstack service create --name glance --description "OpenStack Image service" image 
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image service |
| enabled | True |
| id | a55210ba42074c36856d49a90cd5795d |
| name | glance |
| type | image |
+-------------+----------------------------------+

[[email protected] ~]# 
  1. Create endpoints for glance image service; internal,admin and public:
[[email protected] ~]# export controller=192.168.1.60 
[[email protected] ~]# openstack endpoint create --region RegionOne image public http://$controller:9292 
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 23fd8f981f504d7e9cce0df5a5a865a5 | 
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a55210ba42074c36856d49a90cd5795d |
| service_name | glance | 
| service_type | image |
| url | http://192.168.1.60:9292 |
+--------------+----------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne image internal http://$controller:9292 
+--------------+-------------------------------------------------+
| Field | Value |
+--------------+-------------------------------------------------+
| enabled | True |
| id | 2405df88c0024905b381dedec31af38e |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a55210ba42074c36856d49a90cd5795d |
| service_name | glance |
| service_type | image |
| url | http://192.168.1.60:9292 | 
+--------------+---------------------------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne image admin http://$controller:9292 
+--------------+-------------------------------------------+
| Field | Value | 
+--------------+-------------------------------------------+
| enabled | True |
| id | 681d673dc4384fb09874e41b1f40e9d1 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a55210ba42074c36856d49a90cd5795d |
| service_name | glance |
| service_type | image |
| url | http://192.168.1.60:9292 |
+--------------+--------------------------------------------+
[[email protected] ~]#
  1. Confirm settings:
[[email protected] ~]# openstack service list
+----------------------------------+----------+----------+
| ID | Name | Type |
+----------------------------------+----------+----------+
| 4d3aa109aa534ceb92187549a5e728bf | keystone | identity |
| a55210ba42074c36856d49a90cd5795d | glance | image |
+----------------------------------+----------+----------+
[[email protected] ~]# openstack endpoint list
+----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+
| ID | Region | Service Name | Service Type | Enabled | Interface | URL |
+----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+
| 23fd8f981f504d7e9cce0df5a5a865a5 | RegionOne | glance | image | True | public | http://192.168.1.60:9292 |
| 2405df88c0024905b381dedec31af38e| RegionOne | glance | image | True | internal | http://192.168.1.60:9292 |
| 651d5f5fc4bb4d6db1b74b217b6fcda5 | RegionOne | keystone | identity | True | public | http://192.168.1.60:5000/v2.0 |
| 681d673dc4384fb09874e41b1f40e9d1 | RegionOne | glance | image | True | admin | http://192.168.1.60:9292 |
| 81b112cbfbd949578262a4fd3ebce9fd | RegionOne | keystone | identity | True | admin | http://192.168.1.60:35357/v2.0 |
| f714e382f39748afaf8bd2d5e0054c24 | RegionOne | keystone | identity | True | internal | http://192.168.1.60:5000/v2.0 |
+----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+
[[email protected] ~]#
  1. Glance configuration,
  • Writing /etc/glance/glance-registry.conf configurations :
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf database connection mysql://glance:[email protected]/glance
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://192.168.1.60:5000
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://192.168.1.60:35357
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_plugin password
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_id default
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_id default
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password moonstack
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
[[email protected] ~]# openstack-config --set /etc/glance/glance-registry.conf DEFAULT notification_driver noop
  • Writing to /etc/glance/glance-api.conf file
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf database  connection  mysql://glance:[email protected]/glance
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  auth_uri http://192.168.1.60:5000
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  auth_url http://192.168.1.60:35357
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  auth_plugin  password
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  project_domain_id  default
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  user_domain_id default
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  project_name service
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  username glance
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  password  moonstack
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
[[email protected] ~]# openstack-config --set /etc/glance/glance-api.conf DEFAULT notification_driver noop
[[email protected] ~]# 

moonstack on keystone_authtoken section: Replace with password you chose for the glance user in the Identity service.
192.168.1.60: Ip address of server/controller
moonstack on database section: is equivalent to password you chose for the Image service database.

  1. Populate the Image service database:
[[email protected] ~]# su -s /bin/sh -c "glance-manage db_sync" glance
  1. Start the Image services and configure them to start when the system boots:
[[email protected] ~]# systemctl enable openstack-glance-api.service openstack-glance-registry.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service.
[[email protected] ~]# 
[[email protected] ~]# systemctl start openstack-glance-api.service openstack-glance-registry.service

Check status of both openstack-glance-api.service and openstack-glance-registry.service

[[email protected] ~]# systemctl status openstack-glance-api.service openstack-glance-registry.service
openstack-glance-api.service – OpenStack Image Service (code-named Glance) API server
Loaded: loaded (/usr/lib/systemd/system/openstack-glance-api.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2016-03-28 18:25:58 EAT; 25s ago
Main PID: 27278 (glance-api)
CGroup: /system.slice/openstack-glance-api.service

├─27278 /usr/bin/python2 /usr/bin/glance-api
├─27300 /usr/bin/python2 /usr/bin/glance-api
├─27301 /usr/bin/python2 /usr/bin/glance-api
├─27302 /usr/bin/python2 /usr/bin/glance-api
└─27303 /usr/bin/python2 /usr/bin/glance-api

Mar 28 18:25:56 controller systemd[1]: Starting OpenStack Image Service (code-named Glance) API server…
Mar 28 18:25:57 controller glance-api[27278]: No handlers could be found for logger “oslo_config.cfg”
Mar 28 18:25:58 controller systemd[1]: Started OpenStack Image Service (code-named Glance) API server.
openstack-glance-registry.service – OpenStack Image Service (code-named Glance) Registry server
Loaded: loaded (/usr/lib/systemd/system/openstack-glance-registry.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2016-03-28 18:25:57 EAT; 26s ago
Main PID: 27279 (glance-registry)
CGroup: /system.slice/openstack-glance-registry.service

├─27279 /usr/bin/python2 /usr/bin/glance-registry
├─27296 /usr/bin/python2 /usr/bin/glance-registry
├─27297 /usr/bin/python2 /usr/bin/glance-registry
├─27298 /usr/bin/python2 /usr/bin/glance-registry
└─27299 /usr/bin/python2 /usr/bin/glance-registry

Mar 28 18:25:56 controller systemd[1]: Starting OpenStack Image Service (code-named Glance) Registry server…
Mar 28 18:25:57 controller glance-registry[27279]: No handlers could be found for logger “oslo_config.cfg”
Mar 28 18:25:57 controller systemd[1]: Started OpenStack Image Service (code-named Glance) Registry server

We’ve configured Glance image service successfully. In next tutorial, we’ll add images that Glance will store. We’ll create both CentOS  and Ubuntu glance images manually.

PREVIOUS ARTICLE:

Openstack Liberty Lab Part Three: Configuring Keystone identity service

NEXT ARTICLE:

Openstack Liberty Lab Part Five: Configure Nova Compute Service