From 93cc0578108f9272153d1a379243884f4f82d667 Mon Sep 17 00:00:00 2001
From: David Lehman <dlehman@redhat.com>
Date: Fri, 30 Mar 2012 15:39:14 -0500
Subject: [PATCH 2/3] Make class methods for mountable, formattable,
 supportable.

Properties still exist with the names above. The class methods' names
are getMountable, getFormattable, and getSupportable and become the
backend methods for the properties.
---
 pyanaconda/storage/formats/__init__.py |   29 ++++++++++++--------
 pyanaconda/storage/formats/biosboot.py |    4 +--
 pyanaconda/storage/formats/fs.py       |   46 ++++++++++++++++----------------
 pyanaconda/storage/formats/prepboot.py |    4 +--
 4 files changed, 45 insertions(+), 38 deletions(-)

diff --git a/pyanaconda/storage/formats/__init__.py b/pyanaconda/storage/formats/__init__.py
index 4b0c122..feacbe1 100644
--- a/pyanaconda/storage/formats/__init__.py
+++ b/pyanaconda/storage/formats/__init__.py
@@ -50,13 +50,9 @@ def register_device_format(fmt_class):
 default_fstypes = ("ext4", "ext3", "ext2")
 def get_default_filesystem_type():
     for fstype in default_fstypes:
-        try:
-            supported = get_device_format_class(fstype).supported
-        except AttributeError:
-            supported = None
-
-        if supported:
-            return fstype
+        cls = get_device_format_class(fstype)
+        if cls.getSupported() and cls.getFormattable() and cls.getMountable():
+            return cls
 
     raise DeviceFormatError("None of %s is supported by your kernel" % ",".join(default_fstypes))
 
@@ -344,15 +340,22 @@ class DeviceFormat(object):
                 self.device and 
                 os.path.exists(self.device))
 
+    @classmethod
+    def getFormattable(self):
+        return self._formattable
+
     @property
     def formattable(self):
         """ Can we create formats of this type? """
-        return self._formattable
+        return self.getFormattable()
+
+    @classmethod
+    def getSupported(self):
+        return self._supported
 
     @property
     def supported(self):
-        """ Is this format a supported type? """
-        return self._supported
+        return self.getSupported()
 
     @property
     def packages(self):
@@ -383,10 +386,14 @@ class DeviceFormat(object):
         """ Is this format type native to linux? """
         return self._linuxNative
 
+    @classmethod
+    def getMountable(self):
+        return False
+
     @property
     def mountable(self):
         """ Is this something we can mount? """
-        return False
+        return self.getMountable()
 
     @property
     def dump(self):
diff --git a/pyanaconda/storage/formats/biosboot.py b/pyanaconda/storage/formats/biosboot.py
index 34bd760..55fc6a3 100644
--- a/pyanaconda/storage/formats/biosboot.py
+++ b/pyanaconda/storage/formats/biosboot.py
@@ -51,8 +51,8 @@ class BIOSBoot(DeviceFormat):
     def status(self):
         return False
 
-    @property
-    def supported(self):
+    @classmethod
+    def getSupported(self):
         from pyanaconda import platform
         return isinstance(platform.getPlatform(), platform.X86)
 
diff --git a/pyanaconda/storage/formats/fs.py b/pyanaconda/storage/formats/fs.py
index e8b45cc..7ed7452 100644
--- a/pyanaconda/storage/formats/fs.py
+++ b/pyanaconda/storage/formats/fs.py
@@ -780,13 +780,13 @@ class FS(DeviceFormat):
 
         return True
 
-    @property
-    def supported(self):
+    @classmethod
+    def getSupported(self):
         log_method_call(self, supported=self._supported)
         return self._supported and self.utilsAvailable
 
-    @property
-    def mountable(self):
+    @classmethod
+    def getMountable(self):
         canmount = (self.mountType in kernel_filesystems) or \
                    (os.access("/sbin/mount.%s" % (self.mountType,), os.X_OK))
         modpath = os.path.realpath(os.path.join("/lib/modules", os.uname()[2]))
@@ -1121,8 +1121,8 @@ class EFIFS(FATFS):
     _name = "EFI System Partition"
     _minSize = 50
 
-    @property
-    def supported(self):
+    @classmethod
+    def getSupported(self):
         from pyanaconda import platform
         p = platform.getPlatform()
         return (isinstance(p, platform.EFI) and
@@ -1184,8 +1184,8 @@ class GFS2(FS):
     # partition table type correctly for btrfs partitions
     # partedSystem = fileSystemType["gfs2"]
 
-    @property
-    def supported(self):
+    @classmethod
+    def getSupported(self):
         """ Is this filesystem a supported type? """
         supported = self._supported
         if flags.cmdline.has_key("gfs2"):
@@ -1216,8 +1216,8 @@ class JFS(FS):
     _existingSizeFields = ["Aggregate block size:", "Aggregate size:"]
     partedSystem = fileSystemType["jfs"]
 
-    @property
-    def supported(self):
+    @classmethod
+    def getSupported(self):
         """ Is this filesystem a supported type? """
         supported = self._supported
         if flags.cmdline.has_key("jfs"):
@@ -1250,8 +1250,8 @@ class ReiserFS(FS):
     _existingSizeFields = ["Count of blocks on the device:", "Blocksize:"]
     partedSystem = fileSystemType["reiserfs"]
 
-    @property
-    def supported(self):
+    @classmethod
+    def getSupported(self):
         """ Is this filesystem a supported type? """
         supported = self._supported
         if flags.cmdline.has_key("reiserfs"):
@@ -1338,8 +1338,8 @@ class AppleBootstrapFS(HFS):
     _minSize = 800.00 / 1024.00
     _maxSize = 1
 
-    @property
-    def supported(self):
+    @classmethod
+    def getSupported(self):
         from pyanaconda import platform
         return (isinstance(platform.getPlatform(), platform.NewWorldPPC)
                 and self.utilsAvailable)
@@ -1376,8 +1376,8 @@ class NTFS(FS):
     _existingSizeFields = ["Cluster Size:", "Volume Size in Clusters:"]
     partedSystem = fileSystemType["ntfs"]
 
-    @property
-    def mountable(self):
+    @classmethod
+    def getMountable(self):
         return False
 
     def _fsckFailed(self, rc):
@@ -1437,8 +1437,8 @@ class NFS(FS):
         if devspec is not None and ":" not in devspec:
             raise ValueError("device must be of the form <host>:<path>")
 
-    @property
-    def mountable(self):
+    @classmethod
+    def getMountable(self):
         return False
 
     def _setDevice(self, devspec):
@@ -1532,8 +1532,8 @@ register_device_format(TmpFS)
 class BindFS(FS):
     _type = "bind"
 
-    @property
-    def mountable(self):
+    @classmethod
+    def getMountable(self):
         return True
 
     def _getExistingSize(self):
@@ -1548,9 +1548,9 @@ register_device_format(BindFS)
 class SELinuxFS(NoDevFS):
     _type = "selinuxfs"
 
-    @property
-    def mountable(self):
-        return flags.selinux and super(SELinuxFS, self).mountable
+    @classmethod
+    def getMountable(self):
+        return flags.selinux and super(SELinuxFS, self).getMountable()
 
 register_device_format(SELinuxFS)
 
diff --git a/pyanaconda/storage/formats/prepboot.py b/pyanaconda/storage/formats/prepboot.py
index 102d957..8295b2a 100644
--- a/pyanaconda/storage/formats/prepboot.py
+++ b/pyanaconda/storage/formats/prepboot.py
@@ -50,8 +50,8 @@ class PPCPRePBoot(DeviceFormat):
     def status(self):
         return False
 
-    @property
-    def supported(self):
+    @classmethod
+    def getSupported(self):
         from pyanaconda import platform
         return isinstance(platform.getPlatform(), platform.IPSeriesPPC)
 
-- 
1.7.9.3

