vinstall / vinstall / backend / mountpoints.py

# -*- coding: utf8 -*-


"""Mountpoints module

"""

import os
from vinstall.backend.media import Partition

class MountPoints(object):
    
    DEFAULT_ROOT_FS = "ext3" # Default os to be used for /, unless changed by the user.
    MINIMUM_ROOT_SIZE = 4 # Size in GB

    def __init__(self):

        self.partitions = set(Partition.all())
        self.filesystems = set(["ext2", "ext3", "ext4", "reiserfs", "xfs",
            "jfs", "swap"])
        self.mountpoints = set(["/", "home", "boot", "var", "tmp", "opt",
            "usr", "swap"])
        self.mapping = dict((i, [None, None]) for i in self.partitions)
        
        self.default_filesystem = self.DEFAULT_ROOT_FS
        #XX: ^^ For compatibility purposes only.

    def set_mount(self, partition, mountpoint):
        """Declare a mountpoint for a partition

        """
        self.mapping[partition][0] = os.path.join("/", mountpoint)

    def clear_mount(self, partition):
        """Declare that a partition shouldnt be mounted anymore

        """
        self.mapping[partition][0] = None

    def set_filesystem(self, partition, fs):
        """Declare that a partition should be formatted with fs

        """
        self.mapping[partition][1] = fs

    def clear_filesystem(self, partition):
        """Declare that a partition sholdnt be formatted

        """
        self.mapping[partition][1] = None

    def available_partitions(self):
        """Return available partitions

        """
        return self.partitions - set(self.mapping.keys())

    def available_mountpoints(self):
        """Return available mountpoints

        """
        return self.mountpoints - set(i[0] for i in self.mapping.values())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.