def search(cls, pathspec=None): """Search for logical volumes matching ``pathspec`` This will search for any logical volumes matching ``pathspec`` and return an iterable that provides instances of LogicalVolume :returns: iterable of LogicalVolume instances """ for volume in lvs(pathspec): yield cls(volume)
def test_lvs(self): """Test lv""" log_vol, = lvs("%s/%s" % (TEST_VG, TEST_LV)) self.assertEqual(log_vol["vg_name"], TEST_VG) vg_extents = int(log_vol["vg_extent_count"]) self.assertEqual(int(vg_extents), 31) vg_extent_size = int(log_vol["vg_extent_size"]) self.assertEqual(int(vg_extent_size), 4194304) self.assertEqual(int(log_vol["lv_size"]), IMG_SIZE / 2)
def lookup(cls, pathspec): """Lookup a logical volume for ``pathspec`` This will always return the first volume group found and raise an error if multiple volumes match ``pathspec`` :returns: LogicalVolume instance """ try: volume, = lvs(pathspec) return cls(volume) except (LVMCommandError, ValueError): #XX: Perhaps we should be more specific :) raise LookupError("No LogicalVolume could be found " "for pathspec %r" % pathspec)
def reload(self): """Reload the data for this LogicalVolume""" self.attributes, = lvs(self.device_name())