Prepare placeholder image → Overwrite qcow2 image to oVirt Storage → Update engine DB
Environment
oVirt Engine | engine.ovirt1.int | |
---|---|---|
oVirt Host | n1.ovirt1.int | |
Downloads Path on oVirt Host | /rhev/data-center/mnt/glusterSD/n1.ovirt1.int:_vmstore01/downloads | |
Storage Path on oVirt Host | /rhev/data-center/mnt/glusterSD |
Download cloud image on oVirt Host
mkdir /rhev/data-center/mnt/glusterSD/n1.ovirt1.int:_vmstore01/downloads cd /rhev/data-center/mnt/glusterSD/n1.ovirt1.int:_vmstore01/downloads wget https://cloud-images.ubuntu.com/bionic/20220712/bionic-server-cloudimg-amd64.img -O ubuntu-1804-bionic-amd64.qcow2 wget https://cloud-images.ubuntu.com/focal/20220712/focal-server-cloudimg-amd64.img -O ubuntu-2004-focal-amd64.qcow2 wget https://cloud-images.ubuntu.com/jammy/20220712/jammy-server-cloudimg-amd64.img -O ubuntu-2204-jammy-amd64.qcow2 wget https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img -O ubuntu-1604-xenial-amd64.qcow2 wget https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2111.qcow2 -O centos-7-2111-amd64.qcow2 wget https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-20220125.1.x86_64-amd64.qcow2 -O centos8-20220125-amd64.qcow2 wget https://download.rockylinux.org/pub/rocky/8/images/Rocky-8-GenericCloud-8.6.20220702.0.x86_64-amd64.qcow2 -O rocky-86-amd64.qcow2 chown 36:36 *.qcow2 chcon system_u:object_r:fusefs_t:s0 *.qcow2
# cd /rhev/data-center/mnt/glusterSD/n1.ovirt1.int:_vmstore01/downloads # 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 engine.ovirt1.int engine.ovirt1.int # 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') TARGET_META=$TARGET_IMG.meta mv $DOWN/$IMG $TARGET_IMG 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 } DOWN=/rhev/data-center/mnt/glusterSD/n1.ovirt1.int:_vmstore01/downloads STOR=/rhev/data-center/mnt/glusterSD/n1.ovirt1.int:_vmstore01 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(){ ALIAS=$1 SIZE=$2 ID=$3 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