From fb27cc6979dcc8b4c0ac6595dae0c6e3e413e00f Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Wed, 7 Dec 2011 18:20:03 +0000 Subject: Fix race condition in XenAPI when using .get_all Fixes bug 887708 There are a handful of places where .get_all is followed by a .get_record calls that are potentially racey. This patch fixes all of these cases to use common code that is tolerant of HANDLE_INVALID errors that would be indicative of a race between get_all and delete Change-Id: Ib94adb6d21b6b55e7b26fc1da52ed46d9dba8275 --- nova/tests/test_xenapi.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index c72ee37a7..08441e19e 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -1110,13 +1110,15 @@ class HostStateTestCase(test.TestCase): """Tests HostState, which holds metrics from XenServer that get reported back to the Schedulers.""" - def _fake_safe_find_sr(self, session): + @classmethod + def _fake_safe_find_sr(cls, session): """None SR ref since we're ignoring it in FakeSR.""" return None def test_host_state(self): self.stubs = stubout.StubOutForTesting() - self.stubs.Set(vm_utils, 'safe_find_sr', self._fake_safe_find_sr) + self.stubs.Set(vm_utils.VMHelper, 'safe_find_sr', + self._fake_safe_find_sr) host_state = xenapi_conn.HostState(FakeSession()) stats = host_state._stats self.assertEquals(stats['disk_total'], 10000) -- cgit