[PATCH] Add information about boot method for bootloader

Martin Kolman mkolman at redhat.com
Mon Oct 21 17:46:04 UTC 2013


Make it possible to check which boot method a bootloader
instance is using. Currently reports MBR/EFI or None
if not known.

Related: rhbz#1012132
Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
 pyanaconda/bootloader.py | 19 ++++++++++++++++++-
 pyanaconda/constants.py  |  4 ++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 433a5cf..ec94ec1 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -32,7 +32,7 @@ from blivet.devicelibs import mdraid
 from pyanaconda.isys import sync
 from pyanaconda.product import productName
 from pyanaconda.flags import flags
-from pyanaconda.constants import ROOT_PATH
+from pyanaconda.constants import ROOT_PATH, BOOT_METHOD_MBR, BOOT_METHOD_EFI
 from blivet.errors import StorageError
 from blivet.fcoe import fcoe
 import pyanaconda.network
@@ -251,6 +251,8 @@ class BootLoader(object):
 
     _trusted_boot = False
 
+    _boot_method = None
+
     def __init__(self):
         self.boot_args = Arguments()
         self.dracut_args = Arguments()
@@ -964,12 +966,25 @@ class BootLoader(object):
         """ Update an existing bootloader configuration. """
         pass
 
+    @ property
+    def boot_method(self):
+        """Report the boot type currently used
+        or None if not known
+        This is currently mainly used to differentiate between
+        MBR and EFI booting.
+        :returns: boot type constant or None
+        :rtype: string or None
+        """
+
+        return self._boot_method
+
 
 class GRUB(BootLoader):
     name = "GRUB"
     _config_dir = "grub"
     _config_file = "grub.conf"
     _device_map_file = "device.map"
+    _boot_method = BOOT_METHOD_MBR
     can_dual_boot = True
     can_update = True
 
@@ -1348,6 +1363,7 @@ class GRUB2(GRUB):
     packages = ["grub2"]
     _config_file = "grub.cfg"
     _config_dir = "grub2"
+    _boot_method = BOOT_METHOD_MBR
     config_file_mode = 0600
     defaults_file = "/etc/default/grub"
     can_dual_boot = True
@@ -1614,6 +1630,7 @@ class EFIGRUB(GRUB2):
     can_dual_boot = False
     stage2_is_valid_stage1 = False
     stage2_bootable = False
+    _boot_method = BOOT_METHOD_EFI
 
     @property
     def _config_dir(self):
diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py
index 7af5014..8e09c9c 100644
--- a/pyanaconda/constants.py
+++ b/pyanaconda/constants.py
@@ -142,3 +142,7 @@ PASSWORD_WEAK_CONFIRM = N_("You have provided a weak password. Press Done again
 PASSWORD_WEAK_CONFIRM_WITH_ERROR = N_("You have provided a weak password: %s. Press Done again to use anyway.")
 
 PASSWORD_STRENGTH_DESC = [N_("Empty"), N_("Weak"), N_("Fair"), N_("Good"), N_("Strong")]
+
+# boot methods
+BOOT_METHOD_MBR = "mbr"
+BOOT_METHOD_EFI = "efi"
-- 
1.8.3.1



More information about the anaconda-patches mailing list