[virt-tools-list] [virt-install PATCH v2 07/14] osdict: Add set_install_script_installation_source()

Fabiano Fidêncio fidencio at redhat.com
Fri Feb 22 08:40:14 UTC 2019


As some of the install scripts may act differently depending on whether
the installation is going to be done via the OS media or via network
let's have a wrapper around set_installation_source(), from
Libosinfo.InstallScript, in order to be able to properly set which is
going to be the used installation source.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 virtinst/osdict.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index b348844c..b9387a33 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -563,6 +563,24 @@ class _OsVariant(object):
         logging.debug("Using '%s' injection method", method)
         script.set_preferred_injection_method(injection_method)
 
+    def set_install_script_installation_source(self, script, source):
+        def nick_to_value(source):
+            installation_sources = [
+                    libosinfo.InstallScriptInstallationSource.MEDIA,
+                    libosinfo.InstallScriptInstallationSource.NETWORK]
+
+            for s in installation_sources:
+                if source == s.value_nick:
+                    return s
+
+            raise RuntimeError(
+                _("%s is a non-valid installation source in libosinfo."))
+
+        installation_source = nick_to_value(source)
+
+        logging.debug("Using '%s' installation source", source)
+        script.set_installation_source(installation_source)
+
     def get_install_script_config(self, script, unattended_data, arch,
             hostname):
         def requires_param(config_param):
-- 
2.20.1




More information about the virt-tools-list mailing list