Merge "Move migration_get_..._by_host_and_node to conductor"

This commit is contained in:
Jenkins 2013-01-16 16:15:51 +00:00 committed by Gerrit Code Review
commit b709a9a808
6 changed files with 38 additions and 2 deletions

View File

@ -259,7 +259,8 @@ class ResourceTracker(object):
self._update_usage_from_instances(resources, instances)
# Grab all in-progress migrations:
migrations = db.migration_get_in_progress_by_host_and_node(context,
capi = self.conductor_api
migrations = capi.migration_get_in_progress_by_host_and_node(context,
self.host, self.nodename)
self._update_usage_from_migrations(resources, migrations)

View File

@ -134,6 +134,10 @@ class LocalAPI(object):
return self._manager.migration_get_unconfirmed_by_dest_compute(
context, confirm_window, dest_compute)
def migration_get_in_progress_by_host_and_node(self, context, host, node):
return self._manager.migration_get_in_progress_by_host_and_node(
context, host, node)
def migration_create(self, context, instance, values):
return self._manager.migration_create(context, instance, values)
@ -370,6 +374,11 @@ class API(object):
return crpcapi.migration_get_unconfirmed_by_dest_compute(
context, confirm_window, dest_compute)
def migration_get_in_progress_by_host_and_node(self, context, host, node):
crpcapi = self.conductor_rpcapi
return crpcapi.migration_get_in_progress_by_host_and_node(context,
host, node)
def migration_create(self, context, instance, values):
return self.conductor_rpcapi.migration_create(context, instance,
values)

View File

@ -43,7 +43,7 @@ datetime_fields = ['launched_at', 'terminated_at']
class ConductorManager(manager.SchedulerDependentManager):
"""Mission: TBD."""
RPC_API_VERSION = '1.30'
RPC_API_VERSION = '1.31'
def __init__(self, *args, **kwargs):
super(ConductorManager, self).__init__(service_name='conductor',
@ -100,6 +100,12 @@ class ConductorManager(manager.SchedulerDependentManager):
context, confirm_window, dest_compute)
return jsonutils.to_primitive(migrations)
def migration_get_in_progress_by_host_and_node(self, context,
host, node):
migrations = self.db.migration_get_in_progress_by_host_and_node(
context, host, node)
return jsonutils.to_primitive(migrations)
def migration_create(self, context, instance, values):
values.update({'instance_uuid': instance['uuid'],
'source_compute': instance['host'],

View File

@ -63,6 +63,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.28 - Added binary arg to service_get_all_by
1.29 - Added service_destroy
1.30 - Added migration_create
1.31 - Added migration_get_in_progress_by_host_and_node
"""
BASE_RPC_API_VERSION = '1.0'
@ -106,6 +107,12 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
dest_compute=dest_compute)
return self.call(context, msg, version='1.20')
def migration_get_in_progress_by_host_and_node(self, context,
host, node):
msg = self.make_msg('migration_get_in_progress_by_host_and_node',
host=host, node=node)
return self.call(context, msg, version='1.31')
def migration_create(self, context, instance, values):
instance_p = jsonutils.to_primitive(instance)
msg = self.make_msg('migration_create', instance=instance_p,

View File

@ -80,6 +80,9 @@ class MultiNodeComputeTestCase(BaseTestCase):
super(MultiNodeComputeTestCase, self).setUp()
self.flags(compute_driver='nova.virt.fake.FakeDriver')
self.compute = importutils.import_object(CONF.compute_manager)
self.flags(use_local=True, group='conductor')
self.conductor = self.start_service('conductor',
manager=CONF.conductor.manager)
def test_update_available_resource_add_remove_node(self):
ctx = context.get_admin_context()

View File

@ -130,6 +130,16 @@ class _BaseTestCase(object):
'fake-window',
'fake-host')
def test_migration_get_in_progress_by_host_and_node(self):
self.mox.StubOutWithMock(db,
'migration_get_in_progress_by_host_and_node')
db.migration_get_in_progress_by_host_and_node(
self.context, 'fake-host', 'fake-node').AndReturn('fake-result')
self.mox.ReplayAll()
result = self.conductor.migration_get_in_progress_by_host_and_node(
self.context, 'fake-host', 'fake-node')
self.assertEqual(result, 'fake-result')
def test_migration_create(self):
inst = {'uuid': 'fake-uuid',
'host': 'fake-host',