[virt-tools-list] [PATCH virt-manager 07/10] guest: Add get_boot_order method

Marc Hartmayer mhartmay at linux.ibm.com
Wed Feb 6 09:55:40 UTC 2019


Add 'get_boot_order' method. This method has an optional parameter for
getting the legacy boot order defined in the OS node of the domain
definition.

Signed-off-by: Marc Hartmayer <mhartmay at linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
---
 virtManager/domain.py |  5 ++---
 virtinst/guest.py     | 11 ++++++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/virtManager/domain.py b/virtManager/domain.py
index 74d4a7a4caa7..19d55aab2eed 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -1198,9 +1198,8 @@ class vmmDomain(vmmLibvirtObject):
         return self.get_xmlobj().cpu
 
     def get_boot_order(self):
-        if self.can_use_device_boot_order():
-            return self.xmlobj.get_device_boot_order()
-        return self.xmlobj.get_old_boot_order()
+        legacy = not self.can_use_device_boot_order()
+        return self.xmlobj.get_boot_order(legacy=legacy)
 
     def get_boot_menu(self):
         guest = self.get_xmlobj()
diff --git a/virtinst/guest.py b/virtinst/guest.py
index 6035093c8991..aac5116319c5 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -312,7 +312,7 @@ class Guest(XMLBuilder):
         return self.__osinfo
     osinfo = property(_get_osinfo)
 
-    def get_old_boot_order(self):
+    def _get_old_boot_order(self):
         return self.os.bootorder
 
     def _convert_old_boot_order(self):
@@ -320,7 +320,7 @@ class Guest(XMLBuilder):
         per-device boot order format.
 
         """
-        boot_order = self.get_old_boot_order()
+        boot_order = self._get_old_boot_order()
         ret = []
         disk = None
         cdrom = None
@@ -352,7 +352,7 @@ class Guest(XMLBuilder):
                 ret.append(floppy.get_xml_id())
         return ret
 
-    def get_device_boot_order(self):
+    def _get_device_boot_order(self):
         order = []
         for dev in self.get_bootable_devices(exclude_redirdev=True):
             if not dev.boot.order:
@@ -367,6 +367,11 @@ class Guest(XMLBuilder):
         order.sort(key=lambda p: p[1])
         return [p[0] for p in order]
 
+    def get_boot_order(self, legacy=False):
+        if legacy:
+            return self._get_old_boot_order()
+        return self._get_device_boot_order()
+
     def set_device_boot_order(self, boot_order):
         """Sets the new device boot order for the domain"""
         # Unset the traditional boot order
-- 
2.17.0




More information about the virt-tools-list mailing list