Exemple #1
0
        """ Probe for any missing information about this format. """
        if not self.exists:
            raise RaidMemberError("format does not exist", self.device)

        info = raid.mdexamine(self.device)
        if self.uuid is None:
            self.uuid = info['uuid']
        if self.raidMinor is None:
            self.raidMinor = info['mdMinor']

    def destroy(self, *args, **kwargs):
        if not self.exists:
            raise RaidMemberError("format does not exist", self.device)

        if not os.access(self.device, os.W_OK):
            raise RaidMemberError("device path does not exist", self.device)

        raid.mddestroy(self.device)
        self.exists = False

    @property
    def status(self):
        # XXX hack -- we don't have a nice way to see if the array is active
        return False

    @property
    def hidden(self):
        return (self._hidden or self.biosraid)

register_device_format(RaidMember)
Exemple #2
0
            raise PhysicalVolumeError("Create device failed!", self.device)
        else:
            self.exists = True
            self.notifyKernel()

    def destroy(self, *args, **kwargs):
        """ Destroy the format. """
        if not self.exists:
            raise PhysicalVolumeError("format has not been created", self.device)

        if self.status:
            raise PhysicalVolumeError("device is active", self.device)

        # FIXME: verify path exists?
        try:
            lvm.pvremove(self.device)
        except lvm.LVMError:
            Format.destroy(self, *args, **kwargs)

        self.exists = False
        self.notifyKernel()

    @property
    def status(self):
        # XXX hack
        return (self.exists and self.vgName and
                os.path.isdir("/dev/mapper/%s" % self.vgName))

register_device_format(PhysicalVolume)

        """ Probe for any missing information about this format. """
        if not self.exists:
            raise RaidMemberError("format does not exist", self.device)

        info = raid.mdexamine(self.device)
        if self.uuid is None:
            self.uuid = info['uuid']
        if self.raidMinor is None:
            self.raidMinor = info['mdMinor']

    def destroy(self, *args, **kwargs):
        if not self.exists:
            raise RaidMemberError("format does not exist", self.device)

        if not os.access(self.device, os.W_OK):
            raise RaidMemberError("device path does not exist", self.device)

        raid.mddestroy(self.device)
        self.exists = False

    @property
    def status(self):
        # XXX hack -- we don't have a nice way to see if the array is active
        return False

    @property
    def hidden(self):
        return (self._hidden or self.biosraid)

register_device_format(RaidMember)
Exemple #4
0
        """ Close, or tear down, a device. """
        if not self.exists:
            raise SwapSpaceError("format has not been created", self.device)

        if self.status:
            try:
                swap_off(self.device)
            except SwapError, msg:
                raise SwapSpaceError, msg

    def create(self, *args, **kwargs):
        """ Create the device. """
        force = kwargs.get("force")
        if not force and self.exists:
            raise SwapSpaceError("format already exists", self.device)

        if force:
            self.teardown()
        elif self.status:
            raise SwapError("device exists and is active", self.device)

        try:
            Format.create(self, *args, **kwargs)
            mkswap(self.device, label=self.label)
        except Exception, msg:
            raise SwapSpaceError, msg
        else:
            self.exists = True

register_device_format(SwapSpace)
Exemple #5
0
                                "on %s" % (self.mountType, self.device))

            self._minInstanceSize = size

        return self._minInstanceSize

    @property
    def isDirty(self):
        return yali.sysutils.ext2IsDirty(self.device)

    @property
    def resizeArgs(self):
        argv = ["-p", self.device, "%dM" % (self.targetSize,)]
        return argv

register_device_format(Ext2Filesystem)

class Ext3Filesystem(Ext2Filesystem):
    """ ext3 filesystem. """
    _type = "ext3"
    _modules = ["ext3"]
    _formatOptions = ["-t", "ext3"]
    _migrationTarget = "ext4"
    _modules = ["ext3"]
    _migrateOptions = ["-O", "extents"]
    partedSystem = fileSystemType["ext3"]

register_device_format(Ext3Filesystem)

class Ext4Filesystem(Ext3Filesystem):
    """ ext4 filesystem. """
                                "on %s" % (self.mountType, self.device))

            self._minInstanceSize = size

        return self._minInstanceSize

    @property
    def isDirty(self):
        return yali.sysutils.ext2IsDirty(self.device)

    @property
    def resizeArgs(self):
        argv = ["-p", self.device, "%dM" % (self.targetSize,)]
        return argv

register_device_format(Ext2Filesystem)

class Ext3Filesystem(Ext2Filesystem):
    """ ext3 filesystem. """
    _type = "ext3"
    _modules = ["ext3"]
    _formatOptions = ["-t", "ext3"]
    _migrationTarget = "ext4"
    _modules = ["ext3"]
    _migrateOptions = ["-O", "extents"]
    partedSystem = fileSystemType["ext3"]

register_device_format(Ext3Filesystem)

class Ext4Filesystem(Ext3Filesystem):
    """ ext4 filesystem. """
Exemple #7
0
        if not self.exists:
            raise SwapSpaceError("format has not been created", self.device)

        if self.status:
            try:
                swap_off(self.device)
            except SwapError, msg:
                raise SwapSpaceError, msg

    def create(self, *args, **kwargs):
        """ Create the device. """
        force = kwargs.get("force")
        if not force and self.exists:
            raise SwapSpaceError("format already exists", self.device)

        if force:
            self.teardown()
        elif self.status:
            raise SwapError("device exists and is active", self.device)

        try:
            Format.create(self, *args, **kwargs)
            mkswap(self.device, label=self.label)
        except Exception, msg:
            raise SwapSpaceError, msg
        else:
            self.exists = True


register_device_format(SwapSpace)
            raise PhysicalVolumeError("Create device failed!", self.device)
        else:
            self.exists = True
            self.notifyKernel()

    def destroy(self, *args, **kwargs):
        """ Destroy the format. """
        if not self.exists:
            raise PhysicalVolumeError("format has not been created", self.device)

        if self.status:
            raise PhysicalVolumeError("device is active", self.device)

        # FIXME: verify path exists?
        try:
            lvm.pvremove(self.device)
        except lvm.LVMError:
            Format.destroy(self, *args, **kwargs)

        self.exists = False
        self.notifyKernel()

    @property
    def status(self):
        # XXX hack
        return (self.exists and self.vgName and
                os.path.isdir("/dev/mapper/%s" % self.vgName))

register_device_format(PhysicalVolume)

Exemple #9
0
                optimum_device_alignment = None

            try:
                minimum_device_alignment = self.partedDevice.minimumAlignment
            except _ped.CreateException:
                minimum_device_alignment = None

            try:
                a = optimum_device_alignment.intersect(disklabel_alignment)
            except (ArithmeticError, AttributeError):
                try:
                    a = minimum_device_alignment.intersect(disklabel_alignment)
                except (ArithmeticError, AttributeError):
                    a = disklabel_alignment

            self._alignment = a

        return self._alignment

    @property
    def endAlignment(self):
        if not self._endAlignment:
            self._endAlignment = parted.Alignment(
                offset=self.alignment.offset - 1,
                grainSize=self.alignment.grainSize)

        return self._endAlignment


register_device_format(DiskLabel)
Exemple #10
0
                optimum_device_alignment = None

            try:
                minimum_device_alignment = self.partedDevice.minimumAlignment
            except _ped.CreateException:
                minimum_device_alignment = None

            try:
                a = optimum_device_alignment.intersect(disklabel_alignment)
            except (ArithmeticError, AttributeError):
                try:
                    a = minimum_device_alignment.intersect(disklabel_alignment)
                except (ArithmeticError, AttributeError):
                    a = disklabel_alignment

            self._alignment = a

        return self._alignment

    @property
    def endAlignment(self):
        if not self._endAlignment:
            self._endAlignment = parted.Alignment(
                                        offset = self.alignment.offset - 1,
                                        grainSize = self.alignment.grainSize)

        return self._endAlignment

register_device_format(DiskLabel)