• No se han encontrado resultados

2. MARCO TEÓRICO

2.2. Competencia pragmática

2.2.1. Competencia comunicativa

Installing and Configuring the Image Service ... 35 Configuring the Image Service database backend ... 35 Edit the Glance configuration files ... 36 Troubleshooting the Image Service (Glance) ... 38 Verifying the Image Service Installation ... 38

Installing and Configuring the Image Service

Install the Image service, as root:

# yum install openstack-glance # rm /var/lib/glance/glance.sqlite

Configuring the Image Service database backend

Configure the backend data store. For MySQL, create a glance MySQL database and a glance MySQL user. Grant the "glance" user full access to the glance MySQL database. Start the MySQL command line client by running:

$ mysql -u root -p

Enter the MySQL root user's password when prompted. To configure the MySQL database, create the glance database.

mysql> CREATE DATABASE glance;

Create a MySQL user for the newly-created glance database that has full control of the database.

mysql> GRANT ALL ON glance.* TO 'glance'@'%' IDENTIFIED BY

'[YOUR_GLANCEDB_PASSWORD]';

mysql> GRANT ALL ON glance.* TO 'glance'@'localhost' IDENTIFIED BY

'[YOUR_GLANCEDB_PASSWORD]';

Note

In the above commands, even though the 'glance'@'%' also matches 'glance'@'localhost', you must explicitly specify the 'glance'@'localhost' entry.

By default, MySQL will create entries in the user table with User='' and Host='localhost'. The User='' acts as a wildcard, matching all users. If you do not have the 'glance'@'localhost' account, and you try to log in as the glance user, the precedence rules of MySQL will match against the User='' Host='localhost' account before it matches against the User='glance' Host='%' account. This will result in an error message that looks like:

ERROR 1045 (28000): Access denied for user 'glance'@'localhost' (using password: YES)

Thus, we create a separate User='glance' Host='localhost' entry that will match with higher precedence.

See the MySQL documentation on connection verification for more details on how MySQL determines which row in the user table it uses when authenticating connections.

Enter quit at the mysql> prompt to exit MySQL.

mysql> quit

Edit the Glance configuration files

The Image service has a number of options that you can use to configure the Glance API server, optionally the Glance Registry server, and the various storage backends that Glance can use to store images. By default, the storage backend is in file, specified in the glance- api.conf config file in the section [DEFAULT].

The glance-api service implements versions 1 and 2 of the OpenStack Images API. By default, both are enabled by setting these configuration options to True in the glance- api.conf file.

enable_v1_api=True enable_v2_api=True

Disable either version of the Images API by setting the option to False in the glance- api.conf file.

Note

In order to use the v2 API, you must copy the necessary SQL configuration from your glance-registry service to your glance-api configuration file. The following instructions assume that you want to use the v2 Image API for your installation. The v1 API is implemented on top of the glance-registry service while the v2 API is not.

Most configuration is done via configuration files, with the Glance API server (and possibly the Glance Registry server) using separate configuration files. When installing through an operating system package management system, sample configuration files are installed in / etc/glance.

This walkthrough installs the image service using a file backend and the Identity service (Keystone) for authentication.

Add the admin and service identifiers and flavor=keystone to the end of /etc/ glance/glance-api.conf as shown below.

[keystone_authtoken] auth_host = 127.0.0.1 auth_port = 35357

auth_protocol = http

admin_tenant_name = service admin_user = glance

admin_password = glance [paste_deploy]

# Name of the paste configuration file that defines the available pipelines config_file = /etc/glance/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

Ensure that /etc/glance/glance-api.conf points to the MySQL database rather than sqlite.

sql_connection = mysql://glance:[YOUR_GLANCEDB_PASSWORD]@192.168.206.130/ glance

Restart glance-api to pick up these changed settings.

service glance-api restart

Update the last sections of /etc/glance/glance-registry.conf to reflect the values you set earlier for admin user and the service tenant, plus enable the Identity service with flavor=keystone. [keystone_authtoken] auth_host = 127.0.0.1 auth_port = 35357 auth_protocol = http admin_tenant_name = service admin_user = glance admin_password = glance [paste_deploy]

# Name of the paste configuration file that defines the available pipelines config_file = /etc/glance/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-api-keystone], you would configure the flavor below # as 'keystone'.

flavor=keystone

Update /etc/glance/glance-registry-paste.ini by enabling the Identity service, keystone:

# Use this pipeline for keystone auth [pipeline:glance-registry-keystone] pipeline = authtoken context registryapp

Ensure that /etc/glance/glance-registry.conf points to the MySQL database rather than sqlite.

sql_connection = mysql://glance:[YOUR_GLANCEDB_PASSWORD]@192.168.206.130/ glance

Restart glance-registry to pick up these changed settings.

service glance-registry restart

Note

Any time you change the .conf files, restart the corresponding service. Now you can populate or migrate the database.

# glance-manage db_sync

Restart glance-registry and glance-api services, as root:

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

Note

This guide does not configure image caching, refer to http:// docs.openstack.org/developer/glance/ for more information.

Troubleshooting the Image Service (Glance)

To begin troubleshooting, look at the logs in the /var/log/glance/registry.log or /var/log/glance/api.log.

Verifying the Image Service Installation

To validate the Image service client is installed, enter glance help at the command line. Obtain a test image.

mkdir /tmp/images cd /tmp/images/

wget http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-disk.img

Upload the kernel.

Note

This example shows inputting --os-username, --os-password, --os-tenant-name, --os-auth-url on the command line for reference. You could also use the OS_* environment variables by setting them in an openrc file:

export OS_USERNAME=admin export OS_TENANT_NAME=demo export OS_PASSWORD=secrete

export OS_AUTH_URL=http://192.168.206.130:5000/v2.0/ export OS_REGION_NAME=RegionOne

Then you would source these environment variables by running source openrc.

glance --os-username=admin --os-password=secrete --os-tenant-name=demo --os- auth-url=http://192.168.206.130:5000/v2.0 \

image-create \

--name="Cirros 0.3.1" \ --disk-format=qcow2 \

--container-format bare < cirros-0.3.1-x86_64-disk.img +---+---+ | Property | Value | +---+---+ | checksum | d972013792949d0d3ba628fbe8685bce | | container_format | bare | | created_at | 2013-05-08T18:59:18 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | acafc7c0-40aa-4026-9673-b879898e1fc2 | | is_public | False | | min_disk | 0 | | min_ram | 0 | | name | Cirros 0.3.1 | | owner | efa984b0a914450e9a47788ad330699d | | protected | False | | size | 13147648 | | status | active | | updated_at | 2013-05-08T18:59:18 | +---+---+

Now a glance image-list should show these image IDs.

glance --os-username=admin --os-password=secrete --os-tenant-name=demo --os- auth-url=http://192.168.206.130:5000/v2.0 image-list

+---+--- +---+---+---+---+

| ID | Name | Disk Format | Container Format | Size | Status |

+---+--- +---+---+---+---+

| acafc7c0-40aa-4026-9673-b879898e1fc2 | Cirros 0.3.1 | qcow2 | bare | 13147648 | active |

| 10ccdf86-e59e-41ac-ab41-65af91ea7a9c | cirros-0.3.0-x86_64-uec | ami | ami | 25165824 | active |

| 8473f43f-cd1f-47cc-8d88-ccd9a62e566f | cirros-0.3.0-x86_64-uec-kernel | aki | aki | 4731440 | active |

| 75c1bb27-a406-462c-a379-913e4e6221c9 | cirros-0.3.0-x86_64-uec-ramdisk | ari | ari | 2254249 | active |

+---+--- +---+---+---+---+