OpenStack Grizzly - Add Virtual Machine image2013/08/13 |
Add Virtual Machine image 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://127.0.0.1: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 disk image [root@dlp ~]# qemu-img create -f qcow2 /var/kvm/images/centos6.img 10G
# install [root@dlp ~]# virt-install \
Starting 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' # 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 | 91ad4f207f697fc3ea16050ac069c864 | | container_format | bare | | created_at | 2013-08-13T04:37:00 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | d41846d5-c67c-49f2-a616-6c9a136bed3a | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | CentOS6 | | owner | 4fc0e91962e24923bfe50db73d6930ef | | protected | False | | size | 964689920 | | status | active | | updated_at | 2013-08-13T04:37:06 | +------------------+--------------------------------------+[root@dlp ~(keystone)]# glance image-list +--------------------------------------+---------+-------------+------------------+-----------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +--------------------------------------+---------+-------------+------------------+-----------+--------+ | d41846d5-c67c-49f2-a616-6c9a136bed3a | CentOS6 | qcow2 | bare | 964689920 | active | +--------------------------------------+---------+-------------+------------------+-----------+--------+ |
Sponsored Link |