From 0faa024ad90edee1bd8d7810e4d48c08f65f0877 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Mon, 5 Sep 2022 10:41:07 +0200 Subject: [PATCH] backend: less error-prone libvirt-list'ing --- roles/copr/backend/files/provision/libvirt-list | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/copr/backend/files/provision/libvirt-list b/roles/copr/backend/files/provision/libvirt-list index 118ba1198c..70e4d4f413 100755 --- a/roles/copr/backend/files/provision/libvirt-list +++ b/roles/copr/backend/files/provision/libvirt-list @@ -7,6 +7,7 @@ LibVirt hypervisor. """ import os +import re import argparse import sys import libvirt @@ -42,9 +43,15 @@ def _main(): # List all the volumes in the 'images' pool that seem to be related to given # Pool name pool = conn.storagePoolLookupByName("images") + + # Some of those suffixes are used by Red Hat Copr + known_suffixes = ["_root_disk$", "_config_cd$", "_swap$", "_root$", "_config$"] + for volume in pool.listVolumes(): if volume.startswith(pool_id): - vm_names.add(volume.rsplit("_", 1)[0]) + for suffix in known_suffixes: + volume = re.sub(suffix, "", volume) + vm_names.add(volume) # List all domains that are related to given Pool (just to be 100% sure, but # this shouldn't add any new items to the vm_names set actually).