Ejemplo n.º 1
0
    def __init__(self,
                 name,
                 parents,
                 size=None,
                 free=None,
                 peSize=None,
                 peCount=None,
                 peFree=None,
                 pvCount=None,
                 uuid=None,
                 exists=None,
                 sysfsPath=''):
        """ Create a VolumeGroup instance.

            Arguments:

                name -- the device name (generally a device node's basename)
                parents -- a list of physical volumes (Device)

            Keyword Arguments:

                peSize -- physical extent size (in MB)
                exists -- indicates whether this is an existing device
                sysfsPath -- sysfs device path

                For existing VG's only:

                    size -- the VG's size (in MB)
                    free -- amount of free space in the VG
                    peFree -- number of free extents
                    peCount -- total number of extents
                    pvCount -- number of PVs in this VG
                    uuid -- the VG's UUID

        """
        self.pvClass = get_device_format("lvmpv")
        if not self.pvClass:
            raise VolumeGroupError("cannot find 'lvmpv' class")

        if isinstance(parents, list):
            for dev in parents:
                if not isinstance(dev.format, self.pvClass):
                    raise ValueError("constructor requires a list of PVs")
        elif not isinstance(parents.format, self.pvClass):
            raise ValueError("constructor requires a list of PVs")

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

        self.uuid = uuid
        self.free = numeric_type(free)
        self.peSize = numeric_type(peSize)
        self.peCount = numeric_type(peCount)
        self.peFree = numeric_type(peFree)
        self.pvCount = numeric_type(pvCount)
        self.lv_names = []
        self.lv_uuids = []
        self.lv_sizes = []
        self.lv_attr = []
        self.hasDuplicate = False

        # circular references, here I come
        self._lvs = []

        # TODO: validate peSize if given
        if not self.peSize:
            self.peSize = 32.0  # MB

        if not self.exists:
            self.pvCount = len(self.parents)
Ejemplo n.º 2
0
    def __init__(
        self,
        name,
        parents,
        size=None,
        free=None,
        peSize=None,
        peCount=None,
        peFree=None,
        pvCount=None,
        uuid=None,
        exists=None,
        sysfsPath="",
    ):
        """ Create a VolumeGroup instance.

            Arguments:

                name -- the device name (generally a device node's basename)
                parents -- a list of physical volumes (Device)

            Keyword Arguments:

                peSize -- physical extent size (in MB)
                exists -- indicates whether this is an existing device
                sysfsPath -- sysfs device path

                For existing VG's only:

                    size -- the VG's size (in MB)
                    free -- amount of free space in the VG
                    peFree -- number of free extents
                    peCount -- total number of extents
                    pvCount -- number of PVs in this VG
                    uuid -- the VG's UUID

        """
        self.pvClass = get_device_format("lvmpv")
        if not self.pvClass:
            raise VolumeGroupError("cannot find 'lvmpv' class")

        if isinstance(parents, list):
            for dev in parents:
                if not isinstance(dev.format, self.pvClass):
                    raise ValueError("constructor requires a list of PVs")
        elif not isinstance(parents.format, self.pvClass):
            raise ValueError("constructor requires a list of PVs")

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

        self.uuid = uuid
        self.free = numeric_type(free)
        self.peSize = numeric_type(peSize)
        self.peCount = numeric_type(peCount)
        self.peFree = numeric_type(peFree)
        self.pvCount = numeric_type(pvCount)
        self.lv_names = []
        self.lv_uuids = []
        self.lv_sizes = []
        self.lv_attr = []
        self.hasDuplicate = False

        # circular references, here I come
        self._lvs = []

        # TODO: validate peSize if given
        if not self.peSize:
            self.peSize = 32.0  # MB

        if not self.exists:
            self.pvCount = len(self.parents)