OpenStack Newton : Add VM Images2016/10/22 |
Add Virtual Machine images in Glance.
|
|
[1] | 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
|
[2] |
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 |
[3] | 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 | 1fc0c3cc0f3e581fd046e7a64fe974ff | | container_format | bare | | created_at | 2016-10-21T17:21:44Z | | disk_format | qcow2 | | id | 6afd28b3-6056-4c30-bd47-93fb26cc5062 | | min_disk | 0 | | min_ram | 0 | | name | CentOS7 | | owner | 150e205a8791426e8028a94699fb8848 | | protected | False | | size | 1101660160 | | status | active | | tags | [] | | updated_at | 2016-10-21T17:21:49Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------+[root@dlp ~(keystone)]# glance image-list +--------------------------------------+---------+ | ID | Name | +--------------------------------------+---------+ | 6afd28b3-6056-4c30-bd47-93fb26cc5062 | CentOS7 | +--------------------------------------+---------+ |
[4] | By the way, if you got an image from internet, it's OK to simply add it like follows. |
[root@dlp ~(keystone)]#
[root@dlp ~(keystone)]# wget http://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P /var/kvm/images
glance image-create --name "Ubuntu1604" --file /var/kvm/images/ubuntu-16.04-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare --visibility public +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 3dc12c0950321bb114279959ffb239d8 | | container_format | bare | | created_at | 2016-10-21T17:23:57Z | | disk_format | qcow2 | | id | 1f9224fa-63ca-475a-b595-3ad87dd900ad | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu1604 | | owner | 150e205a8791426e8028a94699fb8848 | | protected | False | | size | 313851904 | | status | active | | tags | [] | | updated_at | 2016-10-21T17:23:58Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------+ |
Sponsored Link |
|