元のディレクトリをバックアップしておきます。
$ sudo cp -a /etc/glance /etc/glance_orig
$ cd /etc/glance
$ sudo vi glance-api.conf glance-registry.conf
sql_connection = mysql://glance:password@stack01/glance?charset=utf8
admin_tenant_name = service
admin_user = glance
admin_password = password
[paste_deploy]
flavor = keystone
$ sudo vi glance-api.conf
notifier_strategy = rabbit
rabbit_host = stack01
rabbit_port = 5672
rabbit_use_ssl = false
rabbit_userid = nova
rabbit_password = password
rabbit_virtual_host = /nova
rabbit_notification_exchange = glance
rabbit_notification_topic = glance_notifications
rabbit_durable_queues = False
$ sudo sed -i "s#127.0.0.1#stack01#" /etc/glance/glance-api.conf
$ sudo sed -i "s#localhost#stack01#" /etc/glance/glance-api.conf
$ sudo sed -i "s#127.0.0.1#stack01#" /etc/glance/glance-registry.conf
$ sudo sed -i "s#localhost#stack01#" /etc/glance/glance-registry.conf
$ MYSQL_PASS_GLANCE=password
$ NOVA_CONTOLLER_HOSTNAME=stack01
$ mysql -u root -pnova -e "drop database if exists glance;"
$ mysql -u root -pnova -e "create database glance character set utf8;"
$ mysql -u root -pnova -e "grant all privileges on glance.* to 'glance'@'%' identified by '$MYSQL_PASS_GLANCE';"
$ mysql -u root -pnova -e "grant all privileges on glance.* to 'glance'@'localhost' identified by '$MYSQL_PASS_GLANCE';"
$ mysql -u root -pnova -e "grant all privileges on glance.* to 'glance'@'$NOVA_CONTOLLER_HOSTNAME' identified by '$MYSQL_PASS_GLANCE';"
$ sudo glance-manage db_sync
Glanceのプロセスを再起動します。
# for i in api registry
do
start glance-$i ; restart glance-$i
done
イメージの置き場所は/opt/virtとします。
ファイルのダウンロード
$ sudo mkdir -p /opt/virt/ubuntu12.04 ; cd /opt/virt/ubuntu12.04
$ sudo wget http://cloud-images.ubuntu.com/releases/precise/release/ubuntu-12.04-server-cloudimg-amd64-disk1.img
$ export OS_USERNAME=admin
$ export OS_PASSWORD=password
$ export OS_TENANT_NAME=admin
$ export OS_AUTH_URL=http://stack01:35357/v2.0/
マシンイメージの登録
$ glance image-create --name="Ubuntu 12.04 TLS" --is-public=true --container-format=ovf --disk-format=qcow2 < ubuntu-12.04-server-cloudimg-amd64-disk1.img
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 13037b2e6d93cd6b7d2c651790047648 |
| container_format | ovf |
| created_at | 2013-02-12T01:04:19 |
| deleted | False |
| deleted_at | None |
| disk_format | qcow2 |
| id | ae7c0c98-7eda-4fb5-bf6f-e857ca437550 |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | Ubuntu 12.04 TLS |
| owner | None |
| protected | False |
| size | 250609664 |
| status | active |
| updated_at | 2013-02-12T01:04:21 |
+------------------+--------------------------------------+
作業によりイメージが問題なく登録されたかを確認します。
$ glance image-list
+--------------------------------------+------------------+-------------+------------------+-----------+--------+
| ID | Name | Disk Format | Container Format | Size | Status |
+--------------------------------------+------------------+-------------+------------------+-----------+--------+
| ae7c0c98-7eda-4fb5-bf6f-e857ca437550 | Ubuntu 12.04 TLS | qcow2 | ovf | 250609664 | active |
+--------------------------------------+------------------+-------------+------------------+-----------+--------+
$ glance image-show ae7c0c98-7eda-4fb5-bf6f-e857ca437550
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 13037b2e6d93cd6b7d2c651790047648 |
| container_format | ovf |
| created_at | 2013-02-12T01:04:19 |
| deleted | False |
| disk_format | qcow2 |
| id | ae7c0c98-7eda-4fb5-bf6f-e857ca437550 |
| is_public | True |
| min_disk | 0 |
| min_ram | 0 |
| name | Ubuntu 12.04 TLS |
| protected | False |
| size | 250609664 |
| status | active |
| updated_at | 2013-02-12T01:04:21 |
+------------------+--------------------------------------+