예제 #1
0
파일: test_lvutil.py 프로젝트: xcp-ng/sm
    def test_activate_noref_norefresh(self, lvsystem):
        # Arrange
        self.__create_test_volume(lvsystem)
        self.mock_exists.return_value = True

        # Act
        lvutil.activateNoRefcount(TEST_VOL, False)
예제 #2
0
파일: test_lvutil.py 프로젝트: xcp-ng/sm
    def test_activate_noref_not_activated(self, lvsystem):
        # Arrange
        self.__create_test_volume(lvsystem)
        self.mock_exists.return_value = False

        # Act
        with self.assertRaises(util.CommandException) as ce:
            lvutil.activateNoRefcount(TEST_VOL, False)

        self.assertIn('LV not activated', ce.exception.reason)
예제 #3
0
파일: test_lvutil.py 프로젝트: xcp-ng/sm
    def test_activate_noref_IO_error_reported(self, lvsystem, mock_cmd_lvm):
        # Arrange
        self.__create_test_volume(lvsystem)
        self.mock_exists.return_value = True

        mock_cmd_lvm.side_effect = [
            util.CommandException(5, 'lvchange', "Device not found")
        ]

        # Act
        with self.assertRaises(util.CommandException) as ce:
            lvutil.activateNoRefcount(TEST_VOL, False)

        self.assertEqual(5, ce.exception.code)
예제 #4
0
def activateVdi(sr_uuid, vdi_uuid, vhd_path):
    name_space = lvhdutil.NS_PREFIX_LVM + sr_uuid
    lock = Lock(vdi_uuid, name_space)
    lock.acquire()
    try:
        count = RefCounter.get(vdi_uuid, False, name_space)
        if count == 1:
            try:
                lvutil.activateNoRefcount(vhd_path, False)
            except Exception as e:
                util.SMlog("  lv activate failed for %s with error %s" %
                           (vhd_path, str(e)))
                RefCounter.put(vdi_uuid, True, name_space)
                return False
    finally:
        lock.release()

    return True
예제 #5
0
def activateVdi(sr_uuid, vdi_uuid, vhd_path):
    name_space = lvhdutil.NS_PREFIX_LVM + sr_uuid
    lock = Lock(vdi_uuid, name_space)
    lock.acquire()
    try:
        count = RefCounter.get(vdi_uuid, False, name_space)
        if count == 1:
            try:
                lvutil.activateNoRefcount(vhd_path, False)
            except Exception, e:
                util.SMlog("  lv activate failed for %s with error %s" % 
                           (vhd_path, str(e)))
                RefCounter.put(vdi_uuid, True, name_space)
                return False
    finally:
        lock.release()

    return True
예제 #6
0
파일: test_lvutil.py 프로젝트: xcp-ng/sm
    def test_activate_noref_metadata_error_retry(self, lvsystem, mock_cmd_lvm,
                                                 mock_sleep):
        # Arrange
        self.__create_test_volume(lvsystem)
        self.mock_exists.return_value = True

        metadata_error = """  Incorrect checksum in metadata area header on /dev/sdb at 4096
   Failed to read mda header from /dev/sdb
   Failed to scan VG from /dev/sdb
   Volume group "VG_XenStorage-94d5c7de-3bee-e7c2-8aeb-d609e7dcd358" not found
   Cannot process volume group VG_XenStorage-94d5c7de-3bee-e7c2-8aeb-d609e7dcd358"""

        mock_cmd_lvm.side_effect = [
            util.CommandException(5, 'lvchange', metadata_error), ''
        ]

        # Act
        lvutil.activateNoRefcount(TEST_VOL, False)
예제 #7
0
파일: lvmcache.py 프로젝트: xcp-ng/sm
 def activateNoRefcount(self, lvName, refresh=False):
     path = self._getPath(lvName)
     lvutil.activateNoRefcount(path, refresh)
     self.lvs[lvName].active = True
예제 #8
0
파일: lvmcache.py 프로젝트: BobBall/sm
 def activateNoRefcount(self, lvName, refresh = False):
     path = self._getPath(lvName)
     lvutil.activateNoRefcount(path, refresh)
     self.lvs[lvName].active = True