CentOS Stream 9
Sponsored Link

OpenStack Caracal : Add VM Images2024/08/06

 

Add Virtual Machine images in Glance.
For example on here, add a CentOS Stream 9 virtual machine image.

[1]

Install KVM HyperVisor, refer to here.
It's unnecessary to set Bridge networking on the section [2] of the link.
Furthermore, Install VM management tools, refer to here.

[2] Create a CentOS Stream 9 image on Glance service Host.
Download the ISO image of CentOS Stream 9 first into a directory before it.
# create a directory for disk image

[root@dlp ~(keystone)]#
mkdir -p /var/kvm/images
# create a disk image

[root@dlp ~(keystone)]#
qemu-img create -f qcow2 /var/kvm/images/centos-st9.img 10G
# install

[root@dlp ~(keystone)]#
virt-install \
--name centos-st9 \
--ram 4096 \
--disk path=/var/kvm/images/centos-st9.img,format=qcow2 \
--vcpus 2 \
--os-variant centos-stream9 \
--network network=default \
--graphics none \
--console pty,target_type=serial \
--location /home/CentOS-Stream-9-latest-x86_64-dvd1.iso \
--extra-args 'console=ttyS0,115200n8'
Starting install...
# after installing OS, login to the VM and configure necessary settings

CentOS Stream 9
Kernel 5.14.0-419.el9.x86_64 on an x86_64

Activate the web console with: systemctl enable --now cockpit.socket

localhost login: root

[root@localhost ~]#
useradd centos

[root@localhost ~]#
passwd centos
[root@localhost ~]#
dnf -y install cloud-init openssh-server

[root@localhost ~]#
vi /etc/cloud/cloud.cfg
# line 16 : if you like to allow SSH password auth, change to [1]
ssh_pwauth:   true

# line 96, 97 : 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

# remove existing interface

[root@localhost ~]#
nmcli device

]DEVICE  TYPE      STATE      CONNECTION
enp1s0  ethernet  connected  enp1s0
lo      loopback  unmanaged  --
[root@localhost ~]#
nmcli connection del enp1s0

Connection 'enp1s0' (81c5724e-b006-364b-9715-b4e4bc227325) successfully deleted.
[root@localhost ~]#
systemctl enable cloud-init sshd

[root@localhost ~]#
shutdown -h now

# finally, undefine the VM

[root@dlp ~(keystone)]#
virsh undefine centos-st9

[3] Add the virtual image to Glance.
[root@dlp ~(keystone)]#
openstack image create "CentOS-Stream9" --file /var/kvm/images/centos-st9.img --disk-format qcow2 --container-format bare --public

+------------------+-----------------------------------------------------------------------------+
| Field            | Value                                                                       |
+------------------+-----------------------------------------------------------------------------+
| container_format | bare                                                                        |
| created_at       | 2024-08-06T00:24:49Z                                                        |
| disk_format      | qcow2                                                                       |
| file             | /v2/images/cfa9783d-ca91-4e3b-8016-81e3336bd5f0/file                        |
| id               | cfa9783d-ca91-4e3b-8016-81e3336bd5f0                                        |
| min_disk         | 0                                                                           |
| min_ram          | 0                                                                           |
| name             | CentOS-Stream9                                                              |
| owner            | b62e60c6d4b7406a90eee2f2d9c45917                                            |
| properties       | os_hidden='False', owner_specified.openstack.md5='', owner_specified.ope... |
| protected        | False                                                                       |
| schema           | /v2/schemas/image                                                           |
| status           | queued                                                                      |
| tags             |                                                                             |
| updated_at       | 2024-08-06T00:24:49Z                                                        |
| visibility       | public                                                                      |
+------------------+-----------------------------------------------------------------------------+

[root@dlp ~(keystone)]#
openstack image list

+--------------------------------------+----------------+--------+
| ID                                   | Name           | Status |
+--------------------------------------+----------------+--------+
| cfa9783d-ca91-4e3b-8016-81e3336bd5f0 | CentOS-Stream9 | active |
+--------------------------------------+----------------+--------+
[4] By the way, if you got an image from internet, it's OK to simply add it like follows.
[root@dlp ~(keystone)]#
wget http://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img
[root@dlp ~(keystone)]#
openstack image create "Ubuntu2404-Official" --file ubuntu-24.04-server-cloudimg-amd64.img --disk-format qcow2 --container-format bare --public

+------------------+-----------------------------------------------------------+
| Field            | Value                                                     |
+------------------+-----------------------------------------------------------+
| container_format | bare                                                      |
| created_at       | 2024-05-21T00:18:05Z                                      |
| disk_format      | qcow2                                                     |
| file             | /v2/images/7620a182-99f2-4132-9c6e-4b2da962b241/file      |
| id               | 7620a182-99f2-4132-9c6e-4b2da962b241                      |
| min_disk         | 0                                                         |
| min_ram          | 0                                                         |
| name             | Ubuntu2404                                                |
| owner            | 9c5145f76fd84324bdd2b1b61658a282                          |
| properties       | os_hidden='False', owner_specified.openstack.md5='',      |
|                  | owner_specified.openstack.object='images/Ubuntu2404',     |
|                  | owner_specified.openstack.sha256=''                       |
| protected        | False                                                     |
| schema           | /v2/schemas/image                                         |
| status           | queued                                                    |
| tags             |                                                           |
| updated_at       | 2024-05-21T00:18:05Z                                      |
| visibility       | public                                                    |
+------------------+-----------------------------------------------------------+
Matched Content