From 6fa11f24bd3d486013678c1aedec013970f07129 Mon Sep 17 00:00:00 2001 From: David Lehman Date: Thu, 21 Feb 2013 13:46:58 +0100 Subject: [PATCH 07/13] Provide a way to set the default fstype for a Blivet instance. (#838145) --- blivet/__init__.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/blivet/__init__.py b/blivet/__init__.py index 89c632e..1c61c6e 100644 --- a/blivet/__init__.py +++ b/blivet/__init__.py @@ -272,6 +272,7 @@ class Blivet(object): self.__luksDevs = {} self.size_sets = [] + self.setDefaultFSType(get_default_filesystem_type()) self.iscsi = iscsi.iscsi() self.fcoe = fcoe.fcoe() @@ -279,7 +280,6 @@ class Blivet(object): self.dasd = dasd.DASD() self._nextID = 0 - self.defaultFSType = get_default_filesystem_type() self._dumpFile = "/tmp/storage.state" # these will both be empty until our reset method gets called @@ -1702,6 +1702,27 @@ class Blivet(object): return fstype @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) + fmt = getFormat(newtype) + if fmt.type is None: + raise ValueError("unrecognized value for new default fs type") + + if (not fmt.mountable or not fmt.formattable or not fmt.supported or + not fmt.linuxNative): + log.debug("invalid default fstype: %r" % fmt) + raise ValueError("new value is not valid as a default fs type") + + self._defaultFSType = newtype + + @property def mountpoints(self): return self.fsset.mountpoints -- 1.8.1