class LvmVolume(resources.LogicalDriveSlice):
    # Q: Why is this identified by LV UUID and VG UUID rather than just
    #    LV UUID?  Isn't the LV UUID unique enough?
    # A: We're matching LVM2's behaviour.  If you e.g. imagine a machine that
    #    has some VGs and LVs, then if you want to disambiguate them you run
    #    'vgchange -u' to get a new VG UUID.  However, there is no equivalent
    #    command to reset LV uuid, because LVM finds two LVs with the same UUID
    #    in VGs with different UUIDs to be unique enough.
    class Meta:
        identifier = GlobalId("uuid", "vg")
        icon = "lvm_lv"
        label = "Logical volume"

    vg = attributes.ResourceReference()
    uuid = attributes.Uuid()
    name = attributes.String()

    def get_label(self):
        return "%s-%s" % (self.vg.name, self.name)

    """ This has to be a class method today because at the point we call it we only has the type not the object"""

    @classmethod
    def device_type(cls):
        return "lvm_volume"
示例#2
0
    def test_uuid(self):
        u = attributes.Uuid()
        u.validate('BACBE363-A1D4-4C1A-9A08-5B47DE17AB73')
        u.validate('BACBE363A1D44C1A9A085B47DE17AB73')
        with self.assertRaises(ValueError):
            u.validate('deadbeef')

        self.assertEqual(u.cast('BACBE363A1D44C1A9A085B47DE17AB73'), 'BACBE363A1D44C1A9A085B47DE17AB73')
示例#3
0
class Disk(resources.PhysicalDisk):
    class Meta:
        identifier = GlobalId('wwid')

    lun = attributes.ResourceReference(optional=True)

    size = attributes.Bytes()
    wwid = attributes.Uuid()
    read_bytes_sec = statistics.Gauge(units="B/s", label="Read bandwidth")
    write_bytes_sec = statistics.Gauge(units="B/s", label="Write bandwidth")
class LvmGroup(resources.StoragePool):
    class Meta:
        identifier = GlobalId("uuid")
        icon = "lvm_vg"
        label = "Volume group"

    uuid = attributes.Uuid()
    name = attributes.String()
    size = attributes.Bytes()

    def get_label(self):
        return self.name