[rhel7-branch] Check host filesystem space for dirinstall (#1078876)
Vratislav Podzimek
vpodzime at redhat.com
Mon Aug 25 14:29:10 UTC 2014
On Thu, 2014-08-21 at 16:11 -0700, Brian C. Lane wrote:
> This fixes using --dirinstall in GUI mode. The space check was failing
> since storage is totally skipped and nothing is mounted. This adds a
> check class that will check the host system's filesystem size instead.
>
> Resolves: rhbz#1078876
> ---
> pyanaconda/ui/gui/hubs/summary.py | 8 ++++++--
> pyanaconda/ui/lib/space.py | 34 +++++++++++++++++++++++++++++++++-
> 2 files changed, 39 insertions(+), 3 deletions(-)
>
> diff --git a/pyanaconda/ui/gui/hubs/summary.py b/pyanaconda/ui/gui/hubs/summary.py
> index fe7eeb1..2615377 100644
> --- a/pyanaconda/ui/gui/hubs/summary.py
> +++ b/pyanaconda/ui/gui/hubs/summary.py
> @@ -20,7 +20,8 @@
> #
>
> from pyanaconda.ui.gui.hubs import Hub
> -from pyanaconda.ui.lib.space import FileSystemSpaceChecker
> +from pyanaconda.ui.lib.space import FileSystemSpaceChecker, DirInstallSpaceChecker
> +from pyanaconda.flags import flags
>
> __all__ = ["SummaryHub"]
>
> @@ -53,7 +54,10 @@ class SummaryHub(Hub):
> """
> super(SummaryHub, self).__init__(data, storage, payload, instclass)
>
> - self._checker = FileSystemSpaceChecker(storage, payload)
> + if not flags.dirInstall:
> + self._checker = FileSystemSpaceChecker(storage, payload)
> + else:
> + self._checker = DirInstallSpaceChecker(storage, payload)
>
> @property
> def continueButton(self):
> diff --git a/pyanaconda/ui/lib/space.py b/pyanaconda/ui/lib/space.py
> index 9169d56..a186d6e 100644
> --- a/pyanaconda/ui/lib/space.py
> +++ b/pyanaconda/ui/lib/space.py
> @@ -18,8 +18,9 @@
> #
> # Red Hat Author(s): David Lehman <dlehman at redhat.com>
> #
> -
Please keep this blank line.
> +import os
> from blivet.size import Size
> +from pyanaconda import iutil
>
> from pyanaconda.i18n import _, N_
>
> @@ -80,3 +81,34 @@ class FileSystemSpaceChecker(object):
> self.error_message = _(self.error_template) % self.deficit
>
> return self.success
> +
> +class DirInstallSpaceChecker(FileSystemSpaceChecker):
> + """Use the amount of space available at ROOT_PATH to calculate free space.
> +
> + This is used for the --dirinstall option where no storage is mounted and it
> + is using space from the host's filesystem.
> + """
And add one here.
> + def check(self):
> + """Check configured storage against software selections. When this
> + method is complete (which should be pretty quickly), the following
> + attributes are available for inspection:
> +
> + success -- A simple boolean defining whether there's enough
> + space or not.
> + deficit -- If unsuccessful, how much space the system is
> + short for current software selections (in MB).
> + error_message -- If unsuccessful, an error message describing the
> + situation. This message is suitable for putting
> + in the info bar at the bottom of a Hub.
> + """
And here.
> + self.reset()
> + stat = os.statvfs(iutil.getSysroot())
> + free = Size(stat.f_bsize * stat.f_bfree)
> + needed = self.payload.spaceRequired
> + log.info("fs space: %s needed: %s", free, needed)
> + self.success = (free >= needed)
> + if not self.success:
> + self.deficit = needed - free
> + self.error_message = _(self.error_template) % self.deficit
> +
> + return self.success
Otherwise this looks good to me.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list