Prepare placeholder image → Overwrite qcow2 image to oVirt Storage → Update engine DB


Downloads Path on oVirt Host/rhev/data-center/mnt/glusterSD/
Storage Path on oVirt Host /rhev/data-center/mnt/glusterSD

Download cloud image on oVirt Host

mkdir /rhev/data-center/mnt/glusterSD/
cd /rhev/data-center/mnt/glusterSD/
wget -O ubuntu-1804-bionic-amd64.qcow2
wget -O ubuntu-2004-focal-amd64.qcow2
wget -O ubuntu-2204-jammy-amd64.qcow2
wget -O ubuntu-1604-xenial-amd64.qcow2
wget -O centos-7-2111-amd64.qcow2
wget -O centos8-20220125-amd64.qcow2
wget -O rocky-86-amd64.qcow2
chown 36:36 *.qcow2
chcon system_u:object_r:fusefs_t:s0 *.qcow2
# cd /rhev/data-center/mnt/glusterSD/
# for IMG in *.qcow2; do SIZE=$(qemu-img info $IMG | grep bytes); echo -e "$SIZE\t$IMG"; done
virtual size: 8 GiB (8589934592 bytes)	centos-7-2111-amd64.qcow2
virtual size: 10 GiB (10737418240 bytes)	centos8-20220125-amd64.qcow2
virtual size: 10 GiB (10737418240 bytes)	rocky-86-amd64.qcow2
virtual size: 2.2 GiB (2361393152 bytes)	ubuntu-1604-xenial-amd64.qcow2
virtual size: 2.2 GiB (2361393152 bytes)	ubuntu-1804-bionic-amd64.qcow2
virtual size: 2.2 GiB (2361393152 bytes)	ubuntu-2004-focal-amd64.qcow2
virtual size: 2.2 GiB (2361393152 bytes)	ubuntu-2204-jammy-amd64.qcow2

Prepare placeholder image

Check metadata on oVirt Engine

# ssh # su postgres
bash-4.4$ psql
postgres=# \c engine
engine=# SELECT disk_id, disk_alias, disk_description FROM public.base_disks WHERE disk_alias ='cirros';
               disk_id                | disk_alias | disk_description
 c8b47c6c-8254-4df5-9166-9ae29500c278 | cirros     |
 23236b4d-0cd8-4395-987c-53f49c2c7897 | cirros     |
 5c49b8ae-90cb-43e5-bc24-1a00d7e7d474 | cirros     |
 a18e9b40-85f2-4c7c-9484-de70765df53a | cirros     |
 58e0be81-4b77-4b54-a639-91aaa5ee6c1b | cirros     |
 1df3e992-1993-4bf2-b2ce-1b88f6ed2640 | cirros     |
 c7103ab1-d84f-43c1-8e5b-cf20cd961720 | cirros     |
(7 rows)

Overwrite qcow2 image to oVirt Storage

function OVERWRITE_IMG(){
    DOWN=$1; STOR=$2; IMG=$3; SIZE=$4; ID=$5
    TARGET_IMG=$(find $STOR -type f | grep $ID | grep -vE 'meta|lease')
    chown 36:36 $TARGET_IMG
    chcon system_u:object_r:fusefs_t:s0 $TARGET_IMG
    sed -e "s#^DESCRIPTION.*#DESCRIPTION={\"DiskAlias\":\"$IMG\",\"DiskDescription\":\"$IMG\"}#g;" -i $TARGET_META
    sed -e "s#^CAP.*#CAP=$SIZE#g;" -i $TARGET_META
    echo $IMG


IMG=centos-7-2111-amd64.qcow2      ; SIZE=8589934592  ; ID=c8b47c6c-8254-4df5-9166-9ae29500c278; OVERWRITE_IMG $DOWN $STOR $IMG $SIZE $ID;
IMG=centos8-20220125-amd64.qcow2   ; SIZE=10737418240 ; ID=23236b4d-0cd8-4395-987c-53f49c2c7897; OVERWRITE_IMG $DOWN $STOR $IMG $SIZE $ID;
IMG=rocky-86-amd64.qcow2           ; SIZE=10737418240 ; ID=5c49b8ae-90cb-43e5-bc24-1a00d7e7d474; OVERWRITE_IMG $DOWN $STOR $IMG $SIZE $ID;
IMG=ubuntu-1604-xenial-amd64.qcow2 ; SIZE=2361393152  ; ID=a18e9b40-85f2-4c7c-9484-de70765df53a; OVERWRITE_IMG $DOWN $STOR $IMG $SIZE $ID;
IMG=ubuntu-1804-bionic-amd64.qcow2 ; SIZE=2361393152  ; ID=58e0be81-4b77-4b54-a639-91aaa5ee6c1b; OVERWRITE_IMG $DOWN $STOR $IMG $SIZE $ID;
IMG=ubuntu-2004-focal-amd64.qcow2  ; SIZE=2361393152  ; ID=1df3e992-1993-4bf2-b2ce-1b88f6ed2640; OVERWRITE_IMG $DOWN $STOR $IMG $SIZE $ID;
IMG=ubuntu-2204-jammy-amd64.qcow2  ; SIZE=2361393152  ; ID=c7103ab1-d84f-43c1-8e5b-cf20cd961720; OVERWRITE_IMG $DOWN $STOR $IMG $SIZE $ID;

Update metadata on oVirt Engine

function UPDATE_DISK(){
    cd /var/lib/pgsql
    sudo -u postgres psql -d engine -c "UPDATE public.base_disks
    SET disk_alias = '$ALIAS',
        disk_description = '$ALIAS'
    WHERE disk_id ='$ID';

    UPDATE public.images
    SET size = $SIZE
    WHERE image_group_id = '$ID';"
    cd -

ALIAS=centos-7-2111-amd64.qcow2      ; SIZE=8589934592  ; ID=c8b47c6c-8254-4df5-9166-9ae29500c278; UPDATE_DISK $ALIAS $SIZE $ID;
ALIAS=centos8-20220125-amd64.qcow2   ; SIZE=10737418240 ; ID=23236b4d-0cd8-4395-987c-53f49c2c7897; UPDATE_DISK $ALIAS $SIZE $ID;
ALIAS=rocky-86-amd64.qcow2           ; SIZE=10737418240 ; ID=5c49b8ae-90cb-43e5-bc24-1a00d7e7d474; UPDATE_DISK $ALIAS $SIZE $ID;
ALIAS=ubuntu-1604-xenial-amd64.qcow2 ; SIZE=2361393152  ; ID=a18e9b40-85f2-4c7c-9484-de70765df53a; UPDATE_DISK $ALIAS $SIZE $ID;
ALIAS=ubuntu-1804-bionic-amd64.qcow2 ; SIZE=2361393152  ; ID=58e0be81-4b77-4b54-a639-91aaa5ee6c1b; UPDATE_DISK $ALIAS $SIZE $ID;
ALIAS=ubuntu-2004-focal-amd64.qcow2  ; SIZE=2361393152  ; ID=1df3e992-1993-4bf2-b2ce-1b88f6ed2640; UPDATE_DISK $ALIAS $SIZE $ID;
ALIAS=ubuntu-2204-jammy-amd64.qcow2  ; SIZE=2361393152  ; ID=c7103ab1-d84f-43c1-8e5b-cf20cd961720; UPDATE_DISK $ALIAS $SIZE $ID;

Check Updated Images

  • No labels