[virt-tools-list] [virt-manager PATCH 03/12] floppyinject: Simplify perform_floppy_injections()
Fabiano Fidêncio
fidencio at redhat.com
Thu Jun 6 14:11:34 UTC 2019
Instead of passing a scratch dir and creating another dir inside it,
let's just take advantage of util's util.make_unattended_cache_dir() and
create the "unattended.img" file there.
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
virtinst/floppyinject.py | 11 +++++------
virtinst/installer.py | 2 +-
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/virtinst/floppyinject.py b/virtinst/floppyinject.py
index 05f91ee0..baa38b8f 100644
--- a/virtinst/floppyinject.py
+++ b/virtinst/floppyinject.py
@@ -7,20 +7,19 @@
import logging
import os
import subprocess
-import tempfile
+from . import util
-def perform_floppy_injections(injections, scratchdir):
+
+def perform_floppy_injections(injections):
"""
Insert files into the root directory of a floppy
"""
if not injections:
return
- tempdir = tempfile.mkdtemp(dir=scratchdir)
- os.chmod(tempdir, 0o775)
-
- img = os.path.join(tempdir, "unattended.img")
+ scratch = util.make_unattended_cache_dir()
+ img = os.path.join(scratch, "unattended.img")
cmd = ["mkfs.msdos", "-C", img, "1440"]
logging.debug("Running mkisofs: %s", cmd)
diff --git a/virtinst/installer.py b/virtinst/installer.py
index 45caf930..e1f4e542 100644
--- a/virtinst/installer.py
+++ b/virtinst/installer.py
@@ -225,7 +225,7 @@ class Installer(object):
logging.debug("Generated script contents:\n%s",
open(path).read())
- floppy = perform_floppy_injections([path], util.get_cache_dir())
+ floppy = perform_floppy_injections([path])
self._add_install_floppy_device(guest, floppy)
self._unattended_files.extend([path, floppy])
--
2.21.0
More information about the virt-tools-list
mailing list