示例#1
0
    def probe(self):
        """ Probe for any missing information about this device.

            I'd like to avoid paying any attention to "Preferred Minor"
            as it seems problematic.
        """
        if not self.exists:
            raise RaidArrayError("device has not been created", self.name)

        try:
            self.devices[0].setup()
        except Exception:
            return

        info = raid.mdexamine(self.devices[0].path)
        if self.level is None:
            self.level = raid.raidLevel(info['level'])
示例#2
0
    def probe(self):
        """ Probe for any missing information about this device.

            I'd like to avoid paying any attention to "Preferred Minor"
            as it seems problematic.
        """
        if not self.exists:
            raise RaidArrayError("device has not been created", self.name)

        try:
            self.devices[0].setup()
        except Exception:
            return

        info = raid.mdexamine(self.devices[0].path)
        if self.level is None:
            self.level = raid.raidLevel(info['level'])
示例#3
0
    def __init__(self, name, level=None, major=None, minor=None, size=None,
                 memberDevices=None, totalDevices=None,
                 uuid=None, format=None, exists=None,
                 parents=None, sysfsPath=''):
        """ Create a RaidArray instance.

            Arguments:

                name -- the device name (generally a device node's basename)

            Keyword Arguments:

                level -- the device's RAID level (a string, eg: '1' or 'raid1')
                parents -- list of member devices (Device instances)
                size -- the device's size (units/format TBD)
                uuid -- the device's UUID
                minor -- the device minor
                sysfsPath -- sysfs device path
                format -- a DeviceFormat instance
                exists -- indicates whether this is an existing device
        """
        Device.__init__(self, name, format=format, exists=exists,
                               major=major, minor=minor, size=size,
                               parents=parents, sysfsPath=sysfsPath)

        self.level = level
        if level == "container":
            self._type = "mdcontainer"
        elif level is not None:
            self.level = raid.raidLevel(level)

        # For new arrays check if we have enough members
        if (not exists and parents and
                len(parents) < raid.get_raid_min_members(self.level)):
            raise ValueError, _("A RAID%(level)d set requires at least %(min_member)d member") % \
                                {"level":self.level, "min_member":raid.get_raid_min_members(self.level)}

        self.uuid = uuid
        self._totalDevices = numeric_type(totalDevices)
        self._memberDevices = numeric_type(memberDevices)
        self.sysfsPath = "/devices/virtual/block/%s" % name
        self.chunkSize = 512.0 / 1024.0         # chunk size in MB
        self.superBlockSize = 2.0               # superblock size in MB

        self.createMetadataVer = "1.1"
        # bitmaps are not meaningful on raid0 according to mdadm-3.0.3
        self.createBitmap = self.level != 0

        # For container members probe size now, as we cannot determine it
        # when teared down.
        if self.parents and self.parents[0].type == "mdcontainer":
            self._size = self.currentSize
            self._type = "mdbiosraidarray"

        self.formatClass = get_device_format("mdmember")
        if not self.formatClass:
            raise RaidArrayError("cannot find class for 'mdmember'", self.name)

        if self.exists and self.uuid:
            # this is a hack to work around mdadm's insistence on giving
            # really high minors to arrays it has no config entry for
            open("/etc/mdadm.conf", "a").write("ARRAY %s UUID=%s\n"
                                                % (self.path, self.uuid))
示例#4
0
    def __init__(self,
                 name,
                 level=None,
                 major=None,
                 minor=None,
                 size=None,
                 memberDevices=None,
                 totalDevices=None,
                 uuid=None,
                 format=None,
                 exists=None,
                 parents=None,
                 sysfsPath=''):
        """ Create a RaidArray instance.

            Arguments:

                name -- the device name (generally a device node's basename)

            Keyword Arguments:

                level -- the device's RAID level (a string, eg: '1' or 'raid1')
                parents -- list of member devices (Device instances)
                size -- the device's size (units/format TBD)
                uuid -- the device's UUID
                minor -- the device minor
                sysfsPath -- sysfs device path
                format -- a DeviceFormat instance
                exists -- indicates whether this is an existing device
        """
        Device.__init__(self,
                        name,
                        format=format,
                        exists=exists,
                        major=major,
                        minor=minor,
                        size=size,
                        parents=parents,
                        sysfsPath=sysfsPath)

        self.level = level
        if level == "container":
            self._type = "mdcontainer"
        elif level is not None:
            self.level = raid.raidLevel(level)

        # For new arrays check if we have enough members
        if (not exists and parents
                and len(parents) < raid.get_raid_min_members(self.level)):
            raise ValueError, _("A RAID%(level)d set requires at least %(min_member)d member") % \
                                {"level":self.level, "min_member":raid.get_raid_min_members(self.level)}

        self.uuid = uuid
        self._totalDevices = numeric_type(totalDevices)
        self._memberDevices = numeric_type(memberDevices)
        self.sysfsPath = "/devices/virtual/block/%s" % name
        self.chunkSize = 512.0 / 1024.0  # chunk size in MB
        self.superBlockSize = 2.0  # superblock size in MB

        self.createMetadataVer = "1.1"
        # bitmaps are not meaningful on raid0 according to mdadm-3.0.3
        self.createBitmap = self.level != 0

        # For container members probe size now, as we cannot determine it
        # when teared down.
        if self.parents and self.parents[0].type == "mdcontainer":
            self._size = self.currentSize
            self._type = "mdbiosraidarray"

        self.formatClass = get_device_format("mdmember")
        if not self.formatClass:
            raise RaidArrayError("cannot find class for 'mdmember'", self.name)

        if self.exists and self.uuid:
            # this is a hack to work around mdadm's insistence on giving
            # really high minors to arrays it has no config entry for
            open("/etc/mdadm.conf",
                 "a").write("ARRAY %s UUID=%s\n" % (self.path, self.uuid))