Site icon UnixArena

Openstack – Installing & Configuring Glance – Part 4

Glance service installation & configuration

Glance service installation & configuration

This article will guide you to configure the Image service on Openstack. Openstack image service has been development and maintained in the name of Glance. Glance service enables users/customers  to discover , register and retrieve virtual machine images. Virtual machine images can be stored in normal file-systems like ext3 ,ext4 or it can be stored it in object storage systems like swift. In this article , we will use the local file-system as glance storage. Image service consists below listed components.

In short, openstack Glance service works like a  registry service for virtual disk images. Using glance service,  openstack users can add new instance images (Ex:RHEL , SUSE , Windows Server , Ubunutu) , snapshot of image from existing instance and launch the instance using the snapshot.

In our environment , Controller node will host the glance service.  So login to the Openstack controller node and begin the glance installation.

 

 

Install the Image Service:

 

1.Install glance image service components on openstack controller node.

root@OSCTRL-UA:/var/lib# apt-get install glance python-glanceclient
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  glance-api glance-common glance-registry python-boto python-cinderclient
  python-concurrent.futures python-glance python-glance-store python-httplib2
  python-ipaddr python-json-patch python-json-pointer python-jsonpatch
  python-oslo.vmware python-osprofiler python-retrying python-simplegeneric
  python-simplejson python-suds python-swiftclient python-warlock python-wsme
Suggested packages:
  python-ceph
The following NEW packages will be installed:
  glance glance-api glance-common glance-registry python-boto
  python-cinderclient python-concurrent.futures python-glance
  python-glance-store python-glanceclient python-httplib2 python-ipaddr
  python-json-patch python-json-pointer python-jsonpatch python-oslo.vmware
  python-osprofiler python-retrying python-simplegeneric python-simplejson
  python-suds python-swiftclient python-warlock python-wsme
0 upgraded, 24 newly installed, 0 to remove and 17 not upgraded.
Need to get 1,667 kB of archives.
After this operation, 12.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:23 http://in.archive.ubuntu.com/ubuntu/ trusty/main python-concurrent.futures all 2.1.6-3 [32.8 kB]
Get:24 http://in.archive.ubuntu.com/ubuntu/ trusty/main python-httplib2 all 0.8-2build1 [35.4 kB]
Fetched 1,667 kB in 12s (136 kB/s)
Selecting previously unselected package python-simplejson.
(Reading database ... 95790 files and directories currently installed.)
Preparing to unpack .../python-simplejson_3.3.1-1ubuntu6_amd64.deb ...
Unpacking python-simplejson (3.3.1-1ubuntu6) ...
Selecting previously unselected package python-cinderclient.
Preparing to unpack .../python-cinderclient_1%3a1.1.0-0ubuntu1~cloud0_all.deb ...
Unpacking python-cinderclient (1:1.1.0-0ubuntu1~cloud0) ...
Selecting previously unselected package python-glance-store.
Preparing to unpack .../python-glance-store_0.1.8-1ubuntu2~cloud0_all.deb ...
Unpacking python-glance-store (0.1.8-1ubuntu2~cloud0) ...
Selecting previously unselected package python-json-pointer.
Preparing to unpack .../python-json-pointer_1.0-2build1_all.deb ...
Unpacking python-json-pointer (1.0-2build1) ...
Selecting previously unselected package python-jsonpatch.
Preparing to unpack .../python-jsonpatch_1.3-4_all.deb ...
Unpacking python-jsonpatch (1.3-4) ...
Selecting previously unselected package python-json-patch.
Preparing to unpack .../python-json-patch_1.3-4_all.deb ...
Unpacking python-json-patch (1.3-4) ...
Selecting previously unselected package python-suds.
Setting up python-swiftclient (1:2.3.0-0ubuntu1~cloud0) ...
Setting up python-glance (1:2014.2.3-0ubuntu1~cloud1) ...
Setting up glance-common (1:2014.2.3-0ubuntu1~cloud1) ...
Adding system user `glance' (UID 112) ...
Adding new user `glance' (UID 112) with group `glance' ...
Not creating home directory `/var/lib/glance'.
Setting up glance-api (1:2014.2.3-0ubuntu1~cloud1) ...
glance-api start/running, process 4146
Setting up glance-registry (1:2014.2.3-0ubuntu1~cloud1) ...
glance-registry start/running, process 4181
Setting up python-glanceclient (1:0.14.0-0ubuntu1~cloud0) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up glance (1:2014.2.3-0ubuntu1~cloud1) ...
root@OSCTRL-UA:/var/lib#

 

2. Edit the glance-api & glance-registry configuration files to update the MySQL  DB information.  As I said earlier, glance service required DB to storage the information. please refer part 2 to see the password database.

root@OSCTRL-UA:/var/lib# egrep "database|mysql:" /etc/glance/glance-api.conf  |grep -v "#"
[database]
connection = mysql://glance:glancedb123@OSCTRL-UA/glance
root@OSCTRL-UA:/var/lib#

root@OSCTRL-UA:~# egrep "database|mysql:" /etc/glance/glance-registry.conf  |grep -v "#"
[database]
connection = mysql://glance:glancedb123@OSCTRL-UA/glance
root@OSCTRL-UA:~#

 

3.Configure the glance image service to use RabbitMQ  (Message Broker). Update the RabbitMQ host , password information on glance-api.conf. For pre-configured password , please refer part 2.

root@OSCTRL-UA:~# grep rabbit /etc/glance/glance-registry.conf
rpc_backend = rabbit
# Configuration options if sending notifications via rabbitmq (these are
rabbit_host = OSCTRL-UA
rabbit_port = 5672
rabbit_use_ssl = false
rabbit_userid = guest
rabbit_password = rabbit123
rabbit_virtual_host = /
rabbit_notification_exchange = glance
rabbit_notification_topic = notifications
rabbit_durable_queues = False
root@OSCTRL-UA:~#


root@OSCTRL-UA:~# grep rabbit /etc/glance/glance-api.conf
rpc_backend = rabbit
# Configuration options if sending notifications via rabbitmq (these are
rabbit_host = OSCTRL-UA
rabbit_port = 5672
rabbit_use_ssl = false
rabbit_userid = guest
rabbit_password = rabbit123
rabbit_virtual_host = /
rabbit_notification_exchange = glance
rabbit_notification_topic = notifications
rabbit_durable_queues = False
root@OSCTRL-UA:~#

 

Please remove if there is any sqlite tables .

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

 

4. Create the Database & users for  Glance on mysql.

root@OSCTRL-UA:~# mysql -u root -pstack
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.5.44-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE glance;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glancedb123';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glancedb123';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

 

5. Create the necessary tables for glance service using the below command.

root@OSCTRL-UA:~# su -s /bin/sh -c "glance-manage db_sync" glance
root@OSCTRL-UA:~#

 

Preparing keystone service for glance:

 

6. Export the variable or create the file like below & source it. (To reduce the command length. Otherwise you need to provide the below credentials on all the 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:~#
root@OSCTRL-UA:~# source admin.rc

 

7. Create the glance user on keystone . This user will be used to authenticate with keystone service.

root@OSCTRL-UA:~# keystone user-create --name=glance --pass=glance123 --email=glance@unixarena.com
+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |       glance@unixarena.com       |
| enabled  |               True               |
|    id    | e19954b08ac34e39b5f8b87001910734 |
|   name   |              glance              |
| username |              glance              |
+----------+----------------------------------+
root@OSCTRL-UA:~#

 

8. Add admin role to the glance user.

root@OSCTRL-UA:~# keystone user-role-add --user=glance --tenant=service --role=admin
root@OSCTRL-UA:~#

 

Configure image service to use keystone:

 

9. Configure the image service to use keystone server by editing the glance configuration files like below.

root@OSCTRL-UA:~# grep -A9 keystone_authtoken /etc/glance/glance-api.conf
[keystone_authtoken]
auth_uri = http://OSCTRL-UA:5000
identity_uri = http://OSCTRL-UA:35357
admin_tenant_name = service
admin_user = glance
admin_password = glance123
revocation_cache_time = 10
root@OSCTRL-UA:~#


root@OSCTRL-UA:~# grep -A9  keystone_authtoken /etc/glance/glance-registry.conf
[keystone_authtoken]
auth_uri = http://OSCTRL-UA:5000
identitiy_uri = http://OSCTRL-UA:35357
admin_tenant_name = service
admin_user = glance
admin_password = glance123
revocation_cache_time = 10

root@OSCTRL-UA:~#

 

10. Set the flavour as keystone on both glance configuration files.

root@OSCTRL-UA:~# grep -A8 paste_deploy /etc/glance/glance-registry.conf
[paste_deploy]
# Name of the paste configuration file that defines the available pipelines
#config_file = glance-registry-paste.ini

# Partial name of a pipeline in your paste configuration file with the
# service name removed. For example, if your paste section name is
# [pipeline:glance-registry-keystone], you would configure the flavor below
# as 'keystone'.
flavor=keystone
root@OSCTRL-UA:~#



root@OSCTRL-UA:~# grep -A8 paste_deploy /etc/glance/glance-api.conf
[paste_deploy]
# Name of the paste configuration file that defines the available pipelines
#config_file = glance-api-paste.ini

# Partial name of a pipeline in your paste configuration file with the
# service name removed. For example, if your paste section name is
# [pipeline:glance-api-keystone], you would configure the flavor below
# as 'keystone'.
flavor=keystone
root@OSCTRL-UA:~#

 

Click Next Page to Continue …….

 

 

11. Register the image service on keystone. So that keystone will authenticate whenever glance will be used.

root@OSCTRL-UA:~# keystone service-create --name=glance --type=image --description="OpenStack Image Service"
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |     OpenStack Image Service      |
|   enabled   |               True               |
|      id     | ee22977db7d84566a4c2217d48859001 |
|     name    |              glance              |
|     type    |              image               |
+-------------+----------------------------------+
root@OSCTRL-UA:~#

 

12. Create the end point service .

root@OSCTRL-UA:~# keystone endpoint-create --service-id=$(keystone service-list | awk '/ image / {print $2}') --publicurl=http://OSCTRL-UA:9292 --internalurl=http://OSCTRL-UA:9292 --adminurl=http://OSCTRL-UA:9292
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
|   adminurl  |      http://OSCTRL-UA:9292       |
|      id     | b17e1f61815e4f83abf3606d1a7b3764 |
| internalurl |      http://OSCTRL-UA:9292       |
|  publicurl  |      http://OSCTRL-UA:9292       |
|    region   |            regionOne             |
|  service_id | ee22977db7d84566a4c2217d48859001 |
+-------------+----------------------------------+
root@OSCTRL-UA:~#

 

13. Restart the glance image services .

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

 

14. Verify the glance service installation by creating the new image & listing it .

 

Let me download the cirros from web.

root@OSCTRL-UA:~# wget https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
--2015-09-27 12:33:13--  https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
Resolving launchpad.net (launchpad.net)... 91.189.89.223, 91.189.89.222
Connecting to launchpad.net (launchpad.net)|91.189.89.223|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://launchpadlibrarian.net/83305348/cirros-0.3.0-x86_64-disk.img [following]
--2015-09-27 12:33:16--  https://launchpadlibrarian.net/83305348/cirros-0.3.0-x86_64-disk.img
Resolving launchpadlibrarian.net (launchpadlibrarian.net)... 91.189.89.228, 91.189.89.229
Connecting to launchpadlibrarian.net (launchpadlibrarian.net)|91.189.89.228|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9761280 (9.3M) [text/plain]
Saving to: ‘cirros-0.3.0-x86_64-disk.img’

100%[===========================================================================================================================>] 97,61,280    118KB/s   in 73s

2015-09-27 12:34:32 (131 KB/s) - ‘cirros-0.3.0-x86_64-disk.img’ saved [9761280/9761280]

root@OSCTRL-UA:~# ls -lrt
total 9544
-rw-r--r-- 1 root root 9761280 Oct 20  2011 cirros-0.3.0-x86_64-disk.img
-rw-r--r-- 1 root root     132 Sep 21 02:59 keystone_var
-rw-r--r-- 1 root root     128 Sep 22 00:41 admin.rc
root@OSCTRL-UA:~#

 

Create the Cirros Image,

root@OSCTRL-UA:~# glance image-create --name="CirrOS 0.3.0" --disk-format=qcow2 --container-format=bare --is-public=true < cirros-0.3.0-x86_64-disk.img
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 50bdc35edb03a38d91b1b071afb20a3c     |
| container_format | bare                                 |
| created_at       | 2015-09-27T07:08:35                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | 7d19b639-6950-42dc-a64d-91c6662e0613 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | CirrOS 0.3.0                         |
| owner            | d14d6a07f862482398b3e3e4e8d581c6     |
| protected        | False                                |
| size             | 9761280                              |
| status           | active                               |
| updated_at       | 2015-09-27T07:08:36                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+

 

List the newly created cirros image,

root@OSCTRL-UA:~# glance image-list
+--------------------------------------+--------------+-------------+------------------+---------+--------+
| ID                                   | Name         | Disk Format | Container Format | Size    | Status |
+--------------------------------------+--------------+-------------+------------------+---------+--------+
| 7d19b639-6950-42dc-a64d-91c6662e0613 | CirrOS 0.3.0 | qcow2       | bare             | 9761280 | active |
+--------------------------------------+--------------+-------------+------------------+---------+--------+
root@OSCTRL-UA:~#

 

We have successfully configured the Openstack image service and verified the installation by creating the new image. In the next article ,we will see the compute node configuration. Hope this article is informative to you.

Share it !! Be Sociable !!!

Exit mobile version