diff options
author | Erik Skultety <eskultet@redhat.com> | 2023-05-24 09:38:59 +0200 |
---|---|---|
committer | Erik Skultety <eskultet@redhat.com> | 2023-06-22 12:05:04 +0000 |
commit | 6f18fe2b54df0a6cd5d4b6f4e2ad83c695d367f2 (patch) | |
tree | b323abac3e38399464a07d8ba2674ce233af1644 | |
parent | 7e29a8bf626a01630c40bfd56bee2df336540ad2 (diff) | |
download | libvirt-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.py | 17 |
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,): |