Ejemplo n.º 1
0
 def deactivateNoRefcount(self, lvName):
     path = self._getPath(lvName)
     if self.checkLV(lvName):
         lvutil.deactivateNoRefcount(path)
         self.lvs[lvName].active = False
     else:
         util.SMlog("LVMCache.deactivateNoRefcount: no LV %s" % lvName)
         lvutil._lvmBugCleanup(path)
Ejemplo n.º 2
0
 def deactivateNoRefcount(self, lvName):
     path = self._getPath(lvName)
     if self.checkLV(lvName):
         lvutil.deactivateNoRefcount(path)
         self.lvs[lvName].active = False
     else:
         util.SMlog("LVMCache.deactivateNoRefcount: no LV %s" % lvName)
         lvutil._lvmBugCleanup(path)
Ejemplo n.º 3
0
    def test_deactivate_noref_withnobugcleanup(self, lvsystem, mock_pread):
        # Arrange
        self.__create_test_volume(lvsystem)
        self.mock_exists.return_value = False
        mock_pread.side_effect = [0, 0]

        # Act
        lvutil.deactivateNoRefcount(
            'VG_XenStorage-b3b18d06-b2ba-5b67-f098-3cdd5087a2a7/volume')
Ejemplo n.º 4
0
    def test_deactivate_noref_withbugcleanup(self, lvsystem):
        # Arrange
        self.__create_test_volume(lvsystem)
        self.mock_exists.return_value = True
        self.mock_lexists.return_value = True

        # Act
        lvutil.deactivateNoRefcount(
            'VG_XenStorage-b3b18d06-b2ba-5b67-f098-3cdd5087a2a7/volume')
Ejemplo n.º 5
0
    def test_deactivate_noref_withbugcleanup_retry(self, lvsystem, mock_pread):
        # Arrange
        self.__create_test_volume(lvsystem)
        self.mock_exists.return_value = True
        self.mock_lexists.return_value = True
        mock_pread.side_effect = [
            0, util.CommandException(0),
            util.CommandException(1), 0
        ]

        # Act
        lvutil.deactivateNoRefcount(
            'VG_XenStorage-b3b18d06-b2ba-5b67-f098-3cdd5087a2a7/volume')
Ejemplo n.º 6
0
def deactivateVdi(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.put(vdi_uuid, False, name_space)
        if count > 0:
            return
        try:
            lvutil.deactivateNoRefcount(vhd_path)
        except Exception as e:
            util.SMlog("  lv de-activate failed for %s with error %s" %
                       (vhd_path, str(e)))
            RefCounter.get(vdi_uuid, False, name_space)
    finally:
        lock.release()
Ejemplo n.º 7
0
def deactivateVdi(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.put(vdi_uuid, False, name_space)
        if count > 0:
            return
        try:
            lvutil.deactivateNoRefcount(vhd_path)
        except Exception, e:
            util.SMlog("  lv de-activate failed for %s with error %s" %
                       (vhd_path, str(e)))
            RefCounter.get(vdi_uuid, False, name_space)
    finally:
        lock.release()
Ejemplo n.º 8
0
    def test_deactivate_noref_withbugcleanup_retry_fail(
            self, lvsystem, mock_pread, mock_sleep, mock_symlink):
        # Arrange
        self.__create_test_volume(lvsystem)
        self.mock_exists.return_value = True
        self.mock_lexists.return_value = False
        side_effect = [0, util.CommandException(0)]
        side_effect += 11 * [
            util.CommandException(1),
            util.CommandException(0)
        ]
        mock_pread.side_effect = side_effect

        # Act
        with self.assertRaises(util.CommandException):
            lvutil.deactivateNoRefcount(
                'VG_XenStorage-b3b18d06-b2ba-5b67-f098-3cdd5087a2a7/volume')

        # Assert
        mock_symlink.assert_called_once_with(
            mock.ANY,
            'VG_XenStorage-b3b18d06-b2ba-5b67-f098-3cdd5087a2a7/volume')