[virt-tools-list] [virt-manager PATCH v3 5/9] unattended: Properly set the installation source
Fabiano Fidêncio
fidencio at redhat.com
Thu Mar 7 12:52:54 UTC 2019
The installation source, which can be either "media" or "network",
should be properly set depending on whether we're installing from a
media or performing a tree based installation.
We have to mind here that any media that is set as "netinstall" variant
has to have its installation source set accordingly.
An different approach for this would be to generate the script
specifically from the media whenever a media is passed. However, IMO, it
would just add two new codepaths and having the media passed around
without a real gain against the method chosen.
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
virtinst/unattended.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/virtinst/unattended.py b/virtinst/unattended.py
index ebfaae8a..b452c33e 100644
--- a/virtinst/unattended.py
+++ b/virtinst/unattended.py
@@ -16,6 +16,7 @@ from gi.repository import Gio
from gi.repository import GLib
from . import util
+from .osdict import _OsinfoIter
def _make_installconfig(script, osobj, unattended_data, arch, hostname, url):
@@ -229,13 +230,28 @@ class UnattendedData():
def prepare_install_script(guest, unattended_data, url=None, media=None):
+ # This is ugly, but that's only the current way to deal with netinstall
+ # medias.
+ def _get_installation_source(media):
+ if not media:
+ return "network"
+
+ variant_list = list(_OsinfoIter(media.get_os_variants()))
+ for variant in variant_list:
+ if "netinst" in variant.get_id():
+ return "network"
+
+ return "media"
+
rawscript = guest.osinfo.get_install_script(unattended_data.profile)
script = OSInstallScript(rawscript, guest.osinfo)
# For all tree based installations we're going to perform initrd injection
# and install the systems via network.
script.set_preferred_injection_method("initrd")
- script.set_installation_source("network")
+
+ installationsource = _get_installation_source(media)
+ script.set_installation_source(installationsource)
config = _make_installconfig(script, guest.osinfo, unattended_data,
guest.os.arch, guest.name, url)
--
2.20.1
More information about the virt-tools-list
mailing list