示例#1
0
 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)
示例#2
0
文件: base.py 项目: bmildren/holland
    def lookup_from_fspath(cls, path):
        """Lookup a logical volume for the filesystem path ``path``

        :returns: LogicalVolumeInstance
        """
        device = getdevice(path)
        return cls.lookup(device)
示例#3
0
    def lookup_from_fspath(cls, path):
        """Lookup a logical volume for the filesystem path ``path``

        :returns: LogicalVolumeInstance
        """
        device = getdevice(path)
        return cls.lookup(device)
示例#4
0
 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()
示例#5
0
 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()
示例#6
0
 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()