aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Skultety <eskultet@redhat.com>2023-05-24 09:38:59 +0200
committerErik Skultety <eskultet@redhat.com>2023-06-22 12:05:04 +0000
commit6f18fe2b54df0a6cd5d4b6f4e2ad83c695d367f2 (patch)
treeb323abac3e38399464a07d8ba2674ce233af1644
parent7e29a8bf626a01630c40bfd56bee2df336540ad2 (diff)
downloadlibvirt-ci-6f18fe2b54df0a6cd5d4b6f4e2ad83c695d367f2.zip
libvirt-ci-6f18fe2b54df0a6cd5d4b6f4e2ad83c695d367f2.tar.gz
libvirt-ci-6f18fe2b54df0a6cd5d4b6f4e2ad83c695d367f2.tar.bz2
libvirt_wrapper: Add a simple helper to create a transient 'dir' pool
The idea behind this trivial helper was inspired by virt-manager and in essence should allow us to fetch data about a backing store volume using libvirt which we'd otherwise have to do ourselves. The pool is supposed to be destroyed by the caller when the backing store volume is processed. Signed-off-by: Erik Skultety <eskultet@redhat.com>
-rw-r--r--lcitool/libvirt_wrapper.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/lcitool/libvirt_wrapper.py b/lcitool/libvirt_wrapper.py
index 7f1eda7..7db954e 100644
--- a/lcitool/libvirt_wrapper.py
+++ b/lcitool/libvirt_wrapper.py
@@ -159,6 +159,23 @@ class LibvirtStoragePoolObject(LibvirtAbstractObject):
if volobj:
return LibvirtStorageVolObject(self, volobj)
+ @staticmethod
+ def _create_transient_pool(conn, name, target):
+ """Creates a transient pool of type 'dir'"""
+
+ pool_xml = textwrap.dedent(
+ f"""
+ <pool type='dir'>
+ <name>{name}</name>
+ <target>
+ <path>{target}</path>
+ </target>
+ </pool>
+ """)
+
+ conn.storagePoolCreateXML(pool_xml)
+ return conn.storagePoolLookupByName(name)
+
def create_volume(self, name, capacity, allocation=None, _format="qcow2",
units='bytes', owner=None, group=None, mode=None,):