Beispiel #1
0
 def commit(self):
     try:
         self._disk.commit()
     except:
         sysutils.run("sync")
         time.sleep(3)
         sysutils.run("sync")
         log.error("Commit Failed!")
         self._disk.commit()
         self._isSetup = False
Beispiel #2
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("reiserfstune")
     cmd = "%s --label %s %s" % (cmd_path, label, partition.path)
     if not sysutils.run(cmd):
         return False
     return label
Beispiel #3
0
 def format(self, partition):
     self.preFormat(partition)
     cmd_path = requires("mkfs.vfat")
     cmd = "%s %s" % (cmd_path, partition.path)
     res = sysutils.run(cmd)
     if not res:
         raise PareError, "vfat format failed: %s" % partition.path
Beispiel #4
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("dosfslabel")
     cmd = "%s %s %s" % (cmd_path, partition.path, label)
     if not sysutils.run(cmd):
         return False
     return label
Beispiel #5
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("xfs_admin")
     cmd = "%s -L %s %s" % (cmd_path, label, partition.path)
     if not sysutils.run(cmd):
         return False
     return label
Beispiel #6
0
 def format(self, partition):
     self.preFormat(partition)
     cmd_path = requires("mkfs.xfs")
     cmd = "%s -f %s" % (cmd_path, partition.path)
     res = sysutils.run(cmd)
     if not res:
         raise PareError, "%s format failed: %s" % (self.name,
                                                    partition.path)
Beispiel #7
0
 def tune2fs(self, partition):
     """ Runs tune2fs for given partition """
     cmd_path = requires("tune2fs")
     # Disable mount count and use 6 month interval to fsck'ing disks at boot
     cmd = "%s -c 0 -i 6m %s" % (cmd_path, partition.path)
     res = sysutils.run(cmd)
     if not res:
         raise PareError, "tune2fs tuning failed: %s" % partition.path
Beispiel #8
0
 def getLabel(self, partition):
     """ Read file system label and return """
     cmd_path = requires("e2label")
     cmd = "%s %s" % (cmd_path, partition.path)
     label = sysutils.run(cmd, capture=True)
     if not label:
         return False
     return label.strip()
Beispiel #9
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = requires("e2label")
     cmd = "%s %s %s" % (cmd_path, partition.path, label)
     if not sysutils.run(cmd):
         return False
     # Check label consistency
     if not self.getLabel(partition) == label:
         return False
     return label
Beispiel #10
0
    def setLabel(self, partition, label):
        label = self.availableLabel(label)
        cmd_path = requires("mkswap")
        cmd = "%s -v1 -L %s %s" % (cmd_path, label, partition.path)
        if not sysutils.run(cmd):
            return False

        # Swap on
        sysutils.swap_on(partition.path)

        return label
Beispiel #11
0
    def resize(self, size, partition):
        """ Resize given partition as given size """
        if size < self.minResizeMB(partition):
            return False

        cmd_path = requires("resize2fs")

        # Check before resize
        self.preResize(partition)

        res = sysutils.run("resize2fs", [partition, "%sM" % (size)])
        if not res:
            raise FileSystemError, "Resize failed on %s" % (partition)
        return True
Beispiel #12
0
    def format(self, partition):
        """ Format the given partition """
        self.preFormat(partition)

        cmd_path = requires("mkfs.%s" % self.name)

        # bug 5616: ~100MB reserved-blocks-percentage
        reserved_percentage = int(math.ceil(100.0 * 100.0 / partition.size))

        # Use hashed b-trees to speed up lookups in large directories
        cmd = "%s -O dir_index -q -j -m %d %s" % (
            cmd_path, reserved_percentage, partition.path)

        res = sysutils.run(cmd)
        if not res:
            raise PareError, "%s format failed: %s" % (self.name,
                                                       partition.path)

        # for Disabling Lengthy Boot-Time Checks
        self.tune2fs(partition)
Beispiel #13
0
def _lvmcapture(args):
    try:
        return sysutils.run("lvm", args, capture=True)
    except RuntimeError, (errno, msg):
        #FIXME:log.error
        raise LVMError, msg
Beispiel #14
0
def _lvmclear(args):
    try:
        return sysutils.run("lvm",args)
    except Exception:
        #FIXME:log.error
        raise LVMError, args[0]
Beispiel #15
0
def _lvmcapture(args):
    try:
        return sysutils.run("lvm", args, capture=True)
    except RuntimeError, (errno, msg):
        #FIXME:log.error
        raise LVMError, msg
Beispiel #16
0
def _lvmclear(args):
    try:
        return sysutils.run("lvm", args)
    except Exception:
        #FIXME:log.error
        raise LVMError, args[0]
Beispiel #17
0
 def check_resize(self, size, partition):
     # don't do anything, just check
     cmd_path = requires("ntfsresize")
     cmd = "%s -n -f -s %dM %s" % (cmd_path, size, partition.path)
     return sysutils.run(cmd)