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
This commit is contained in:
@@ -1908,25 +1908,23 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
dest = "fake_host_2"
|
dest = "fake_host_2"
|
||||||
src = instance_ref['host']
|
src = instance_ref['host']
|
||||||
conn = libvirt_driver.LibvirtDriver(False)
|
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, '_create_shared_storage_test_file')
|
||||||
self.mox.StubOutWithMock(conn, '_compare_cpu')
|
self.mox.StubOutWithMock(conn, '_compare_cpu')
|
||||||
|
|
||||||
conn._get_compute_info(self.context, FLAGS.host).AndReturn(
|
|
||||||
{'disk_available_least': 400})
|
|
||||||
# _check_cpu_match
|
# _check_cpu_match
|
||||||
conn._get_compute_info(self.context,
|
|
||||||
src).AndReturn({'cpu_info': "asdf"})
|
|
||||||
conn._compare_cpu("asdf")
|
conn._compare_cpu("asdf")
|
||||||
|
|
||||||
# mounted_on_same_shared_storage
|
# mounted_on_same_shared_storage
|
||||||
filename = "file"
|
|
||||||
conn._create_shared_storage_test_file().AndReturn(filename)
|
conn._create_shared_storage_test_file().AndReturn(filename)
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
return_value = conn.check_can_live_migrate_destination(self.context,
|
return_value = conn.check_can_live_migrate_destination(self.context,
|
||||||
instance_ref, True)
|
instance_ref, compute_info, compute_info, True)
|
||||||
self.assertDictMatch(return_value,
|
self.assertDictMatch(return_value,
|
||||||
{"filename": "file",
|
{"filename": "file",
|
||||||
'disk_available_mb': 409600,
|
'disk_available_mb': 409600,
|
||||||
@@ -1938,23 +1936,21 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
dest = "fake_host_2"
|
dest = "fake_host_2"
|
||||||
src = instance_ref['host']
|
src = instance_ref['host']
|
||||||
conn = libvirt_driver.LibvirtDriver(False)
|
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, '_create_shared_storage_test_file')
|
||||||
self.mox.StubOutWithMock(conn, '_compare_cpu')
|
self.mox.StubOutWithMock(conn, '_compare_cpu')
|
||||||
|
|
||||||
# _check_cpu_match
|
# _check_cpu_match
|
||||||
conn._get_compute_info(self.context,
|
|
||||||
src).AndReturn({'cpu_info': "asdf"})
|
|
||||||
conn._compare_cpu("asdf")
|
conn._compare_cpu("asdf")
|
||||||
|
|
||||||
# mounted_on_same_shared_storage
|
# mounted_on_same_shared_storage
|
||||||
filename = "file"
|
|
||||||
conn._create_shared_storage_test_file().AndReturn(filename)
|
conn._create_shared_storage_test_file().AndReturn(filename)
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
return_value = conn.check_can_live_migrate_destination(self.context,
|
return_value = conn.check_can_live_migrate_destination(self.context,
|
||||||
instance_ref, False)
|
instance_ref, compute_info, compute_info, False)
|
||||||
self.assertDictMatch(return_value,
|
self.assertDictMatch(return_value,
|
||||||
{"filename": "file",
|
{"filename": "file",
|
||||||
"block_migration": False,
|
"block_migration": False,
|
||||||
@@ -1966,18 +1962,17 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
dest = "fake_host_2"
|
dest = "fake_host_2"
|
||||||
src = instance_ref['host']
|
src = instance_ref['host']
|
||||||
conn = libvirt_driver.LibvirtDriver(False)
|
conn = libvirt_driver.LibvirtDriver(False)
|
||||||
|
compute_info = {'cpu_info': 'asdf'}
|
||||||
|
|
||||||
self.mox.StubOutWithMock(conn, '_get_compute_info')
|
|
||||||
self.mox.StubOutWithMock(conn, '_compare_cpu')
|
self.mox.StubOutWithMock(conn, '_compare_cpu')
|
||||||
|
|
||||||
conn._get_compute_info(self.context, src).AndReturn(
|
|
||||||
{'cpu_info': "asdf"})
|
|
||||||
conn._compare_cpu("asdf").AndRaise(exception.InvalidCPUInfo)
|
conn._compare_cpu("asdf").AndRaise(exception.InvalidCPUInfo)
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
self.assertRaises(exception.InvalidCPUInfo,
|
self.assertRaises(exception.InvalidCPUInfo,
|
||||||
conn.check_can_live_migrate_destination,
|
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):
|
def test_check_can_live_migrate_dest_cleanup_works_correctly(self):
|
||||||
instance_ref = db.instance_create(self.context, self.test_instance)
|
instance_ref = db.instance_create(self.context, self.test_instance)
|
||||||
|
|||||||
@@ -2398,7 +2398,9 @@ class XenAPILiveMigrateTestCase(stubs.XenAPITestBase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = self.conn.check_can_live_migrate_destination(self.context,
|
result = self.conn.check_can_live_migrate_destination(self.context,
|
||||||
{'host': 'host'}, True, False)
|
{'host': 'host'},
|
||||||
|
{}, {},
|
||||||
|
True, False)
|
||||||
self.assertEqual(expected, result)
|
self.assertEqual(expected, result)
|
||||||
|
|
||||||
def test_check_can_live_migrate_destination_block_migration_fails(self):
|
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.conn = xenapi_conn.XenAPIDriver(False)
|
||||||
self.assertRaises(exception.MigrationError,
|
self.assertRaises(exception.MigrationError,
|
||||||
self.conn.check_can_live_migrate_destination,
|
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):
|
def test_check_can_live_migrate_source_with_block_migrate(self):
|
||||||
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
|
stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
|
||||||
|
|||||||
Reference in New Issue
Block a user