OpenStack Rocky : Add VM images to Glance2019/08/19 |
Add Virtual Machine images to Glance.
|
|
[1] |
Install KVM HyperVisor on Compute Host, refer to here.
It's unnecessarry to set Bridge networking on the section [3] of the link. |
[2] | For example, Create a Virtual Machine image of Debian 10. |
# create a disk image root@dlp ~(keystone)# qemu-img create -f qcow2 /var/kvm/images/debian10.img 10G
# install root@dlp ~(keystone)# virsh net-start default root@dlp ~(keystone)# virt-install \
--name debian10 \ --ram 2048 \ --disk path=/var/kvm/images/debian10.img,format=qcow2 \ --vcpus 2 \ --os-type linux \ --os-variant debian9 \ --network network=default \ --graphics none \ --console pty,target_type=serial \ --location 'http://ftp.jaist.ac.jp/pub/Linux/debian/dists/buster/main/installer-amd64/' \ --extra-args 'console=ttyS0,115200n8 serial'
Starting install...
# installation starts
# after finishing installation, Configure settings on VM for openstack instance Debian GNU/Linux 10 debian ttyS0 debian login: root Password:
root@debian:~#
apt update root@debian:~# apt -y install ssh cloud-init pollinate software-properties-common
root@debian:~#
vi /etc/default/grub # line 9: change like follows GRUB_DEFAULT=0 GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=0 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT=" console=tty1 console=ttyS0 "GRUB_CMDLINE_LINUX="" # line 33,34: comment out # GRUB_TERMINAL=serial# GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stopp=1"
root@debian:~#
update-grub
root@debian:~#
vi /etc/cloud/cloud.cfg # line 13: add (if you'd like to allow SSH password authentication to login)
ssh_pwauth: true
# line 87: change (if you'd like to allow [debian] user's SSH password auth) default_user: name: debian lock_passwd: False
root@debian:~#
vi /etc/network/interfaces # comment out all except loopback interface # allow-hotplug enp1s0# iface enp1s0 inet dhcp
# shutdown and finish root@debian:~# shutdown -h now
|
[3] | Add the Virtual Machine image to Glance. |
root@dlp ~(keystone)# openstack image create "Debian10" --file /var/kvm/images/debian10.img --disk-format qcow2 --container-format bare --public +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Field | Value | +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | checksum | 40152e1b4c9148903f96054520fb5833 | | container_format | bare | | created_at | 2019-08-09T05:09:50Z | | disk_format | qcow2 | | file | /v2/images/df87400f-1fdb-4ce7-a985-d8b3b9bcac55/file | | id | df87400f-1fdb-4ce7-a985-d8b3b9bcac55 | | min_disk | 0 | | min_ram | 0 | | name | Debian10 | | owner | f683c8a5418644f78f5bc9b7837cdd56 | | properties | os_hash_algo='sha512', os_hash_value='ec3addf0b68f772dc6a5125108da78ca35179cb6ac0b9bd49412ce8d82f7c15c280cf3116cbb97c003e98d59f259493f1cfbb9a59d9912ff8d4918df57de0c65', os_hidden='False' | | protected | False | | schema | /v2/schemas/image | | size | 1903230976 | | status | active | | tags | | | updated_at | 2019-08-09T05:10:02Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+root@dlp ~(keystone)# openstack image list +--------------------------------------+----------+--------+ | ID | Name | Status | +--------------------------------------+----------+--------+ | df87400f-1fdb-4ce7-a985-d8b3b9bcac55 | Debian10 | active | +--------------------------------------+----------+--------+ |
[4] | By the way, if you got an image from internet to add it in Glance, 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-06-13T04: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-06-13T04:46:29Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+ |
Sponsored Link |