OpenStack Victoria : Add VM Images2020/11/17 |
Add Virtual Machine images in Glance.
For example on here, add a CentOS 8 virtual machine image. |
|
[1] |
Install KVM HyperVisor, refer to here.
It's unnecessarry to set Bridge networking on the section [2] of the link. Fyrthermore, Install VM management tools, refer to here. |
[2] | Create a CentOS 8 image on Glance service Host. |
# download official image [root@dlp ~(keystone)]# virt-builder centos-8.2 --format qcow2 --size 10G -o /var/kvm/images/centos8.qcow2 --root-password password
# install [root@dlp ~(keystone)]# virt-install \
--name centos-8.2 \ --ram 2048 \ --disk path=/var/kvm/images/centos8.qcow2 \ --vcpus 2 \ --os-type linux \ --os-variant rhel8.2 \ --network network=default \ --graphics none \ --serial pty \ --console pty \ --boot hd \ --import # after starting VM, login and configure some necessary settings
CentOS Linux 8 (Core)
Kernel 4.18.0-193.6.3.el8_2.x86_64 on an x86_64
localhost login: root
# replace the interface name [enp1s0] to your own environment [root@localhost ~]# passwd root [root@localhost ~]# useradd centos [root@localhost ~]# passwd centos
[root@localhost ~]#
vi /etc/sysconfig/network-scripts/ifcfg-enp1s0 # disable the [UUID] line and also set [dhcp] for [BOOTPROTO] line #UUID="3ebe29b4-b7a3-49d6-997a-ee8b78749840" BOOTPROTO="dhcp"[root@localhost ~]# dnf -y install cloud-init openssh-server
[root@localhost ~]#
vi /etc/cloud/cloud.cfg # line 5: if you'd like to allo SSH password auth, change to [1] ssh_pwauth: 1 # line 57, 58: change to [centos] as default user # if you'd like to allow SSH password auth to the user, chage like follows system_info: default_user: name: centos lock_passwd: false[root@localhost ~]# systemctl enable cloud-init sshd [root@localhost ~]# shutdown -h now |
[3] | Add the virtual image to Glance. |
[root@dlp ~(keystone)]# openstack image create "CentOS8" --file /var/kvm/images/centos8.qcow2 --disk-format qcow2 --container-format bare --public +------------------+-----------------------------------------------------------------------------+ | Field | Value | +------------------+-----------------------------------------------------------------------------+ | container_format | bare | | created_at | 2020-11-17T01:11:10Z | | disk_format | qcow2 | | file | /v2/images/8507b98f-3e9d-4ac9-92f9-9ee8d7f69339/file | | id | 8507b98f-3e9d-4ac9-92f9-9ee8d7f69339 | | min_disk | 0 | | min_ram | 0 | | name | CentOS8 | | owner | bd0827a1282f45f28c4100b77289eb0a | | properties | os_hidden='False', owner_specified.openstack.md5='', owner_specified.ope... | | protected | False | | schema | /v2/schemas/image | | status | queued | | tags | | | updated_at | 2020-11-17T01:11:10Z | | visibility | public | +------------------+-----------------------------------------------------------------------------+[root@dlp ~(keystone)]# openstack image list +--------------------------------------+---------+--------+ | ID | Name | Status | +--------------------------------------+---------+--------+ | 8507b98f-3e9d-4ac9-92f9-9ee8d7f69339 | CentOS8 | 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/20.04/release/ubuntu-20.04-server-cloudimg-amd64.img -P /var/kvm/images
openstack image create "Ubuntu2004-Official" --file /var/kvm/images/ubuntu-20.04-server-cloudimg-amd64.img --disk-format qcow2 --container-format bare --public +------------------+----------------------------------------------------------------------------------------------+ | Field | Value | +------------------+----------------------------------------------------------------------------------------------+ | checksum | be096b5b3c1a28f9416deed0253ad3e2 | | container_format | bare | | created_at | 2020-06-04T03:43:24Z | | disk_format | qcow2 | | file | /v2/images/ecfb5b90-eb90-436e-b853-16ede5f55bda/file | | id | ecfb5b90-eb90-436e-b853-16ede5f55bda | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu2004-Official | | owner | 3227cdd34d5c4d9c97eeb8f0dfdf5d0e | | properties | os_hash_algo='sha512', os_hash_value='1cbc97f05e9de86ea571dd154b855dd217de51905367e9599c1... | | protected | False | | schema | /v2/schemas/image | | size | 533856256 | | status | active | | tags | | | updated_at | 2020-06-04T03:43:27Z | | visibility | public | +------------------+----------------------------------------------------------------------------------------------+ |
Sponsored Link |
|