backend: less error-prone libvirt-list'ing
This commit is contained in:
parent
b6669bc5f6
commit
0faa024ad9
1 changed files with 8 additions and 1 deletions
|
@ -7,6 +7,7 @@ LibVirt hypervisor.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
import libvirt
|
import libvirt
|
||||||
|
@ -42,9 +43,15 @@ def _main():
|
||||||
# List all the volumes in the 'images' pool that seem to be related to given
|
# List all the volumes in the 'images' pool that seem to be related to given
|
||||||
# Pool name
|
# Pool name
|
||||||
pool = conn.storagePoolLookupByName("images")
|
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():
|
for volume in pool.listVolumes():
|
||||||
if volume.startswith(pool_id):
|
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
|
# 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).
|
# this shouldn't add any new items to the vm_names set actually).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue