OpenStack Rocky : Add VM Images2018/08/31 |
Add Virtual Machine images in Glance.
For example on here, create and add CentOS 7 virtual machine image. |
|
[1] |
Install KVM HyperVisor, refer to here.
It's unnecessarry to set Bridge networking on the section [2] of the link. |
[2] | Create CentOS 7 image on Glance Host. |
# 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] * Install [cloud-init] package and enable [cloud-init] service, and also add a user whose name is [centos] |
[3] | Add the virtual image to Glance. |
[root@dlp ~(keystone)]# openstack image create "CentOS7" --file /var/kvm/images/centos7.img --disk-format qcow2 --container-format bare --public +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Field | Value | +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | checksum | f6516ab092ecbe691ac21ebc186b6253 | | container_format | bare | | created_at | 2018-08-31T01:57:06Z | | disk_format | qcow2 | | file | /v2/images/05269b20-9625-46b6-8377-3893c70906bd/file | | id | 05269b20-9625-46b6-8377-3893c70906bd | | min_disk | 0 | | min_ram | 0 | | name | CentOS7 | | owner | 2cb4b9d73bcc46449f711794506c3faf | | properties | os_hash_algo='sha512', os_hash_value='3da7d126bea073906fbd6c3b8080d87f47dbb22ddfdfbd4196ec8a3c9d2cf857050a4178e42c35ce83dc73a1470df88f12e7c499eb337130a792b1e0111bf90d', os_hidden='False' | | protected | False | | schema | /v2/schemas/image | | size | 1421869056 | | status | active | | tags | | | updated_at | 2018-08-31T01:57:15Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+[root@dlp ~(keystone)]# openstack image list +--------------------------------------+---------+--------+ | ID | Name | Status | +--------------------------------------+---------+--------+ | 05269b20-9625-46b6-8377-3893c70906bd | CentOS7 | active | +--------------------------------------+---------+--------+ |
[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/18.04/release/ubuntu-18.04-server-cloudimg-amd64.img -P /var/kvm/images
openstack image create "Ubuntu1804" --file /var/kvm/images/ubuntu-18.04-server-cloudimg-amd64.img --disk-format qcow2 --container-format bare --public +------------------+------------------------------------------------------+ | Field | Value | +------------------+------------------------------------------------------+ | checksum | d7912161a35c8e8cc384589601751dd8 | | container_format | bare | | created_at | 2018-08-31T04:46:27Z | | disk_format | qcow2 | | file | /v2/images/7e22891e-9d01-49b4-9eb2-4b02dbab051c/file | | id | 7e22891e-9d01-49b4-9eb2-4b02dbab051c | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu1804 | | owner | 12d80218a35e4c62aa0403e92b5b649a | | protected | False | | schema | /v2/schemas/image | | size | 336461824 | | status | active | | tags | | | updated_at | 2018-08-31T04:46:29Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+ |
Sponsored Link |