예제 #1
0
파일: raidarray.py 프로젝트: Tayyib/uludag
    def create(self):
        """ Create the device. """
        if self.exists:
            raise DeviceError("device already exists", self.name)

        try:
            self.createParents()
            self.setupParents()

            disks = [disk.path for disk in self.devices]
            spares = len(self.devices) - self.memberDevices
            raid.mdcreate(self.path,
                            self.level,
                            disks,
                            spares,
                            metadataVer=self.createMetadataVer,
                            bitmap=self.createBitmap)
        except Exception:
            raise
        else:
            self.exists = True
            # the array is automatically activated upon creation, but...
            self.setup()
            udev_settle()
            self.updateSysfsPath()
            info = udev_get_block_device(self.sysfsPath)
            self.uuid = udev_device_get_md_uuid(info)
            for member in self.devices:
                member.mdUuid = self.uuid
예제 #2
0
            spares = len(self.devices) - self.memberDevices
            raid.mdcreate(self.path,
                            self.level,
                            disks,
                            spares,
                            metadataVer=self.createMetadataVer,
                            bitmap=self.createBitmap)
        except Exception, msg:
            raise RaidArrayError, msg
        else:
            self.exists = True
            # the array is automatically activated upon creation, but...
            self.setup()
            udev_settle()
            self.updateSysfsPath()
            info = udev_get_block_device(self.sysfsPath)
            self.uuid = udev_device_get_md_uuid(info)
            for member in self.devices:
                member.mdUuid = self.uuid
        finally:
            if w:
                w.pop()

    @property
    def formatArgs(self):
        formatArgs = []
        if self.format.type == "ext2":
            if self.level == raid.RAID5:
                formatArgs = ['-R',
                              'stride=%d' % ((self.memberDevices - 1) * 16)]
            if self.level == raid.RAID4:
예제 #3
0
            spares = len(self.devices) - self.memberDevices
            raid.mdcreate(self.path,
                          self.level,
                          disks,
                          spares,
                          metadataVer=self.createMetadataVer,
                          bitmap=self.createBitmap)
        except Exception, msg:
            raise RaidArrayError, msg
        else:
            self.exists = True
            # the array is automatically activated upon creation, but...
            self.setup()
            udev_settle()
            self.updateSysfsPath()
            info = udev_get_block_device(self.sysfsPath)
            self.uuid = udev_device_get_md_uuid(info)
            for member in self.devices:
                member.mdUuid = self.uuid
        finally:
            if w:
                w.pop()

    @property
    def formatArgs(self):
        formatArgs = []
        if self.format.type == "ext2":
            if self.level == raid.RAID5:
                formatArgs = [
                    '-R', 'stride=%d' % ((self.memberDevices - 1) * 16)
                ]