Mindmajix

How Can We Configure the OpenStack Image Service

Configure the OpenStack Image Service

This section allows readers to gain knowledge on how to configure the OpenStack image service (code-names as glance).

To retrieve image-oriented events and samples, we need to configure the Image Service. Compute is configured to use the OpenStack Image Service (Glance), which is currently the only supported image service.

The OpenStack Image Service acts as a registry for virtual disk images. It enables users to discover, register, and retrieve virtual machine images. Also known as the glance project, the Image Service offers a REST API that enables you to query virtual machine image metadata and retrieve an actual image. You can store virtual machine images made available through the Image Service in a variety of locations from simple file systems to object-storage systems like OpenStack Object Storage.

Configuring OpenStack Image Service to use OpenStack Identity Service is essential to allow our OpenStack Compute to operate correctly.

Getting Started

To begin with, ensure you’re logged into our OpenStack Controller host or the host that is running OpenStack Image Service.

To log on to our OpenStack Controller host that was created using Vagrant, issue the following command:

vagrant ssh controller

How to achieve it…

To configure OpenStack Image Service for the usage of OpenStack Identity Service, carry out the following steps:

  1. We first edit the /etc/ glance/ glance-api-paste.ini file and configure the [filter:authtoken] section found at the bottom of this file, to match our glance service user which was configured previously under Keystone:

[filter:authtoken]

paste.filter_factory =

keystoneclient.middleware.auth_token:filter_factory

admin_tenant_name = service

admin_user = glance

admin_password = glance

  1. With the file saved, we add the following snippet at the bottom of the /etc/ glance/ glance-api.conf file, to tell OpenStack Image Service to utilize OpenStack Identity Service and also the information in the glance-api-paste.ini file:

[keystone_authtoken]

auth_host = 172.16.0.200

auth_port = 35357

auth_protocol = http

admin_tenant_name = service

admin_user = glance

admin_password = glance

[paste_deploy]

config_file = /etc/ glance/ glance-api-paste.ini

flavor = keystone

  1. We repeat this process for the /etc/ glance/ glance-registry-paste.ini file, configuring the glance service user in the [filter:authtoken] section:

[filter:authtoken]

paste.filter_factory =

keystoneclient.middleware.auth_token:filter_factory

admin_tenant_name = service

admin_user = glance admin_password = glance

         4. Then, we add the following to the corresponding /etc/ glance/ glance-registry.conf file, to use this information and enable it to use OpenStack Identity Service: [keystone_authtoken] auth_host = 172.16.0.200 auth_port = 35357 auth_protocol = http admin_tenant_name = service

[keystone_authtoken]

auth_host = 172.16.0.200

auth_port = 35357

auth_protocol = http

admin_tenant_name = service

admin_user = glance

admin_password = glance

[paste_deploy]

config_file = /etc/ glance/ glance-registry-paste.ini

flavor = keystone

  1. Finally, we restart the two OpenStack Image Service processes to pick up the changes:

sudo restart glance-api

sudo restart glance-registry

 How it works…

OpenStack Image Service runs two processes. They are the glance-api, which is the service that our clients and services talk to, and the other is glance-registry process that manages the objects on the disk and database registry. Both of these services need to have matching credentials that were defined previously in OpenStack Identity Service in their configuration files, in order to allow a user to authenticate with the service successfully.

Configuring Image Service with MySQL

 By default, the OpenStack Image Service (Glance) is configured to use a local SQL database. In order to scale effectively, we must configure our OpenStack Image Service to a central, scalable, and more resilient database tier. For this purpose, we will use our MySQL database.

Getting started

To begin with, ensure you’re logged into our OpenStack Controller host— where OpenStack Image Service has been installed.

To log on to our OpenStack Controller host that was created using Vagrant, issue the following command:

 vagrant ssh controller

How to achieve it…

Carry out the following steps:

1. With OpenStack Image Service already being installed, we can now create the glance database in our MySQL database server. We do this as follows:

MYSQL_ROOT_PASSWORD = openstack

mysql-uroot -p $ MYSQL_ROOT_PASSWORD \ -e ‘CREATE DATABASE glance;’

2. We now create a glance user, with the password openstack and with privileges to use this database, as follows:

MYSQL_GLANCE_PASSWORD = openstack

mysql -uroot -p ${ MYSQL_ROOT_PASSWORD} \

-e “GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@’%’

IDENTIFIED BY ‘$ { MYSQL_GLANCE_PASSWORD}’;”

mysql -uroot -p $ { MYSQL_ROOT_PASSWORD} \

 -e “GRANT ALL PRIVILEGES ON glance.* TO

‘glance’@’ localhost’ IDENTIFIED BY

 ‘$ { MYSQL_GLANCE_PASSWORD}’;”

3. We now configure the OpenStack Image Service to use this database by editing the /etc/ glance/ glance-registry.conf and /etc/ glance/ glance-api.conf files and change the sql_connection line to match the database credentials. We do this as follows:

sudo sed -i “s, ^ sql_connection.*, sql_connection =

mysql:// glance: ${ MYSQL_DB_PASSWORD}@ 172.16.0.200/ glance,”

 \

  /etc/ glance/ glance-{ registry, api}. conf

4. We can now restart the glance-registry service, as follows:

sudo stop glance-registry

sudo start glance-registry

5. And the same for the glance-api service:

sudo stop glance-api

sudo start glance-api

6. The glance database is versioned controlled under Ubuntu 12.04 to allow upgrade and downgrade of service. We first set the version control to be 0 by issuing the following command:

glance-manage version_control 0

7. We now sync the database to ensure that the correct table structure is present. We do this by issuing the following command:

sudo glance-manage db_sync

How it works…

The OpenStack Image Service is split up into two running services— glance-api and glance-registry—and it is the glance-registry service that connects to the database backend. The first step is to create our glance database and glance user, so it can perform operations on the glance database that we have created.

Once this is done, we modify the /etc/ glance/ glance-registry.conf and /etc/ glance/ glance-registry.conf files so that glance knows where to find and connect to our MySQL database. This is provided by the standard SQL Alchemy connection string that has the following syntax:

sql_connection = mysql:// USER:PASSWORD@ HOST/ DBNAME

Enroll for Live Instructor Led Online OpenStack Training


0 Responses on How Can We Configure the OpenStack Image Service"

Leave a Message

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

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.