backend: libvirt-delete: allow searching volumes in other pools
This commit is contained in:
parent
f54c597aa7
commit
99e373a3ea
3 changed files with 19 additions and 11 deletions
|
@ -1,3 +1,8 @@
|
|||
def get_volume_pools():
|
||||
""" Get a list of pools where to search for Resalloc-related volumes """
|
||||
return ["images"]
|
||||
|
||||
|
||||
def get_hv_identification_from_pool_id(pool_id):
|
||||
""" Get unique ID of the hypervisor """
|
||||
if pool_id.startswith("copr_hv_x86_64_01"):
|
||||
|
|
|
@ -12,6 +12,8 @@ import time
|
|||
|
||||
import libvirt
|
||||
|
||||
from helpers import get_volume_pools
|
||||
|
||||
def repeat(call, args):
|
||||
""" Repeat the given function call, with args """
|
||||
attempts = 3
|
||||
|
@ -59,15 +61,16 @@ def _main():
|
|||
except Exception:
|
||||
logging.exception("domain can't be removed")
|
||||
|
||||
pool = repeat(conn.storagePoolLookupByName, ("images",))
|
||||
for volume_name in repeat(pool.listVolumes, ()):
|
||||
if not volume_name.startswith(args.domainname):
|
||||
continue
|
||||
try:
|
||||
repeat(_delete_volume, (pool, volume_name,))
|
||||
logging.info("volume %s removed", volume_name)
|
||||
except Exception:
|
||||
logging.exception("volume %s can not be removed", volume_name)
|
||||
for pool_name in get_volume_pools():
|
||||
pool = repeat(conn.storagePoolLookupByName, (pool_name,))
|
||||
for volume_name in repeat(pool.listVolumes, ()):
|
||||
if not volume_name.startswith(args.domainname):
|
||||
continue
|
||||
try:
|
||||
repeat(_delete_volume, (pool, volume_name,))
|
||||
logging.info("volume %s removed", volume_name)
|
||||
except Exception:
|
||||
logging.exception("volume %s can not be removed", volume_name)
|
||||
|
||||
if __name__ == "__main__":
|
||||
_main()
|
||||
|
|
|
@ -11,7 +11,7 @@ import re
|
|||
import argparse
|
||||
import sys
|
||||
import libvirt
|
||||
from helpers import get_hv_identification_from_pool_id
|
||||
from helpers import get_hv_identification_from_pool_id, get_volume_pools
|
||||
|
||||
|
||||
def _get_parser():
|
||||
|
@ -42,7 +42,7 @@ def _main():
|
|||
|
||||
# Some of those suffixes are used by Red Hat Copr
|
||||
known_suffixes = ["_root_disk$", "_config_cd$", "_swap$", "_root$", "_config$"]
|
||||
volume_pool_names = ["images", "swap-space"]
|
||||
volume_pool_names = get_volume_pools()
|
||||
|
||||
for pool_name in volume_pool_names:
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue