From 97cfccc2ce35b29fd98809b6c7ecdd86c56f76e3 Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Mon, 24 Oct 2011 21:55:12 +0000 Subject: Fix concurrency of XenAPI sessions Fixes bug 879044 Nova currently does not serialize access to the XenAPI session which can result in multiple (green)threads trying to use the same HTTP connection. This will typically only affect Python 2.7 which has updated xmlrpclib to try to use one HTTP connection for multiple requests. Change-Id: I101d63b822c8bf8c28674a836e4b54aa8259e1a8 --- nova/tests/test_xenapi.py | 7 +++++-- nova/tests/xenapi/stubs.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index c2aa0a373..e2ed14495 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -1072,8 +1072,11 @@ class FakeSession(object): 'free-computed': 40} return json.dumps({'host_memory': vm}) - def get_xenapi(self): - return FakeXenApi() + def call_xenapi(self, method, *args): + f = FakeXenApi() + for m in method.split('.'): + f = getattr(f, m) + return f(*args) class HostStateTestCase(test.TestCase): diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py index f44d96d20..c79bda682 100644 --- a/nova/tests/xenapi/stubs.py +++ b/nova/tests/xenapi/stubs.py @@ -38,7 +38,7 @@ def stubout_instance_snapshot(stubs): sr_ref = "fakesr" vdi_ref = create_vdi(name_label=name_label, read_only=False, sr_ref=sr_ref, sharable=False) - vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref) + vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref) vdi_uuid = vdi_rec['uuid'] return [dict(vdi_type='os', vdi_uuid=vdi_uuid)] @@ -307,7 +307,7 @@ def stub_out_migration_methods(stubs): def fake_get_vdi(cls, session, vm_ref): vdi_ref = fake.create_vdi(name_label='derp', read_only=False, sr_ref='herp', sharable=False) - vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref) + vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref) return vdi_ref, {'uuid': vdi_rec['uuid'], } def fake_shutdown(self, inst, vm, hard=True): -- cgit