[PATCH blivet rhel7-branch] Add support for specifying arbitrary mkfs options.

David Lehman dlehman at redhat.com
Tue Jun 30 19:25:54 UTC 2015


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


More information about the anaconda-patches mailing list