While we have support for fsprofile, that is only supported by the various ext* filesystems. We have no way to support passing options for any of the other filesystems, including the default in RHEL.
Resolves: rhbz#1220898 --- blivet/formats/__init__.py | 19 +++++++++++++++---- blivet/formats/fs.py | 5 +++++ 2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/blivet/formats/__init__.py b/blivet/formats/__init__.py index 55fc626..01fdbb8 100644 --- a/blivet/formats/__init__.py +++ b/blivet/formats/__init__.py @@ -185,6 +185,7 @@ class DeviceFormat(ObjectID): self.uuid = kwargs.get("uuid") self.exists = kwargs.get("exists") self.options = kwargs.get("options") + self._createOptions = kwargs.get("createOptions")
# don't worry about existence if this is a DeviceFormat instance #if self.__class__ is DeviceFormat: @@ -194,14 +195,16 @@ class DeviceFormat(ObjectID): s = ("%(classname)s instance (%(id)s) object id %(object_id)d--\n" " type = %(type)s name = %(name)s status = %(status)s\n" " device = %(device)s uuid = %(uuid)s exists = %(exists)s\n" - " options = %(options)s supported = %(supported)s" + " options = %(options)s\n" + " createOptions = %(createOptions)s supported = %(supported)s" " formattable = %(format)s resizable = %(resize)s\n" % {"classname": self.__class__.__name__, "id": "%#x" % id(self), - "object_id": self.id, + "object_id": self.id, "createOptions": self.createOptions, "type": self.type, "name": self.name, "status": self.status, "device": self.device, "uuid": self.uuid, "exists": self.exists, "options": self.options, "supported": self.supported, - "format": self.formattable, "resize": self.resizable}) + "format": self.formattable, "resize": self.resizable, + "createOptions": self.createOptions}) return s
@property @@ -223,7 +226,7 @@ class DeviceFormat(ObjectID): d = {"type": self.type, "name": self.name, "device": self.device, "uuid": self.uuid, "exists": self.exists, "options": self.options, "supported": self.supported, - "resizable": self.resizable} + "resizable": self.resizable, "createOptions": self.createOptions} return d
@classmethod @@ -293,6 +296,14 @@ class DeviceFormat(ObjectID):
options = property(_getOptions, _setOptions)
+ def _setCreateOptions(self, options): + self._setupCreateOptions = options # pylint: disable=attribute-defined-outside-init + + def _getCreateOptions(self): + return self._createOptions + + createOptions = property(_getCreateOptions, _setCreateOptions) + def _setDevice(self, devspec): if devspec and not devspec.startswith("/"): raise ValueError("device must be a fully qualified path") diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py index 6981a10..2784fbe 100644 --- a/blivet/formats/fs.py +++ b/blivet/formats/fs.py @@ -24,6 +24,7 @@ """ Filesystem classes. """ from decimal import Decimal import os +import shlex import tempfile
from . import fslabeling @@ -402,6 +403,9 @@ class FS(DeviceFormat): else: log.warning("Choosing not to apply label (%s) during creation of filesystem %s. Label format is unacceptable for this filesystem.", self.label, self.type)
+ if self.createOptions: + argv.extend(shlex.split(self.createOptions)) + argv.append(self.device) return argv
@@ -930,6 +934,7 @@ class FS(DeviceFormat): else: data.fsopts = ""
+ data.mkfsopts = self.createOptions or "" data.fsprofile = self.fsprofile or ""
class Ext2FS(FS):
Related: rhbz#1218260 --- pykickstart/commands/logvol.py | 3 +++ pykickstart/commands/partition.py | 3 +++ pykickstart/commands/raid.py | 3 +++ tests/commands/logvol.py | 4 ++++ tests/commands/partition.py | 3 +++ tests/commands/raid.py | 4 ++++ 6 files changed, 20 insertions(+)
diff --git a/pykickstart/commands/logvol.py b/pykickstart/commands/logvol.py index b3cbc49..9cf3b58 100644 --- a/pykickstart/commands/logvol.py +++ b/pykickstart/commands/logvol.py @@ -564,6 +564,9 @@ class RHEL7_LogVol(F21_LogVol): if not retval.format and retval.mkfsopts: raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("--mkfsoptions with --noformat has no effect.")))
+ if retval.fsprofile and retval.mkfsopts: + raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("--mkfsoptions and --fsprofile cannot be used together."))) + if retval.cache_size or retval.cache_mode or retval.cache_pvs: if retval.preexist: err = formatErrorMsg(self.lineno, msg=_("Adding a cache to an existing logical volume is not supported")) diff --git a/pykickstart/commands/partition.py b/pykickstart/commands/partition.py index 4db6425..75bc551 100644 --- a/pykickstart/commands/partition.py +++ b/pykickstart/commands/partition.py @@ -502,4 +502,7 @@ class RHEL7_Partition(F20_Partition): if not retval.format and retval.mkfsopts: raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("--mkfsoptions with --noformat has no effect.")))
+ if retval.fsprofile and retval.mkfsopts: + raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("--mkfsoptions and --fsprofile cannot be used together."))) + return retval diff --git a/pykickstart/commands/raid.py b/pykickstart/commands/raid.py index 2a5b76d..d2854d4 100644 --- a/pykickstart/commands/raid.py +++ b/pykickstart/commands/raid.py @@ -502,4 +502,7 @@ class RHEL7_Raid(F20_Raid): if not retval.format and retval.mkfsopts: raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("--mkfsoptions with --noformat has no effect.")))
+ if retval.fsprofile and retval.mkfsopts: + raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("--mkfsoptions and --fsprofile cannot be used together."))) + return retval diff --git a/tests/commands/logvol.py b/tests/commands/logvol.py index 731efe1..85ee48c 100644 --- a/tests/commands/logvol.py +++ b/tests/commands/logvol.py @@ -320,6 +320,10 @@ class RHEL7_TestCase(F21_TestCase): self.assert_parse_error("logvol / --size=4096 --name=LVNAME --vgname=VGNAME --mkfsoptions=some,thing --noformat", KickstartValueError)
+ # can't use --mkfsoptions with --fsprofile + self.assert_parse_error("logvol / --size=4096 --name=LVNAME --vgname=VGNAME --mkfsoptions=some,thing --fsprofile=PROFILE", + KickstartValueError) + # accept cache specifications self.assert_parse("logvol /home --name=home --vgname=vg --size=500 --cachesize=250 --cachepvs=pv.01,pv.02 --cachemode=writeback") # cache mode is not required diff --git a/tests/commands/partition.py b/tests/commands/partition.py index 93a1f70..4339725 100644 --- a/tests/commands/partition.py +++ b/tests/commands/partition.py @@ -217,5 +217,8 @@ class RHEL7_TestCase(F18_TestCase): # can't use --mkfsoptions if you're not formatting self.assert_parse_error("part / --size=4096 --mkfsoptions=some,thing --noformat", KickstartValueError)
+ # can't use --mkfsoptions with --fsprofile + self.assert_parse_error("part / --size=4096 --mkfsoptions=some,thing --fsprofile=PROFILE", KickstartValueError) + if __name__ == "__main__": unittest.main() diff --git a/tests/commands/raid.py b/tests/commands/raid.py index 8566c80..65183b1 100644 --- a/tests/commands/raid.py +++ b/tests/commands/raid.py @@ -269,5 +269,9 @@ class RHEL7_TestCase(F19_TestCase): self.assert_parse_error("raid / --device=md0 --level=1 --mkfsoptions=some,thing --noformat raid.01 raid.02", KickstartValueError)
+ # can't use --mkfsoptions with --fsprofile + self.assert_parse_error("raid / --device=md0 --level=1 --mkfsoptions=some,thing --fsprofile=PROFILE raid.01 raid.02", + KickstartValueError) + if __name__ == "__main__": unittest.main()
Most of the work for this is done in blivet. All that's really needed in anaconda is passing values from pykickstart to blivet.
Resolves: rhbz#1217110 --- pyanaconda/kickstart.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index 3350ab9..104780b 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -504,7 +504,8 @@ class BTRFSData(commands.btrfs.RHEL7_BTRFSData): mountpoint=self.mountpoint, metaDataLevel=self.metaDataLevel, dataLevel=self.dataLevel, - parents=members) + parents=members, + createOptions=self.mkfsopts)
storage.createDevice(request)
@@ -931,6 +932,7 @@ class LogVolData(commands.logvol.RHEL7_LogVolData): mountpoint=self.mountpoint, label=self.label, fsprofile=self.fsprofile, + createOptions=self.mkfsopts, mountopts=self.fsopts) if not fmt.type and not self.thin_pool: raise KickstartValueError(formatErrorMsg(self.lineno, @@ -1225,6 +1227,7 @@ class PartitionData(commands.partition.RHEL7_PartData): label=self.label, fsprofile=self.fsprofile, mountopts=self.fsopts, + createOptions=self.mkfsopts, size=size) if not kwargs["fmt"].type: raise KickstartValueError(formatErrorMsg(self.lineno, @@ -1445,7 +1448,8 @@ class RaidData(commands.raid.RHEL7_RaidData): label=self.label, fsprofile=self.fsprofile, mountpoint=self.mountpoint, - mountopts=self.fsopts) + mountopts=self.fsopts, + createOptions=self.mkfsopts) if not kwargs["fmt"].type: raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("The "%s" file system type is not supported.") % ty))
While we have support for fsprofile, that is only supported by the various ext* filesystems. We have no way to support passing options for any of the other filesystems, including the default in RHEL.
Resolves: rhbz#1220898
I had been planning on doing a companion patch to this one that renamed the existing options property to be setupOptions, to make it more clear which is which. However, I abandoned that plan for a couple reasons. First, this is established API that I didn't want to break. Second, "options" is used very extensively throughout blivet and this is a code base I am far from an expert in.
I am sure that if anyone else wanted to take care of that patch, though, it would be welcome - at least on master.
- Chris
On 06/30/2015 12:22 PM, Chris Lumens wrote:
While we have support for fsprofile, that is only supported by the various ext* filesystems. We have no way to support passing options for any of the other filesystems, including the default in RHEL.
Resolves: rhbz#1220898
blivet/formats/__init__.py | 19 +++++++++++++++---- blivet/formats/fs.py | 5 +++++ 2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/blivet/formats/__init__.py b/blivet/formats/__init__.py index 55fc626..01fdbb8 100644 --- a/blivet/formats/__init__.py +++ b/blivet/formats/__init__.py @@ -185,6 +185,7 @@ class DeviceFormat(ObjectID): self.uuid = kwargs.get("uuid") self.exists = kwargs.get("exists") self.options = kwargs.get("options")
self._createOptions = kwargs.get("createOptions") # don't worry about existence if this is a DeviceFormat instance #if self.__class__ is DeviceFormat:@@ -194,14 +195,16 @@ class DeviceFormat(ObjectID): s = ("%(classname)s instance (%(id)s) object id %(object_id)d--\n" " type = %(type)s name = %(name)s status = %(status)s\n" " device = %(device)s uuid = %(uuid)s exists = %(exists)s\n"
" options = %(options)s supported = %(supported)s"
" options = %(options)s\n"" createOptions = %(createOptions)s supported = %(supported)s" " formattable = %(format)s resizable = %(resize)s\n" % {"classname": self.__class__.__name__, "id": "%#x" % id(self),
"object_id": self.id,
"object_id": self.id, "createOptions": self.createOptions, "type": self.type, "name": self.name, "status": self.status, "device": self.device, "uuid": self.uuid, "exists": self.exists, "options": self.options, "supported": self.supported,
"format": self.formattable, "resize": self.resizable})
"format": self.formattable, "resize": self.resizable,"createOptions": self.createOptions}) return s @property@@ -223,7 +226,7 @@ class DeviceFormat(ObjectID): d = {"type": self.type, "name": self.name, "device": self.device, "uuid": self.uuid, "exists": self.exists, "options": self.options, "supported": self.supported,
"resizable": self.resizable}
"resizable": self.resizable, "createOptions": self.createOptions} return d @classmethod@@ -293,6 +296,14 @@ class DeviceFormat(ObjectID):
options = property(_getOptions, _setOptions)
- def _setCreateOptions(self, options):
self._setupCreateOptions = options # pylint: disable=attribute-defined-outside-init
Should be "self._createOptions", which I think will obviate the pylint disable.
- def _getCreateOptions(self):
return self._createOptions- createOptions = property(_getCreateOptions, _setCreateOptions)
def _setDevice(self, devspec): if devspec and not devspec.startswith("/"): raise ValueError("device must be a fully qualified path")diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py index 6981a10..2784fbe 100644 --- a/blivet/formats/fs.py +++ b/blivet/formats/fs.py @@ -24,6 +24,7 @@ """ Filesystem classes. """ from decimal import Decimal import os +import shlex import tempfile
from . import fslabeling @@ -402,6 +403,9 @@ class FS(DeviceFormat): else: log.warning("Choosing not to apply label (%s) during creation of filesystem %s. Label format is unacceptable for this filesystem.", self.label, self.type)
if self.createOptions:argv.extend(shlex.split(self.createOptions))argv.append(self.device) return argv@@ -930,6 +934,7 @@ class FS(DeviceFormat): else: data.fsopts = ""
data.mkfsopts = self.createOptions or "" data.fsprofile = self.fsprofile or ""class Ext2FS(FS):
Looks fine otherwise.
David
anaconda-patches@lists.fedorahosted.org