diff options
author | Dan Smith <danms@us.ibm.com> | 2013-01-04 09:18:33 -0800 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-01-05 04:30:05 +0000 |
commit | d2edb0a0077f6acd6a9db359822b63cc1a19dbff (patch) | |
tree | 72dd10290d96f10de1ca5bf42366ad57f2b8bf33 | |
parent | ba2a0565a6451ee3227b6e11bbdd8ea75cbf1fc3 (diff) | |
download | nova-d2edb0a0077f6acd6a9db359822b63cc1a19dbff.tar.gz nova-d2edb0a0077f6acd6a9db359822b63cc1a19dbff.tar.xz nova-d2edb0a0077f6acd6a9db359822b63cc1a19dbff.zip |
Move migration_get_unconfirmed_by_dest_compute to conductor
This patch moves compute/manager's use of the db query
migration_get_unconfirmed_by_dest_compute to the conductor.
Related to blueprint no-db-compute-manager
Change-Id: Ic92f3ae09f831465d12809c14c4a18ffd394f26f
-rw-r--r-- | nova/compute/manager.py | 3 | ||||
-rw-r--r-- | nova/conductor/api.py | 13 | ||||
-rw-r--r-- | nova/conductor/manager.py | 9 | ||||
-rw-r--r-- | nova/conductor/rpcapi.py | 9 | ||||
-rw-r--r-- | nova/tests/conductor/test_conductor.py | 11 |
5 files changed, 43 insertions, 2 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 588e437f9..f8b8d08e3 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2876,7 +2876,8 @@ class ComputeManager(manager.SchedulerDependentManager): @manager.periodic_task def _poll_unconfirmed_resizes(self, context): if CONF.resize_confirm_window > 0: - migrations = self.db.migration_get_unconfirmed_by_dest_compute( + capi = self.conductor_api + migrations = capi.migration_get_unconfirmed_by_dest_compute( context, CONF.resize_confirm_window, self.host) migrations_info = dict(migration_count=len(migrations), diff --git a/nova/conductor/api.py b/nova/conductor/api.py index 883b368df..ffcf5c8eb 100644 --- a/nova/conductor/api.py +++ b/nova/conductor/api.py @@ -110,6 +110,12 @@ class LocalAPI(object): def migration_get(self, context, migration_id): return self._manager.migration_get(context, migration_id) + def migration_get_unconfirmed_by_dest_compute(self, context, + confirm_window, + dest_compute): + return self._manager.migration_get_unconfirmed_by_dest_compute( + context, confirm_window, dest_compute) + def migration_update(self, context, migration, status): return self._manager.migration_update(context, migration, status) @@ -263,6 +269,13 @@ class API(object): def migration_get(self, context, migration_id): return self.conductor_rpcapi.migration_get(context, migration_id) + def migration_get_unconfirmed_by_dest_compute(self, context, + confirm_window, + dest_compute): + crpcapi = self.conductor_rpcapi + return crpcapi.migration_get_unconfirmed_by_dest_compute( + context, confirm_window, dest_compute) + def migration_update(self, context, migration, status): return self.conductor_rpcapi.migration_update(context, migration, status) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 1585a6e83..e2e2cfc77 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -43,7 +43,7 @@ datetime_fields = ['launched_at', 'terminated_at'] class ConductorManager(manager.SchedulerDependentManager): """Mission: TBD""" - RPC_API_VERSION = '1.19' + RPC_API_VERSION = '1.20' def __init__(self, *args, **kwargs): super(ConductorManager, self).__init__(service_name='conductor', @@ -83,6 +83,13 @@ class ConductorManager(manager.SchedulerDependentManager): migration_id) return jsonutils.to_primitive(migration_ref) + def migration_get_unconfirmed_by_dest_compute(self, context, + confirm_window, + dest_compute): + migrations = self.db.migration_get_unconfirmed_by_dest_compute( + context, confirm_window, dest_compute) + return jsonutils.to_primitive(migrations) + @rpc_common.client_exceptions(exception.MigrationNotFound) def migration_update(self, context, migration, status): migration_ref = self.db.migration_update(context.elevated(), diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py index 21ee59d31..9b3a802ea 100644 --- a/nova/conductor/rpcapi.py +++ b/nova/conductor/rpcapi.py @@ -51,6 +51,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): 1.17 - Added instance_info_cache_delete 1.18 - Added instance_type_get 1.19 - Added vol_get_usage_by_time and vol_usage_update + 1.20 - Added migration_get_unconfirmed_by_dest_compute """ BASE_RPC_API_VERSION = '1.0' @@ -76,6 +77,14 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy): msg = self.make_msg('migration_get', migration_id=migration_id) return self.call(context, msg, version='1.4') + def migration_get_unconfirmed_by_dest_compute(self, context, + confirm_window, + dest_compute): + msg = self.make_msg('migration_get_unconfirmed_by_dest_compute', + confirm_window=confirm_window, + dest_compute=dest_compute) + return self.call(context, msg, version='1.20') + def migration_update(self, context, migration, status): migration_p = jsonutils.to_primitive(migration) msg = self.make_msg('migration_update', migration=migration_p, diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index d2c3df19a..b2342f5b4 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -100,6 +100,17 @@ class _BaseTestCase(object): self.conductor.migration_get(self.context, migration['id'])) + def test_migration_get_unconfirmed_by_dest_compute(self): + self.mox.StubOutWithMock(db, + 'migration_get_unconfirmed_by_dest_compute') + db.migration_get_unconfirmed_by_dest_compute(self.context, + 'fake-window', + 'fake-host') + self.mox.ReplayAll() + self.conductor.migration_get_unconfirmed_by_dest_compute(self.context, + 'fake-window', + 'fake-host') + def test_migration_update(self): migration = db.migration_create(self.context.elevated(), {'instance_uuid': 'fake-uuid', |