Example #1
0
    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)
Example #2
0
    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)
Example #3
0
    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)
Example #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
Example #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
Example #6
0
    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)
Example #7
0
 def activateNoRefcount(self, lvName, refresh=False):
     path = self._getPath(lvName)
     lvutil.activateNoRefcount(path, refresh)
     self.lvs[lvName].active = True
Example #8
0
 def activateNoRefcount(self, lvName, refresh = False):
     path = self._getPath(lvName)
     lvutil.activateNoRefcount(path, refresh)
     self.lvs[lvName].active = True