~ubuntu-branches/ubuntu/trusty/landscape-client/trusty-proposed

« back to all changes in this revision

Viewing changes to landscape/sysinfo/disk.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2010-04-07 16:27:45 UTC
  • mfrom: (1.1.14 upstream) (24.1.1 karmic-proposed)
  • Revision ID: james.westby@ubuntu.com-20100407162745-oeyoppvl0qyvii55
Tags: 1.5.0-0ubuntu0.10.04.0
* New upstream version (LP: #557244)
  - Fix package-changer running before smart-update has completed (LP: #542215)
  - Report the version of Eucalyptus used to generate topology data (LP: #554007)
  - Enable the Eucalyptus plugin by default, if supported (LP: #546531)
  - Use a whitelist of allowed filesystem types to instead of a blacklist (LP: #351927)
  - Report the update-manager logs to the server (LP: #503384)
  - Turn off Curl's DNS caching for requests. (LP: #522688)

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
from landscape.lib.disk import get_mount_info, get_filesystem_for_path
8
8
 
9
9
 
10
 
# List of filesystem types to exclude when generating disk use statistics.
11
 
BORING_FILESYSTEMS = set(["udf", "iso9660", "fuse.gvfs-fuse-daemon",
12
 
                          "squashfs", "ecryptfs"])
 
10
# List of filesystem types authorized when generating disk use statistics.
 
11
STABLE_FILESYSTEMS = set(
 
12
    ["ext", "ext2", "ext3", "ext4", "reiserfs", "ntfs", "msdos", "dos", "vfat",
 
13
     "xfs", "hpfs", "jfs", "ufs", "hfs", "hfsplus"])
13
14
 
14
15
 
15
16
def format_megabytes(megabytes):
38
39
 
39
40
    def run(self):
40
41
        main_info = get_filesystem_for_path("/home", self._mounts_file,
41
 
                                            self._statvfs)
42
 
        total = main_info["total-space"]
43
 
        if total <= 0:
44
 
            main_info = get_filesystem_for_path("/", self._mounts_file,
45
 
                                                self._statvfs)
 
42
                                            self._statvfs, STABLE_FILESYSTEMS)
 
43
        if main_info is not None:
46
44
            total = main_info["total-space"]
47
 
        if total <= 0:
48
 
            main_usage = "unknown"
 
45
            if total <= 0:
 
46
                root_main_info = get_filesystem_for_path(
 
47
                    "/", self._mounts_file, self._statvfs, STABLE_FILESYSTEMS)
 
48
                if root_main_info is not None:
 
49
                    total = root_main_info["total-space"]
 
50
                    main_info = root_main_info
 
51
            if total <= 0:
 
52
                main_usage = "unknown"
 
53
            else:
 
54
                main_usage = usage(main_info)
 
55
            self._sysinfo.add_header("Usage of " + main_info["mount-point"],
 
56
                                     main_usage)
49
57
        else:
50
 
            main_usage = usage(main_info)
51
 
        self._sysinfo.add_header("Usage of " + main_info["mount-point"],
52
 
                                 main_usage)
 
58
            self._sysinfo.add_header("Usage of /home", "unknown")
53
59
 
54
60
        seen_mounts = set()
55
61
        seen_devices = set()
56
 
        infos = list(get_mount_info(self._mounts_file, self._statvfs))
 
62
        infos = list(get_mount_info(self._mounts_file, self._statvfs,
 
63
                                    STABLE_FILESYSTEMS))
57
64
        infos.sort(key=lambda i: len(i["mount-point"]))
58
65
        for info in infos:
59
66
            total = info["total-space"]
64
71
            if mount_seen or device_seen:
65
72
                continue
66
73
 
67
 
            if info["filesystem"] in BORING_FILESYSTEMS:
68
 
                continue
69
74
            if total <= 0:
70
75
                # Some "virtual" filesystems have 0 total space. ignore them.
71
76
                continue