From 7d81801f28e012fa418980e182e81d11cae84288 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 24 Oct 2012 14:33:08 -0700 Subject: [PATCH] Remove database usage from libvirt check_can_live_migrate_destination While libvirt is the only one that actually uses the compute host info during this check, I think that it's an entirely reasonable thing to pass to each hypervisor when doing the "can I migrate to this host" check. Thus, I've added it excplicitly, without a gating check of the capabilities. Related to bp:no-db-compute Change-Id: I7049879fcec3894165f1bece9beeb045ed78c94b --- nova/tests/test_libvirt.py | 27 +++++++++++---------------- nova/tests/test_xenapi.py | 8 ++++++-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index f8bc3c33..5a158c4b 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1908,25 +1908,23 @@ class LibvirtConnTestCase(test.TestCase): dest = "fake_host_2" src = instance_ref['host'] conn = libvirt_driver.LibvirtDriver(False) + compute_info = {'disk_available_least': 400, + 'cpu_info': 'asdf', + } + filename = "file" - self.mox.StubOutWithMock(conn, '_get_compute_info') self.mox.StubOutWithMock(conn, '_create_shared_storage_test_file') self.mox.StubOutWithMock(conn, '_compare_cpu') - conn._get_compute_info(self.context, FLAGS.host).AndReturn( - {'disk_available_least': 400}) # _check_cpu_match - conn._get_compute_info(self.context, - src).AndReturn({'cpu_info': "asdf"}) conn._compare_cpu("asdf") # mounted_on_same_shared_storage - filename = "file" conn._create_shared_storage_test_file().AndReturn(filename) self.mox.ReplayAll() return_value = conn.check_can_live_migrate_destination(self.context, - instance_ref, True) + instance_ref, compute_info, compute_info, True) self.assertDictMatch(return_value, {"filename": "file", 'disk_available_mb': 409600, @@ -1938,23 +1936,21 @@ class LibvirtConnTestCase(test.TestCase): dest = "fake_host_2" src = instance_ref['host'] conn = libvirt_driver.LibvirtDriver(False) + compute_info = {'cpu_info': 'asdf'} + filename = "file" - self.mox.StubOutWithMock(conn, '_get_compute_info') self.mox.StubOutWithMock(conn, '_create_shared_storage_test_file') self.mox.StubOutWithMock(conn, '_compare_cpu') # _check_cpu_match - conn._get_compute_info(self.context, - src).AndReturn({'cpu_info': "asdf"}) conn._compare_cpu("asdf") # mounted_on_same_shared_storage - filename = "file" conn._create_shared_storage_test_file().AndReturn(filename) self.mox.ReplayAll() return_value = conn.check_can_live_migrate_destination(self.context, - instance_ref, False) + instance_ref, compute_info, compute_info, False) self.assertDictMatch(return_value, {"filename": "file", "block_migration": False, @@ -1966,18 +1962,17 @@ class LibvirtConnTestCase(test.TestCase): dest = "fake_host_2" src = instance_ref['host'] conn = libvirt_driver.LibvirtDriver(False) + compute_info = {'cpu_info': 'asdf'} - self.mox.StubOutWithMock(conn, '_get_compute_info') self.mox.StubOutWithMock(conn, '_compare_cpu') - conn._get_compute_info(self.context, src).AndReturn( - {'cpu_info': "asdf"}) conn._compare_cpu("asdf").AndRaise(exception.InvalidCPUInfo) self.mox.ReplayAll() self.assertRaises(exception.InvalidCPUInfo, conn.check_can_live_migrate_destination, - self.context, instance_ref, False) + self.context, instance_ref, + compute_info, compute_info, False) def test_check_can_live_migrate_dest_cleanup_works_correctly(self): instance_ref = db.instance_create(self.context, self.test_instance) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 11e8844c..fa10cfda 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -2398,7 +2398,9 @@ class XenAPILiveMigrateTestCase(stubs.XenAPITestBase): } } result = self.conn.check_can_live_migrate_destination(self.context, - {'host': 'host'}, True, False) + {'host': 'host'}, + {}, {}, + True, False) self.assertEqual(expected, result) def test_check_can_live_migrate_destination_block_migration_fails(self): @@ -2407,7 +2409,9 @@ class XenAPILiveMigrateTestCase(stubs.XenAPITestBase): self.conn = xenapi_conn.XenAPIDriver(False) self.assertRaises(exception.MigrationError, self.conn.check_can_live_migrate_destination, - self.context, {'host': 'host'}, True, False) + self.context, {'host': 'host'}, + {}, {}, + True, False) def test_check_can_live_migrate_source_with_block_migrate(self): stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)