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)
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)
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)
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
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
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)
def activateNoRefcount(self, lvName, refresh=False): path = self._getPath(lvName) lvutil.activateNoRefcount(path, refresh) self.lvs[lvName].active = True
def activateNoRefcount(self, lvName, refresh = False): path = self._getPath(lvName) lvutil.activateNoRefcount(path, refresh) self.lvs[lvName].active = True