From 6f18fe2b54df0a6cd5d4b6f4e2ad83c695d367f2 Mon Sep 17 00:00:00 2001 From: Erik Skultety Date: Wed, 24 May 2023 09:38:59 +0200 Subject: 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 --- lcitool/libvirt_wrapper.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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""" + + {name} + + {target} + + + """) + + 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,): -- cgit v1.1