[master 1/1] Set format options for mkfs

TimothyAsirJeyasing installerbot-noreply at redhat.com
Thu Mar 12 08:00:33 UTC 2015


From: Timothy Asir Jeyasingh <tjeyasin at redhat.com>

Currently format options can be specified only for doFormat
function. This patch provides options to set the format options.

Usage ex:-
format = blivet.formats.getFormat("xfs", device=lv.path)
format.formatOptions = ["-f", "-K", "-i", "size=256", "-d", ...]
blivetEnv.formatDevice(lv, format)
blivetEnv.doIt()

bug-url: https://bugzilla.redhat.com/show_bug.cgi?id=1180221
Signed-off-by: Timothy Asir Jeyasingh <tjeyasin at redhat.com>
---
 blivet/formats/fs.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 8972521..6759bf8 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -69,6 +69,7 @@ class FS(DeviceFormat):
     _fsck = ""                           # fs check utility
     _fsckErrors = {}                     # fs check command error codes & msgs
     _infofs = ""                         # fs info utility
+    _formatOptions = []
     _defaultFormatOptions = []           # default options passed to mkfs
     _defaultMountOptions = ["defaults"]  # default options passed to mount
     _defaultCheckOptions = []
@@ -363,6 +364,16 @@ def free(self):
         """
         return max(Size(0), self.currentSize - self.minSize)
 
+    @property
+    def formatOptions(self):
+        """ Get format options passed to mkfs for this filesystem type. """
+        return self._formatOptions[:]
+
+    @formatOptions.setter
+    def formatOptions(self, options=[]):
+        """ Set format options passed to mkfs for this filesystem type. """
+        return self._formatOptions = options
+
     def _getFormatOptions(self, options=None, do_labeling=False):
         """Get a list of format options to be used when creating the
            filesystem.
@@ -375,7 +386,9 @@ def _getFormatOptions(self, options=None, do_labeling=False):
         argv = []
         if options and isinstance(options, list):
             argv.extend(options)
-        argv.extend(self.defaultFormatOptions)
+        if not self.formatOptions:
+            argv.extend(self.defaultFormatOptions)
+        argv.extend(self.formatOptions)
         if self._fsProfileSpecifier and self.fsprofile:
             argv.extend([self._fsProfileSpecifier, self.fsprofile])
 


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/17477e4261b1df4e1c669c6d2c67d886f5349fae


More information about the anaconda-patches mailing list