Example #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
Example #2
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
Example #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 rror, "vfat format failed: %s" % partition.path
Example #4
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
Example #5
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 rror, "%s format failed: %s" % (self.name, partition.path)
Example #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 rror, "%s format failed: %s" % (self.name, partition.path)
Example #7
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
Example #8
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
Example #9
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 rror, "vfat format failed: %s" % partition.path
Example #10
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
Example #11
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
Example #12
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()
Example #13
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
Example #14
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()
Example #15
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
Example #16
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
Example #17
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
Example #18
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
Example #19
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
Example #20
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
Example #21
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
Example #22
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)
Example #23
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)
Example #24
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)
Example #25
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)