Ejemplo n.º 1
0
    def __init__(self, name, raidSet=None, format=None,
                 size=None, parents=None, sysfsPath=''):
        """ Create a DMRaidArray instance.

            Arguments:

                name -- the dmraid name also the device node's basename

            Keyword Arguments:

                raidSet -- the RaidSet object from block
                parents -- a list of the member devices
                sysfsPath -- sysfs device path
                size -- the device's size
                format -- a DeviceFormat instance
        """
        if isinstance(parents, list):
            for parent in parents:
                if not parent.format or parent.format.type != "dmraidmember":
                    raise ValueError("parent devices must contain dmraidmember format")
        DeviceMapper.__init__(self, name, format=format, size=size,
                          parents=parents, sysfsPath=sysfsPath, exists=True)

        self.formatClass = get_device_format("dmraidmember")
        if not self.formatClass:
            raise StorageError("cannot find class for 'dmraidmember'")

        self._raidSet = raidSet
Ejemplo n.º 2
0
    def __init__(self, name, vgdev, size=None, uuid=None,
                 stripes=1, logSize=0, snapshotSpace=0,
                 format=None, exists=None, sysfsPath='',
                 grow=None, maxsize=None, percent=None):
        """ Create a LogicalVolume instance.

            Arguments:

                name -- the device name (generally a device node's basename)
                vgdev -- volume group (VolumeGroup instance)

            Keyword Arguments:

                size -- the device's size (in MB)
                uuid -- the device's UUID
                stripes -- number of copies in the vg (>1 for mirrored lvs)
                logSize -- size of log volume (for mirrored lvs)
                snapshotSpace -- sum of sizes of snapshots of this lv
                sysfsPath -- sysfs device path
                format -- a DeviceFormat instance
                exists -- indicates whether this is an existing device

                For new (non-existent) LVs only:

                    grow -- whether to grow this LV
                    maxsize -- maximum size for growable LV (in MB)
                    percent -- percent of VG space to take

        """
        if isinstance(vgdev, list):
            if len(vgdev) != 1:
                raise ValueError("constructor requires a single VolumeGroup instance")
            elif not isinstance(vgdev[0], VolumeGroup):
                raise ValueError("constructor requires a VolumeGroup instance")
        elif not isinstance(vgdev, VolumeGroup):
            raise ValueError("constructor requires a VolumeGroup instance")

        DeviceMapper.__init__(self, name, size=size, format=format,
                              sysfsPath=sysfsPath, parents=vgdev, exists=exists)

        self.uuid = uuid
        self.snapshotSpace = snapshotSpace
        self.stripes = stripes
        self.logSize = logSize

        self.req_grow = None
        self.req_max_size = 0
        self.req_size = 0   
        self.req_percent = 0

        if not self.exists:
            self.req_grow = grow
            self.req_max_size = numeric_type(maxsize)
            # XXX should we enforce that req_size be pe-aligned?
            self.req_size = self._size
            self.req_percent = numeric_type(percent)

        # here we go with the circular references
        self.vg._addLogicalVolume(self)
Ejemplo n.º 3
0
    def __init__(self, name, vgdev, size=None, uuid=None,
                 stripes=1, logSize=0, snapshotSpace=0,
                 format=None, exists=None, sysfsPath='',
                 grow=None, maxsize=None, percent=None):
        """ Create a LogicalVolume instance.

            Arguments:

                name -- the device name (generally a device node's basename)
                vgdev -- volume group (VolumeGroup instance)

            Keyword Arguments:

                size -- the device's size (in MB)
                uuid -- the device's UUID
                stripes -- number of copies in the vg (>1 for mirrored lvs)
                logSize -- size of log volume (for mirrored lvs)
                snapshotSpace -- sum of sizes of snapshots of this lv
                sysfsPath -- sysfs device path
                format -- a DeviceFormat instance
                exists -- indicates whether this is an existing device

                For new (non-existent) LVs only:

                    grow -- whether to grow this LV
                    maxsize -- maximum size for growable LV (in MB)
                    percent -- percent of VG space to take

        """
        if isinstance(vgdev, list):
            if len(vgdev) != 1:
                raise ValueError("constructor requires a single VolumeGroup instance")
            elif not isinstance(vgdev[0], VolumeGroup):
                raise ValueError("constructor requires a VolumeGroup instance")
        elif not isinstance(vgdev, VolumeGroup):
            raise ValueError("constructor requires a VolumeGroup instance")

        DeviceMapper.__init__(self, name, size=size, format=format,
                              sysfsPath=sysfsPath, parents=vgdev, exists=exists)

        self.uuid = uuid
        self.snapshotSpace = snapshotSpace
        self.stripes = stripes
        self.logSize = logSize

        self.req_grow = None
        self.req_max_size = 0
        self.req_size = 0   
        self.req_percent = 0

        if not self.exists:
            self.req_grow = grow
            self.req_max_size = numeric_type(maxsize)
            # XXX should we enforce that req_size be pe-aligned?
            self.req_size = self._size
            self.req_percent = numeric_type(percent)

        # here we go with the circular references
        self.vg._addLogicalVolume(self)
Ejemplo n.º 4
0
 def __str__(self):
     s = DeviceMapper.__str__(self)
     s += ("  VG device = %(vgdev)r  percent = %(percent)s\n"
           "  mirrored = %(mirrored)s stripes = %(stripes)d"
           "  snapshot total =  %(snapshots)dMB\n"
           "  VG space used = %(vgspace)dMB" %
           {"vgdev": self.vg, "percent": self.req_percent,
            "mirrored": self.mirrored, "stripes": self.stripes,
            "snapshots": self.snapshotSpace, "vgspace": self.vgSpaceUsed })
     return s
Ejemplo n.º 5
0
 def __str__(self):
     s = DeviceMapper.__str__(self)
     s += ("  VG device = %(vgdev)r  percent = %(percent)s\n"
           "  mirrored = %(mirrored)s stripes = %(stripes)d"
           "  snapshot total =  %(snapshots)dMB\n"
           "  VG space used = %(vgspace)dMB" %
           {"vgdev": self.vg, "percent": self.req_percent,
            "mirrored": self.mirrored, "stripes": self.stripes,
            "snapshots": self.snapshotSpace, "vgspace": self.vgSpaceUsed })
     return s
Ejemplo n.º 6
0
    def __init__(self,
                 name,
                 raidSet=None,
                 format=None,
                 size=None,
                 parents=None,
                 sysfsPath=''):
        """ Create a DMRaidArray instance.

            Arguments:

                name -- the dmraid name also the device node's basename

            Keyword Arguments:

                raidSet -- the RaidSet object from block
                parents -- a list of the member devices
                sysfsPath -- sysfs device path
                size -- the device's size
                format -- a DeviceFormat instance
        """
        if isinstance(parents, list):
            for parent in parents:
                if not parent.format or parent.format.type != "dmraidmember":
                    raise ValueError(
                        "parent devices must contain dmraidmember format")
        DeviceMapper.__init__(self,
                              name,
                              format=format,
                              size=size,
                              parents=parents,
                              sysfsPath=sysfsPath,
                              exists=True)

        self.formatClass = get_device_format("dmraidmember")
        if not self.formatClass:
            raise DMRaidArrayError("cannot find class for 'dmraidmember'")

        self._raidSet = raidSet