[virt-tools-list] [virt-manager PATCH v3 6/9] osdict: Refactor get_install_script()
Fabiano Fidêncio
fidencio at redhat.com
Thu Mar 7 12:52:55 UTC 2019
Let's refactor get_install_script() in a way that any addition done in
order to get the install scripts from the media would be cleaner.
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
virtinst/osdict.py | 53 ++++++++++++++++++++++++----------------------
1 file changed, 28 insertions(+), 25 deletions(-)
diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index 88d5ddc3..a54cc413 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -536,33 +536,36 @@ class _OsVariant(object):
(self.name, arch))
def get_install_script(self, profile):
+ def _get_install_script(script_list):
+ if not script_list:
+ raise RuntimeError(
+ _("'%s' does not support unattended installation.") %
+ self.name)
+
+ installscripts = []
+ profile_names = set()
+ for script in script_list:
+ profile_names.add(script.get_profile())
+ if script.get_profile() == profile:
+ installscripts.append(script)
+
+ if not installscripts:
+ raise RuntimeError(
+ _("'%s' does not support unattended installation for the "
+ "'%s' profile. Available profiles: %s") %
+ (self.name, profile, ", ".join(list(profile_names))))
+
+ logging.debug("Install script found for profile '%s'", profile)
+
+ # Some OSes (as Windows) have more than one installer script,
+ # depending on the OS version and profile choosen, to be used to
+ # perform the unattended installation. Let's just deal with
+ # multiple installer scripts when its actually needed, though.
+ return installscripts[0]
+
script_list = []
if self._os:
script_list = list(_OsinfoIter(self._os.get_install_script_list()))
- if not script_list:
- raise RuntimeError(
- _("'%s' does not support unattended installation.") %
- self.name)
-
- installscripts = []
- profile_names = set()
- for script in script_list:
- profile_names.add(script.get_profile())
- if script.get_profile() == profile:
- installscripts.append(script)
-
- if not installscripts:
- raise RuntimeError(
- _("'%s' does not support unattended installation for the '%s' "
- "profile. Available profiles: %s") %
- (self.name, profile, ", ".join(list(profile_names))))
-
- logging.debug("Install script found for profile '%s'", profile)
-
- # Some OSes (as Windows) have more than one installer script, depending
- # on the OS version and profile choosen, to be used to perform the
- # unattended installation. Let's just deal with multiple installer
- # scripts when its actually needed, though.
- installscript = installscripts[0]
+ installscript = _get_install_script(script_list)
return installscript
--
2.20.1
More information about the virt-tools-list
mailing list