copr-be: don't require additional helpers.py edits
This commit is contained in:
parent
99e373a3ea
commit
d923eb6877
3 changed files with 12 additions and 20 deletions
|
@ -1,8 +1,3 @@
|
|||
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,8 +12,6 @@ import time
|
|||
|
||||
import libvirt
|
||||
|
||||
from helpers import get_volume_pools
|
||||
|
||||
def repeat(call, args):
|
||||
""" Repeat the given function call, with args """
|
||||
attempts = 3
|
||||
|
@ -61,8 +59,11 @@ def _main():
|
|||
except Exception:
|
||||
logging.exception("domain can't be removed")
|
||||
|
||||
for pool_name in get_volume_pools():
|
||||
pool = repeat(conn.storagePoolLookupByName, (pool_name,))
|
||||
|
||||
for pool in repeat(conn.listAllStoragePools, ()):
|
||||
if pool.name() not in ["images", "swap-space"]:
|
||||
continue
|
||||
|
||||
for volume_name in repeat(pool.listVolumes, ()):
|
||||
if not volume_name.startswith(args.domainname):
|
||||
continue
|
||||
|
|
|
@ -11,7 +11,7 @@ import re
|
|||
import argparse
|
||||
import sys
|
||||
import libvirt
|
||||
from helpers import get_hv_identification_from_pool_id, get_volume_pools
|
||||
from helpers import get_hv_identification_from_pool_id
|
||||
|
||||
|
||||
def _get_parser():
|
||||
|
@ -40,20 +40,16 @@ def _main():
|
|||
# Gather the list of all domains here
|
||||
vm_names = set()
|
||||
|
||||
# Some of those suffixes are used by Red Hat Copr
|
||||
# Some of those are used by Red Hat Copr
|
||||
known_suffixes = ["_root_disk$", "_config_cd$", "_swap$", "_root$", "_config$"]
|
||||
volume_pool_names = get_volume_pools()
|
||||
|
||||
for pool_name in volume_pool_names:
|
||||
try:
|
||||
pool = conn.storagePoolLookupByName(pool_name)
|
||||
except libvirt.libvirtError:
|
||||
msg = "Pool {0} not found\n".format(pool_name)
|
||||
sys.stderr.write(msg)
|
||||
continue
|
||||
known_pools = ["images", "swap-space"]
|
||||
|
||||
for pool in conn.listAllStoragePools():
|
||||
# List all the volumes in the volume pool that seem to be related to
|
||||
# the given Pool name
|
||||
if pool.name() not in known_pools:
|
||||
continue
|
||||
|
||||
for volume in pool.listVolumes():
|
||||
if volume.startswith(pool_id):
|
||||
for suffix in known_suffixes:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue