[rhel7-branch] Check host filesystem space for dirinstall (#1078876)

Brian C. Lane bcl at redhat.com
Thu Aug 21 23:11:24 UTC 2014


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>
 #
-
+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.
+    """
+    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.
+        """
+        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
-- 
1.9.3



More information about the anaconda-patches mailing list