[rhel7/master/f21-blivet] Add ability to set a default fstype for the boot partition (#1112697)

Brian C. Lane bcl at redhat.com
Thu Oct 30 21:43:46 UTC 2014


By default the boot partition fstype is the first in the list returned
by the bootloader. This adds setDefaultBootFSType() which can be used to
override this.

Related: rhbz#1112697
---
 blivet/__init__.py | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/blivet/__init__.py b/blivet/__init__.py
index ad8e8c5..37693b6 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -336,6 +336,7 @@ class Blivet(object):
         self.__luksDevs = {}
         self.size_sets = []
         self.setDefaultFSType(get_default_filesystem_type())
+        self._defaultBootFSType = None
 
         self.iscsi = iscsi.iscsi()
         self.fcoe = fcoe.fcoe()
@@ -1856,21 +1857,19 @@ class Blivet(object):
     @property
     def defaultBootFSType(self):
         """The default filesystem type for the boot partition."""
+        if self._defaultBootFSType:
+            return self._defaultBootFSType
+
         fstype = None
         if self.bootloader:
             fstype = self.bootFSTypes[0]
         return fstype
 
-    @property
-    def defaultFSType(self):
-        return self._defaultFSType
-
-    def setDefaultFSType(self, newtype):
-        """ Set the default fstype for this instance.
+    def _check_valid_fstype(self, newtype):
+        """ Check the fstype to see if it is valid
 
             Raise ValueError on invalid input.
         """
-        log.debug("trying to set new default fstype to '%s'", newtype)
         fmt = getFormat(newtype)
         if fmt.type is None:
             raise ValueError("unrecognized value %s for new default fs type" % newtype)
@@ -1882,6 +1881,30 @@ class Blivet(object):
 
         self._defaultFSType = newtype # pylint: disable=attribute-defined-outside-init
 
+    def setDefaultBootFSType(self, newtype):
+        """ Set the default /boot fstype for this instance.
+
+            Raise ValueError on invalid input.
+        """
+        log.debug("trying to set new default /boot fstype to '%s'", newtype)
+        # This will raise ValueError if it isn't valid
+        self._check_valid_fstype(newtype)
+        self._defaultBootFSType = newtype
+
+    @property
+    def defaultFSType(self):
+        return self._defaultFSType
+
+    def setDefaultFSType(self, newtype):
+        """ Set the default fstype for this instance.
+
+            Raise ValueError on invalid input.
+        """
+        log.debug("trying to set new default fstype to '%s'", newtype)
+        # This will raise ValueError if it isn't valid
+        self._check_valid_fstype(newtype)
+        self._defaultFSType = newtype # pylint: disable=attribute-defined-outside-init
+
     @property
     def mountpoints(self):
         return self.fsset.mountpoints
-- 
1.9.3



More information about the anaconda-patches mailing list