Product SiteDocumentation Site

Chapter 3. Glance (Images)

Now that Keystone has been installed and configured, we are going to move on to Glance. The first step is to install the openstack-glance package.
$ sudo yum install openstack-glance
Glance makes use of MySQL to store metadata about images. Use the openstack-db utility to initialize the database for use with Glance.
$ sudo openstack-db --init --service glance
Keystone is used to handle authentication. Run the following commands to update the Glance configuration files for Keystone usage.
$ sudo openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
$ sudo openstack-config --set /etc/glance/glance-api-paste.ini \
  filter:authtoken admin_token $(cat /tmp/ks_admin_token)
$ sudo openstack-config --set /etc/glance/glance-registry.conf \
  paste_deploy flavor keystone
$ sudo openstack-config --set /etc/glance/glance-registry-paste.ini \
  filter:authtoken admin_token $(cat /tmp/ks_admin_token)
Now that Glance has been configured, start the glance-api and glance-registry services.
$ sudo service openstack-glance-registry start
$ sudo service openstack-glance-api start
$ sudo chkconfig openstack-glance-registry on
$ sudo chkconfig openstack-glance-api on
In addition to providing authentication, Keystone also maintains a registry of available of OpenStack services and how to reach them. This is referred to as the service catalog. Now that we have installed Glance, we must add it as an entry in Keystone's service catalog. This is an action that must be performed as the Keystone administrator.
$ . ~/keystonerc_admin
$ keystone service-create --name=glance --type=image --description="Glance Image Service"
|   Property  |              Value               |
| description | Glance Image Service             |
| id          | 1447f490e9784aa8890f9e39ddaa8d44 |
| name        | glance                           |
| type        | image                            |
$ keystone endpoint-create --service_id 1447f490e9784aa8890f9e39ddaa8d44 \
  --publicurl \
  --adminurl \
|   Property  |              Value               |
| adminurl    |         |
| id          | 9693e1af560843f68e9e91f2b3664a19 |
| internalurl |         |
| publicurl   |         |
| region      | regionOne                        |
| service_id  | 1447f490e9784aa8890f9e39ddaa8d44 |
Now it's time to test out the glance client application. First set up your environment to use the credentials for the regular account. Then run the glance index command. This will list the images that are currently available. If no errors occur, this command should produce no output since we have not registered an image yet.
$ . ~/keystonerc_username
$ glance index
Finally, add an image of RHEL 6.2 to Glance. This is done using the glance add command. Once the image has been added, it will show up in the list of available images. You can also retrieve details about the image from Glance using the glance show command.
$ glance add name="RHEL 6.2" is_public=true disk_format=qcow2 \
  container_format=bare < /srv/rhsummit/images/rhel62_x86_64.qcow2
Uploading image 'RHEL 6.2'
==========================================[100%] 155.966310M/s, ETA  0h  0m  0s
Added new image with ID: 17a34b8e-c573-48d6-920c-b4b450172b41
$ glance index
ID                                   Name                           Disk Format          Container Format     Size          
------------------------------------ ------------------------------ -------------------- -------------------- --------------
17a34b8e-c573-48d6-920c-b4b450172b41 RHEL 6.2                       qcow2                bare                      213581824
$ glance show 17a34b8e-c573-48d6-920c-b4b450172b41
Id: 17a34b8e-c573-48d6-920c-b4b450172b41
Public: Yes
Protected: No
Name: RHEL 6.2
Status: active
Size: 213581824
Disk format: qcow2
Container format: bare
Minimum Ram Required (MB): 0
Minimum Disk Required (GB): 0
Owner: 05816b0106994f95a83b913d4ff995eb
The following diagram shows the services that have been installed and configured so far, which include Keystone and Glance.