[virt-install PATCH v2 02/14] osdict: Add get_install_script()

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

 



get_install_script() method returns an installer script of a specific
profile type for a specific OS.

In case no OS is defined, None is returned.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 virtinst/osdict.py | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index 5735d835..6d4080b4 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -510,4 +510,31 @@ class _OsVariant(object):
         # the right one.
         return filtered_treelist.get_nth(0).get_url()
 
+    def get_install_script(self, profile):
+        if not self._os:
+            return None
+
+        script_list = self._os.get_install_script_list()
+        if script_list.get_length == 0:
+            raise RuntimeError(
+                _("%s does not support unattended installation."), self.name)
+
+        profile_filter = libosinfo.Filter()
+        profile_filter.add_constraint(
+            libosinfo.INSTALL_SCRIPT_PROP_PROFILE, profile)
+
+        filtered_script_list = script_list.new_filtered(profile_filter)
+        if filtered_script_list.get_length() == 0:
+            raise RuntimeError(
+                _("%s does not support unattended installation for the '%s' "
+                  "profile."), self.name, profile)
+
+        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 filtered_script_list.get_nth(0)
+
 OSDB = _OSDB()
-- 
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