[virt-manager PATCH v3 6/9] osdict: Refactor get_install_script()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux