Posted by: John Bresnahan | December 27, 2012

OpenStack from scratch on Fedora 17 (part 3 glance)

In the previous post I showed how to setup a keystone development environment from scratch. Here I will talk about how to install, configure, and use glance with that keystone installation.

Glance

First remember to activate your python virtual environment.  See the details in part one.  Then get glance from github and install it:

source openstackVE/bin/activate
git clone git://github.com/openstack/glance.git
python setup.py develop

Now we need to setup the glance configuration directory.  You can read about the search path that glance uses to find its configuration files here.  Here we use $HOME/.glance.  Make this directory and add these 5 files to it. Once you add them substitute out my home directory (/home/jbresnah/) for yours.

glance-api.conf
glance-api-paste.ini
glance-cache.conf
glance-registry.conf
glance-registry-paste.ini

mkdir ~/.glance
$ ls
glance-api.conf       glance-cache.conf     glance-registry-paste.ini
glance-api-paste.ini  glance-registry.conf

The following set of commands will create the needed files and directories under ~/.glance and start the registry and api services.

glance-manage db_sync
glance-api &
glance-registry &

Now look at the directory ~/.glance/ and notice the newly created files and directories.  In particular there should be a file called glance.db.  While glance does not intend for you to manually alter this database viewing its contents with sqlite can provide some insight into what is happening behind the scenes.

Now we must tell keystone how to find the image service.  Source your environment for interacting with the keystone service as the admin.  The details of this are discussed in the previous post, but they are also here:

export OS_USERNAME=admin
export OS_TENANT_NAME=admin
export OS_PASSWORD=secret
export OS_AUTH_URL=http://127.0.0.1:35357/v2.0/
export PS1="[\u@\h \W(keystone_admin)]\$ "

Now that the admin environment is setup for use with the keystone client we need to tell keystone how to find the image service:

$ keystone service-create --name=glance --type=image --description="Glance Image Service"
Failed to load keyring modules.
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |       Glance Image Service       |
|      id     | ef316045376b4b65b102eaa1b356fd75 |
|     name    |              glance              |
|     type    |              image               |
+-------------+----------------------------------+
$ keystone endpoint-create --service_id ef316045376b4b65b102eaa1b356fd75 --publicurl http://127.0.0.1:9292/v1   --adminurl http://127.0.0.1:9292/v1   --internalurl http://127.0.0.1:9292/v1
Failed to load keyring modules.
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
|   adminurl  |     http://127.0.0.1:9292/v1     |
|      id     | 78fd0991378e4524bce3c511e0e22c29 |
| internalurl |     http://127.0.0.1:9292/v1     |
|  publicurl  |     http://127.0.0.1:9292/v1     |
|    region   |            regionOne             |
|  service_id | ef316045376b4b65b102eaa1b356fd75 |
+-------------+----------------------------------+

Glance Client

Now that we have the service running we must install a glance client. Download the source code from github, and install it into the python virtual environment (which should already be configured):

git clone git://github.com/openstack/python-glanceclient.git
cd python-glanceclient
python setup.py develop

Now that it is installed and the admin client environment is set you can start interacting with the service. The following commands will upload a dummy image and allow you to interact with it.

$ glance image-create --name "Test Image" --is-public True --container-format bare --disk-format qcow2 < /etc/group
Failed to load keyring modules.
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 09841e9d59f9d367d89bf552592f5f27     |
| container_format | bare                                 |
| created_at       | 2012-12-27T20:25:34.043619           |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | dc222bd3-6fca-4f6e-b9fe-44cb65c98130 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Test Image                           |
| owner            | 1a70d5412a3f41d5b366addd7c778dbe     |
| protected        | False                                |
| size             | 876                                  |
| status           | active                               |
| updated_at       | 2012-12-27T20:25:34.696230           |
+------------------+--------------------------------------+
$ glance index
Failed to load keyring modules.
ID                                   Name                           Disk Format          Container Format     Size
------------------------------------ ------------------------------ -------------------- -------------------- --------------
dc222bd3-6fca-4f6e-b9fe-44cb65c98130 Test Image                     qcow2                bare                            876
$ glance image-show dc222bd3-6fca-4f6e-b9fe-44cb65c98130
Failed to load keyring modules.
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 09841e9d59f9d367d89bf552592f5f27     |
| container_format | bare                                 |
| created_at       | 2012-12-27T20:25:34.043619           |
| deleted          | False                                |
| disk_format      | qcow2                                |
| id               | dc222bd3-6fca-4f6e-b9fe-44cb65c98130 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Test Image                           |
| owner            | 1a70d5412a3f41d5b366addd7c778dbe     |
| protected        | False                                |
| size             | 876                                  |
| status           | active                               |
| updated_at       | 2012-12-27T20:25:34.696230           |
+------------------+--------------------------------------+
Advertisements

Responses

  1. […] two earlier posts I explained how to manually setup Glance and Keystone development environments.  Have that setup (or whatever works for you) and make sure […]

  2. Hi, I have followed all the steps in your this series, but always get:
    (env)test@vm1:~/os$ glance image-list
    Unable to communicate with identity service: {“error”: {“message”: “Could not find project: admin”, “code”: 401, “title”: “Unauthorized”}}. (HTTP 401)

    Your glance-api-paste.ini can’t be downloaded, so I just copies the etc/glance-api-paste.ini to ~/.glance/glance-api-paste.ini. I am not sure if this is the culprit. Any ideas, thanks in advacned !

    Your blog is a great help for the people like me that are very fresh to the development of OS.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: