[virt-tools-list] [virt-manager PATCH 7/7] installer: add support for windows unattended install
Fabiano Fidêncio
fidencio at redhat.com
Thu Mar 28 21:44:48 UTC 2019
The Windows unattended installation is quite similar to the Linux one
with a few major differences:
- It uses floppy injection instead of initrd injection
- Yes, it does. Then we have to create a floppy, add the device and,
when finishing the installation, remove the device;
- There's no InstallerTreeMedia in the game making us end up duplicating
some code in the Installer class as:
- keeping track of files that have to be cleanup up;
- actually cleaning up the files;
- generating the install script
Apart from that, some obvious differences in the scripts where already
done in a previous commit, but those were basically:
- Not using /dev/*da as a target disk, but use "C" instead;
- Set the product-key
- Explicitly set the injection method as "floppy"
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
virt-install | 9 +++++----
virtinst/installer.py | 21 ++++++++++++++++++++-
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/virt-install b/virt-install
index 57835849..40ea86eb 100755
--- a/virt-install
+++ b/virt-install
@@ -449,10 +449,11 @@ def build_installer(options, guest):
if options.unattended:
if options.os_variant.is_none or options.os_variant.is_auto:
fail(_("--unattended requires an explicit --os-variant"))
- if options.cdrom:
- options.location = options.cdrom
- options.cdrom = None
- options.os_variant.install = "location"
+ if not guest.osinfo.is_windows():
+ if options.cdrom:
+ options.location = options.cdrom
+ options.cdrom = None
+ options.os_variant.install = "location"
if options.os_variant.install == "location":
if not options.location:
diff --git a/virtinst/installer.py b/virtinst/installer.py
index 2ae20a84..c2ce3e5d 100644
--- a/virtinst/installer.py
+++ b/virtinst/installer.py
@@ -13,8 +13,10 @@ import libvirt
from .devices import DeviceDisk
from .domain import DomainOs
-from .osdict import OSDB
+from .osdict import OSDB, OsMedia
from .installertreemedia import InstallerTreeMedia
+from .floppyinject import perform_floppy_injections
+from . import unattended
from . import util
@@ -207,10 +209,26 @@ class Installer(object):
self._install_initrd = i
if a and "VIRTINST_INITRD_TEST" not in os.environ:
self.extra_args.append(a)
+ elif self._unattended_data:
+ osguess = OSDB.guess_os_by_iso(self.cdrom)
+ osmedia = OsMedia(osguess[1])
+ script = unattended.prepare_install_script(
+ guest, self._unattended_data, self.cdrom, osmedia)
+ path, _ = unattended.generate_install_script(script)
+ logging.debug("Generated unattended script: %s", path)
+ logging.debug("Generated script contents:\n%s",
+ open(path).read())
+
+ floppy = perform_floppy_injections([path], util.get_cache_dir())
+ self._add_install_floppy_device(guest, floppy)
+
+ self._unattended_files.extend([path, floppy])
def _cleanup(self, guest):
if self._treemedia:
self._treemedia.cleanup(guest)
+ elif self._unattended_files:
+ self._cleanup_unattended_files()
def _get_postinstall_bootdev(self, guest):
if self.cdrom and self.livecd:
@@ -353,6 +371,7 @@ class Installer(object):
return ret
finally:
self._remove_install_cdrom_media(guest)
+ self._remove_install_floppy_device(guest)
self._finish_get_install_xml(guest, data)
def _build_xml(self, guest, meter):
--
2.20.1
More information about the virt-tools-list
mailing list