OpenStack Mitaka : Add VM Images2016/04/12 |
Add Virtual Machine images in Glance.
|
|
[1] | Load environment variables first. |
[root@dlp ~]# unset OS_TOKEN OS_URL
[root@dlp ~]#
vi ~/keystonerc
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default export OS_PROJECT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=adminpassword export OS_AUTH_URL=http://10.0.0.30:35357/v3 export OS_IDENTITY_API_VERSION=3 export PS1='[\u@\h \W(keystone)]\$ '
[root@dlp ~]#
chmod 600 ~/keystonerc [root@dlp ~]# source ~/keystonerc [root@dlp ~(keystone)]# echo "source ~/keystonerc " >> ~/.bash_profile
# display status (it's OK if no error is shown) [root@dlp ~(keystone)]# glance image-list
+----+------+ | ID | Name | +----+------+ +----+------+ |
[2] | For example, Create a Virtual Machine image of CentOS 7. |
# create a disk image [root@dlp ~(keystone)]# qemu-img create -f qcow2 /var/kvm/images/centos7.img 10G
# install [root@dlp ~(keystone)]# virt-install \
Starting install...
--name centos7 \ --ram 2048 \ --disk path=/var/kvm/images/centos7.img,format=qcow2 \ --vcpus 2 \ --os-type linux \ --os-variant rhel7 \ --graphics none \ --console pty,target_type=serial \ --location 'http://ftp.iij.ad.jp/pub/linux/centos/7/os/x86_64/' \ --extra-args '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 |
[4] | Add the virtual image to Glance. |
[root@dlp ~(keystone)]# glance image-create --name "CentOS7" --file /var/kvm/images/centos7.img --disk-format qcow2 --container-format bare --visibility public +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 98ab5e50d4870f85177937e5ae26d262 | | container_format | bare | | created_at | 2016-04-12T13:21:00Z | | disk_format | qcow2 | | id | 087d827e-3c60-41fb-8592-a234a3bf15c5 | | min_disk | 0 | | min_ram | 0 | | name | CentOS7 | | owner | c70760f08db7408e908c7d035eae109a | | protected | False | | size | 1105723392 | | status | active | | tags | [] | | updated_at | 2016-04-12T13:21:05Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------+[root@dlp ~(keystone)]# glance image-list +--------------------------------------+---------+ | ID | Name | +--------------------------------------+---------+ | 087d827e-3c60-41fb-8592-a234a3bf15c5 | CentOS7 | +--------------------------------------+---------+ |
[5] | By the way, if you got an image from internet, it's OK to simply add it like follows. |
root@dlp:~#
root@dlp:~# wget http://cloud-images.ubuntu.com/releases/14.04.3/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img -P /var/kvm/images
glance image-create --name "Ubuntu1404" --file /var/kvm/images/ubuntu-14.04-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare --visibility public +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 4263306b9755eade84578f8ca27f8164 | | container_format | bare | | created_at | 2015-11-14T12:16:12Z | | disk_format | qcow2 | | id | d3c09925-4eb1-40c7-ba18-d27d496eb64a | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu1404 | | owner | d625e02b3d394afbad250def2f88fefa | | protected | False | | size | 258671104 | | status | active | | tags | [] | | updated_at | 2015-11-14T12:16:13Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------+ |
Sponsored Link |
|