CentOS 6
Sponsored Link

OpenStack Icehouse : Add Images2014/06/23

 
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
+----+------+-------------+------------------+------+--------+
| ID | Name | Disk Format | Container Format | Size | Status |
+----+------+-------------+------------------+------+--------+
+----+------+-------------+------------------+------+--------+
[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 \
--name centos6 \
--ram 2048 \
--disk path=/var/kvm/images/centos6.img,format=qcow2 \
--vcpus=2 \
--os-type linux \
--os-variant=rhel6 \
--graphics none \
--console pty,target_type=serial \
--location='http://ftp.jaist.ac.jp/pub/Linux/CentOS/6.5/os/x86_64/' \
--extra-args='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         | b7c387387f16a39d87daa7568d4eb9d0     |
| container_format | bare                                 |
| created_at       | 2014-05-07T12:49:12                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | e410fef2-4387-43f6-bedc-5a9f81ee6ac6 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | CentOS6                              |
| owner            | 35f01938c8fc4021ab8e9710512a1201     |
| protected        | False                                |
| size             | 1072562176                           |
| status           | active                               |
| updated_at       | 2014-05-07T12:49:19                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+

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

+-----------+---------+-------------+------------------+------------+--------+
| ID        | Name    | Disk Format | Container Format | Size       | Status |
+-----------+---------+-------------+------------------+------------+--------+
| e410fef2- | CentOS6 | qcow2       | bare             | 1072562176 | 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/14.04/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img -P /var/kvm/images
root@dlp:~#
glance image-create --name="Ubuntu1404" --is-public=true --disk-format=qcow2 --container-format=bare < /var/kvm/images/ubuntu-14.04-server-cloudimg-amd64-disk1.img

+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | b65cbc63bfa4abb6144dddf43caa6b5e     |
| container_format | bare                                 |
| created_at       | 2014-05-05T05:26:46                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | 90b2b3fd-d671-4f2f-aba1-b8a890857bd8 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Ubuntu1404                           |
| owner            | fa66398ac25943629877cc6e459d38ae     |
| protected        | False                                |
| size             | 252707328                            |
| status           | active                               |
| updated_at       | 2014-05-05T05:26:49                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+
Matched Content