[PATCH virt-manager 06/10] domain: Move get boot order methods to guest

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

 



Move get boot order methods to guest XML builder. For this we must
replace self.get_bootable_devices() with
self.get_bootable_devices(exclude_redirdev=True) in the
_get_device_boot_order and set_device_boot_order to have no
functionality change.

Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
---
 virtManager/domain.py | 59 +++----------------------------------------
 virtinst/guest.py     | 55 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 56 deletions(-)

diff --git a/virtManager/domain.py b/virtManager/domain.py
index 77dc6a3d7206..74d4a7a4caa7 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -1197,64 +1197,11 @@ class vmmDomain(vmmLibvirtObject):
     def get_cpu_config(self):
         return self.get_xmlobj().cpu
 
-    def _convert_old_boot_order(self):
-        """Converts the old boot order (e.g. <boot dev='hd'/>) into the
-        per-device boot order format.
-
-        """
-        boot_order = self._get_old_boot_order()
-        ret = []
-        disk = None
-        cdrom = None
-        floppy = None
-        net = None
-
-        for d in self.xmlobj.devices.disk:
-            if not cdrom and d.device == "cdrom":
-                cdrom = d
-            if not floppy and d.device == "floppy":
-                floppy = d
-            if not disk and d.device not in ["cdrom", "floppy"]:
-                disk = d
-            if cdrom and disk and floppy:
-                break
-
-        for n in self.xmlobj.devices.interface:
-            net = n
-            break
-
-        for b in boot_order:
-            if b == "network" and net:
-                ret.append(net.get_xml_id())
-            elif b == "hd" and disk:
-                ret.append(disk.get_xml_id())
-            elif b == "cdrom" and cdrom:
-                ret.append(cdrom.get_xml_id())
-            elif b == "fd" and floppy:
-                ret.append(floppy.get_xml_id())
-        return ret
-
-    def _get_device_boot_order(self):
-        order = []
-        for dev in self.get_bootable_devices():
-            if not dev.boot.order:
-                continue
-            order.append((dev.get_xml_id(), dev.boot.order))
-
-        if not order:
-            # No devices individually marked bootable, convert traditional
-            # boot XML to fine grained, for the UI.
-            return self._convert_old_boot_order()
-
-        order.sort(key=lambda p: p[1])
-        return [p[0] for p in order]
-
-    def _get_old_boot_order(self):
-        return self.get_xmlobj().os.bootorder
     def get_boot_order(self):
         if self.can_use_device_boot_order():
-            return self._get_device_boot_order()
-        return self._get_old_boot_order()
+            return self.xmlobj.get_device_boot_order()
+        return self.xmlobj.get_old_boot_order()
+
     def get_boot_menu(self):
         guest = self.get_xmlobj()
         return bool(guest.os.enable_bootmenu)
diff --git a/virtinst/guest.py b/virtinst/guest.py
index bc70abbe99ab..6035093c8991 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -312,6 +312,61 @@ class Guest(XMLBuilder):
         return self.__osinfo
     osinfo = property(_get_osinfo)
 
+    def get_old_boot_order(self):
+        return self.os.bootorder
+
+    def _convert_old_boot_order(self):
+        """Converts the old boot order (e.g. <boot dev='hd'/>) into the
+        per-device boot order format.
+
+        """
+        boot_order = self.get_old_boot_order()
+        ret = []
+        disk = None
+        cdrom = None
+        floppy = None
+        net = None
+
+        for d in self.devices.disk:
+            if not cdrom and d.device == "cdrom":
+                cdrom = d
+            if not floppy and d.device == "floppy":
+                floppy = d
+            if not disk and d.device not in ["cdrom", "floppy"]:
+                disk = d
+            if cdrom and disk and floppy:
+                break
+
+        for n in self.devices.interface:
+            net = n
+            break
+
+        for b in boot_order:
+            if b == "network" and net:
+                ret.append(net.get_xml_id())
+            elif b == "hd" and disk:
+                ret.append(disk.get_xml_id())
+            elif b == "cdrom" and cdrom:
+                ret.append(cdrom.get_xml_id())
+            elif b == "fd" and floppy:
+                ret.append(floppy.get_xml_id())
+        return ret
+
+    def get_device_boot_order(self):
+        order = []
+        for dev in self.get_bootable_devices(exclude_redirdev=True):
+            if not dev.boot.order:
+                continue
+            order.append((dev.get_xml_id(), dev.boot.order))
+
+        if not order:
+            # No devices individually marked bootable, convert traditional
+            # boot XML to fine grained
+            return self._convert_old_boot_order()
+
+        order.sort(key=lambda p: p[1])
+        return [p[0] for p in 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

_______________________________________________
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