def test_find_sr_from_vdi(self): vdi_ref = "fake-ref" def fake_call_xenapi(method, *args): self.assertEqual(method, "VDI.get_SR") self.assertEqual(args[0], vdi_ref) return args[0] session = mock.Mock() session.call_xenapi.side_effect = fake_call_xenapi self.assertEqual(volume_utils.find_sr_from_vdi(session, vdi_ref), vdi_ref)
def test_find_sr_from_vdi(self): vdi_ref = 'fake-ref' def fake_call_xenapi(method, *args): self.assertEqual(method, 'VDI.get_SR') self.assertEqual(args[0], vdi_ref) return args[0] session = mock.Mock() session.call_xenapi.side_effect = fake_call_xenapi self.assertEqual(volume_utils.find_sr_from_vdi(session, vdi_ref), vdi_ref)
def safe_cleanup_from_vdis(self, vdi_refs): # A helper method to detach volumes that are not associated with an # instance for vdi_ref in vdi_refs: try: sr_ref = volume_utils.find_sr_from_vdi(self._session, vdi_ref) except exception.StorageError as exc: LOG.debug(exc.format_message()) continue try: # Forget (i.e. disconnect) SR only if not in use volume_utils.purge_sr(self._session, sr_ref) except Exception: LOG.debug("Ignoring error while purging sr: %s" % sr_ref, exc_info=True)
def safe_cleanup_from_vdis(self, vdi_refs): # A helper method to detach volumes that are not associated with an # instance for vdi_ref in vdi_refs: try: sr_ref = volume_utils.find_sr_from_vdi(self._session, vdi_ref) except exception.StorageError as exc: LOG.debug(exc.format_message()) continue try: # Forget (i.e. disconnect) SR only if not in use volume_utils.purge_sr(self._session, sr_ref) except Exception: LOG.debug('Ignoring error while purging sr: %s' % sr_ref, exc_info=True)