def test_lvm_logical_volume_pv_free_linear(self): pv = StorageDevice("pv1", fmt=blivet.formats.get_format("lvmpv"), size=Size("1025 MiB")) pv2 = StorageDevice("pv2", fmt=blivet.formats.get_format("lvmpv"), size=Size("513 MiB")) vg = LVMVolumeGroupDevice("testvg", parents=[pv, pv2]) pv_spec = LVPVSpec(pv, Size("256 MiB")) pv_spec2 = LVPVSpec(pv2, Size("256 MiB")) lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"), fmt=blivet.formats.get_format("xfs"), exists=False, pvs=[pv_spec, pv_spec2]) self.assertEqual(lv.seg_type, "linear") self.assertEqual(pv.format.free, Size("768 MiB")) self.assertEqual(pv2.format.free, Size("256 MiB"))
def test_lvm_logical_volume_insuf_seg_type(self): # pylint: disable=unused-variable pv = StorageDevice("pv1", fmt=blivet.formats.get_format("lvmpv"), size=Size("1025 MiB")) pv2 = StorageDevice("pv2", fmt=blivet.formats.get_format("lvmpv"), size=Size("513 MiB")) vg = LVMVolumeGroupDevice("testvg", parents=[pv, pv2]) # pvs have to be specified for non-linear LVs with self.assertRaises(ValueError): lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"), fmt=blivet.formats.get_format("xfs"), exists=False, seg_type="raid1") with self.assertRaises(ValueError): lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"), fmt=blivet.formats.get_format("xfs"), exists=False, seg_type="striped") # no or complete specification has to be given for linear LVs with self.assertRaises(ValueError): lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"), fmt=blivet.formats.get_format("xfs"), exists=False, pvs=[pv]) with self.assertRaises(ValueError): pv_spec = LVPVSpec(pv, Size("256 MiB")) pv_spec2 = LVPVSpec(pv2, Size("250 MiB")) lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"), fmt=blivet.formats.get_format("xfs"), exists=False, pvs=[pv_spec, pv_spec2])
def test_lvm_logical_volume_pv_free_cached(self): pv = StorageDevice("pv1", fmt=blivet.formats.get_format("lvmpv"), size=Size("1025 MiB")) pv2 = StorageDevice("pv2", fmt=blivet.formats.get_format("lvmpv"), size=Size("513 MiB")) vg = LVMVolumeGroupDevice("testvg", parents=[pv, pv2]) pv_spec = LVPVSpec(pv, Size("256 MiB")) pv_spec2 = LVPVSpec(pv2, Size("256 MiB")) cache_req = LVMCacheRequest(Size("512 MiB"), [pv], "writethrough") lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"), fmt=blivet.formats.get_format("xfs"), exists=False, cache_request=cache_req, pvs=[pv_spec, pv_spec2]) self.assertEqual(lv.seg_type, "linear") # 1024 MiB (free) - 256 MiB (LV part) - 504 MiB (cache shrank for pmspare space) self.assertEqual(pv.format.free, Size("264 MiB")) self.assertEqual(pv2.format.free, Size("256 MiB"))
def test_lvm_logical_volume_with_pvs_init(self): pv = StorageDevice("pv1", fmt=blivet.formats.get_format("lvmpv"), size=Size("1025 MiB")) pv2 = StorageDevice("pv2", fmt=blivet.formats.get_format("lvmpv"), size=Size("512 MiB")) vg = LVMVolumeGroupDevice("testvg", parents=[pv, pv2]) pv_spec = LVPVSpec(pv, Size("1 GiB")) lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("1 GiB"), fmt=blivet.formats.get_format("xfs"), exists=False, pvs=[pv_spec]) self.assertEqual([spec.pv for spec in lv._pv_specs], [pv])