def test_getdevice(self): """ get root fs, and test getdevice """ dev = None filep = open("/etc/mtab", "r") for line in filep: row = line.split() if row[1] == "/": dev = row[0] filep.close() self.assertEqual(getdevice("/"), dev) self.assertEqual(getdevice("/foobarbaz"), None)
def lookup_from_fspath(cls, path): """Lookup a logical volume for the filesystem path ``path`` :returns: LogicalVolumeInstance """ device = getdevice(path) return cls.lookup(device)
def test_snapshot(self): lv = LogicalVolume.lookup('%s/%s' % (TEST_VG, TEST_LV)) snapshot = None try: snapshot = lv.snapshot(lv.lv_name + '_snapshot', 1) ok_(lv != snapshot) ok_('s' in snapshot.lv_attr) assert_equals(snapshot.lv_size, snapshot.vg_extent_size) snapshot.mount(MNT_DIR, options='nouuid') ok_(snapshot.is_mounted()) assert_equals(getdevice(MNT_DIR), os.path.realpath(snapshot.device_name())) lv.reload() snapshot.unmount() assert_equals(snapshot.is_mounted(), False) snapshot.remove() ok_(not snapshot.exists()) snapshot = None finally: if snapshot and snapshot.is_mounted(): snapshot.unmount() if snapshot and snapshot.exists(): snapshot.remove()
def test_snapshot(self): """Test snapshot""" log_vol = LogicalVolume.lookup("%s/%s" % (TEST_VG, TEST_LV)) snapshot = None try: snapshot = log_vol.snapshot(log_vol.lv_name + "_snapshot", 1) self.assertTrue(log_vol != snapshot) self.assertTrue("s" in snapshot.lv_attr) self.assertEqual(snapshot.lv_size, snapshot.vg_extent_size) snapshot.mount(self.__class__.tmpdir) self.assertTrue(snapshot.is_mounted()) self.assertEqual(getdevice(self.__class__.tmpdir), "/dev/mapper/holland-test_lv_snapshot") log_vol.reload() snapshot.unmount() self.assertEqual(snapshot.is_mounted(), False) snapshot.remove() self.assertTrue(not snapshot.exists()) snapshot = None finally: if snapshot and snapshot.is_mounted(): snapshot.unmount() if snapshot and snapshot.exists(): snapshot.remove()