CentOS 6
Sponsored Link

OpenStack Havana - Add Virtual Machine Images2013/10/22

 
Add Virtual Machine images in Glance.
[1] Load environment variables first.
[root@dlp ~]#
unset SERVICE_TOKEN

[root@dlp ~]#
unset SERVICE_ENDPOINT

[root@dlp ~]#
vi ~/keystonerc
export OS_USERNAME=admin
export OS_PASSWORD=adminpassword
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://10.0.0.30:35357/v2.0/
export PS1='[\u@\h \W(keystone)]\$ '
[root@dlp ~]#
chmod 600 ~/keystonerc

[root@dlp ~]#
source ~/keystonerc

[root@dlp ~(keystone)]#
echo "source ~/keystonerc " >> ~/.bash_profile
# confirm status (it's OK if no errors are shown)

[root@dlp ~(keystone)]#
glance image-list
[2] For example, Create a Virtual Machine image of CentOS 6 for adding.
# create a directory for disk image

[root@dlp ~]#
mkdir -p /var/kvm/images
# create a disk image

[root@dlp ~]#
qemu-img create -f qcow2 /var/kvm/images/centos6.img 10G
# install

[root@dlp ~]#
virt-install \
-n centos6 \
-r 2048 \
--disk path=/var/kvm/images/centos6.img,format=qcow2 \
--vcpus=2 \
--os-type linux \
--os-variant=rhel6 \
--nographics \
--location='http://ftp.jaist.ac.jp/pub/Linux/CentOS/6.4/os/x86_64/' \
--extra-args='console=tty0 console=ttyS0,115200n8 serial'
Starting install...
# installation starts
[3]
After installation, change settings in virtual machine like follows and shutdown it.
* delete or comment out the line "HWADDR" and "UUID" in /etc/sysconfig/network-scripts/ifcfg-eth0
* set "dhcp" for "BOOTPROTO" in /etc/sysconfig/network-scripts/ifcfg-eth0
* delete the file "/etc/udev/rules.d/70-persistent-net.rules"
[4] Add the virtual image to Glance.
[root@dlp ~(keystone)]#
glance image-create --name="CentOS6" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/centos6.img

+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 8794d92243f25b712a834992e731eccd     |
| container_format | bare                                 |
| created_at       | 2013-10-22T12:43:42                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | 46042f47-c307-4fce-af0d-a1b2c14d6d78 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | CentOS6                              |
| owner            | 97be94660c2043e58fee407bc9cde0d5     |
| protected        | False                                |
| size             | 976420864                            |
| status           | active                               |
| updated_at       | 2013-10-22T12:43:49                  |
+------------------+--------------------------------------+

[root@dlp ~(keystone)]#
glance image-list

+-------------+---------+-------------+------------------+-----------+--------+
| ID          | Name    | Disk Format | Container Format | Size      | Status |
+-------------+---------+-------------+------------------+-----------+--------+
| 46042f47-c3 | CentOS6 | qcow2       | bare             | 976420864 | active |
+-------------+---------+-------------+------------------+-----------+--------+
[5] By the way, if you got an image fron internet, it's OK to simplt add it like follows.
[root@dlp ~]#
wget http://cloud-images.ubuntu.com/releases/13.10/release/ubuntu-13.10-server-cloudimg-amd64-disk1.img -P /var/kvm/images
[root@dlp ~]#
glance image-create --name="Ubuntu1310" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/ubuntu-13.10-server-cloudimg-amd64-disk1.img

+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 567c81fee02aa4d6d97a41d10c7daaf4     |
| container_format | bare                                 |
| created_at       | 2013-10-22T16:28:23                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | d6dbbd44-7f71-409e-ac89-8181d9c2bca4 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Ubuntu1310                           |
| owner            | 97be94660c2043e58fee407bc9cde0d5     |
| protected        | False                                |
| size             | 241762304                            |
| status           | active                               |
| updated_at       | 2013-10-22T16:28:24                  |
+------------------+--------------------------------------+

[root@dlp ~(keystone)]#
glance image-list

+-------------+------------+-------------+------------------+-----------+--------+
| ID          | Name       | Disk Format | Container Format | Size      | Status |
+-------------+------------+-------------+------------------+-----------+--------+
| 46042f47-c3 | CentOS6    | qcow2       | bare             | 976420864 | active |
| d6dbbd44-7f | Ubuntu1310 | qcow2       | bare             | 241762304 | active |
+-------------+------------+-------------+------------------+-----------+--------+
Matched Content