]>
git.ipfire.org Git - nitsi.git/blob - disk.py
11 def __init__(self
, disk
):
12 self
.con
= guestfs
.GuestFS(python_return_dict
=True)
13 self
.con
.add_drive_opts(disk
, format
="qcow2")
15 def mount(self
, uuid
, path
):
17 part
= self
.con
.findfs_uuid(uuid
)
18 self
.con
.mount(part
, path
)
20 def copy_in(self
, fr
, to
):
21 tmp
= tempfile
.mkstemp()
23 with tarfile
.open(tmp
, "w") as tar
:
25 tar
.add(file, arcname
=os
.path
.basename(file))
26 self
.con
.tar_in_opts(tmp
, to
)
28 def umount(self
, path
):
29 self
.con
.umount_opts(path
)
35 # test = disk("/var/lib/libvirt/images/alice.qcow2")
36 # test.mount("45598e92-3487-4a1b-961d-79aa3dd42a7d", "/")
37 # test.copy_in("/home/jonatan/nitsi/libguestfs-test", "/root/")