summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-12-09 06:38:55 +0000
committerGerrit Code Review <review@openstack.org>2012-12-09 06:38:55 +0000
commit0e6d3a8826000bb4222b072deacfbd1df7292447 (patch)
tree884911a534e082b0978074e2be73c795d5a56f1f
parent607822644e81b2151d3bb7b65ca943394d896dcf (diff)
parentaa97ba926d5bf6bc81903c5d651ece308e9629c0 (diff)
Merge "Use conductor for migration_get()"
-rw-r--r--nova/compute/manager.py15
-rw-r--r--nova/conductor/api.py6
-rw-r--r--nova/conductor/manager.py7
-rw-r--r--nova/conductor/rpcapi.py5
-rw-r--r--nova/tests/conductor/test_conductor.py8
5 files changed, 30 insertions, 11 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 699d53b83..9dc6f2c3b 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1633,8 +1633,7 @@ class ComputeManager(manager.SchedulerDependentManager):
migration=None, migration_id=None):
"""Destroys the source instance."""
if not migration:
- migration = self.db.migration_get(context.elevated(),
- migration_id)
+ migration = self.conductor_api.migration_get(context, migration_id)
self._notify_about_instance_usage(context, instance,
"resize.confirm.start")
@@ -1670,8 +1669,7 @@ class ComputeManager(manager.SchedulerDependentManager):
"""
if not migration:
- migration = self.db.migration_get(context.elevated(),
- migration_id)
+ migration = self.conductor_api.migration_get(context, migration_id)
# NOTE(comstud): A revert_resize is essentially a resize back to
# the old size, so we need to send a usage event here.
@@ -1714,10 +1712,8 @@ class ComputeManager(manager.SchedulerDependentManager):
in the database.
"""
- elevated = context.elevated()
-
if not migration:
- migration = self.db.migration_get(elevated, migration_id)
+ migration = self.conductor_api.migration_get(context, migration_id)
with self._error_out_instance_on_exception(context, instance['uuid'],
reservations):
@@ -1898,7 +1894,7 @@ class ComputeManager(manager.SchedulerDependentManager):
instance_type=None):
"""Starts the migration of a running instance to another host."""
if not migration:
- migration = self.db.migration_get(context.elevated(), migration_id)
+ migration = self.conductor_api.migration_get(context, migration_id)
with self._error_out_instance_on_exception(context, instance['uuid'],
reservations):
if not instance_type:
@@ -2035,8 +2031,7 @@ class ComputeManager(manager.SchedulerDependentManager):
"""
if not migration:
- migration = self.db.migration_get(context.elevated(),
- migration_id)
+ migration = self.conductor_api.migration_get(context, migration_id)
try:
self._finish_resize(context, instance, migration,
disk_info, image)
diff --git a/nova/conductor/api.py b/nova/conductor/api.py
index ddbd64d03..781a6ea90 100644
--- a/nova/conductor/api.py
+++ b/nova/conductor/api.py
@@ -53,6 +53,9 @@ class LocalAPI(object):
def instance_get_all_by_host(self, context, host):
return self._manager.instance_get_all_by_host(context, host)
+ def migration_get(self, context, migration_id):
+ return self._manager.migration_get(context, migration_id)
+
def migration_update(self, context, migration, status):
return self._manager.migration_update(context, migration, status)
@@ -81,6 +84,9 @@ class API(object):
def instance_get_all_by_host(self, context, host):
return self.conductor_rpcapi.instance_get_all_by_host(context, host)
+ def migration_get(self, context, migration_id):
+ return self.conductor_rpcapi.migration_get(context, migration_id)
+
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 824875b3c..ce76fe02d 100644
--- a/nova/conductor/manager.py
+++ b/nova/conductor/manager.py
@@ -41,7 +41,7 @@ datetime_fields = ['launched_at', 'terminated_at']
class ConductorManager(manager.SchedulerDependentManager):
"""Mission: TBD"""
- RPC_API_VERSION = '1.3'
+ RPC_API_VERSION = '1.4'
def __init__(self, *args, **kwargs):
super(ConductorManager, self).__init__(service_name='conductor',
@@ -69,6 +69,11 @@ class ConductorManager(manager.SchedulerDependentManager):
return jsonutils.to_primitive(
self.db.instance_get_all_by_host(context.elevated(), host))
+ def migration_get(self, context, migration_id):
+ migration_ref = self.db.migration_get(context.elevated(),
+ migration_id)
+ return jsonutils.to_primitive(migration_ref)
+
def migration_update(self, context, migration, status):
migration_ref = self.db.migration_update(context.elevated(),
migration['id'],
diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py
index ae82856e4..0ca1269c4 100644
--- a/nova/conductor/rpcapi.py
+++ b/nova/conductor/rpcapi.py
@@ -30,6 +30,7 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.1 - Added migration_update
1.2 - Added instance_get_by_uuid and instance_get_all_by_host
1.3 - Added aggregate_host_add and aggregate_host_delete
+ 1.4 - Added migration_get
"""
BASE_RPC_API_VERSION = '1.0'
@@ -55,6 +56,10 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
msg = self.make_msg('instance_get_all_by_host', host=host)
return self.call(context, msg, version='1.2')
+ def migration_get(self, context, migration_id):
+ msg = self.make_msg('migration_get', migration_id=migration_id)
+ return self.call(context, msg, version='1.4')
+
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 880a3a717..8c97c4cdc 100644
--- a/nova/tests/conductor/test_conductor.py
+++ b/nova/tests/conductor/test_conductor.py
@@ -90,6 +90,14 @@ class ConductorTestCase(BaseTestCase):
self.assertRaises(KeyError,
self._do_update, 'any-uuid', foobar=1)
+ def test_migration_get(self):
+ migration = db.migration_create(self.context.elevated(),
+ {'instance_uuid': 'fake-uuid',
+ 'status': 'migrating'})
+ self.assertEqual(jsonutils.to_primitive(migration),
+ self.conductor.migration_get(self.context,
+ migration['id']))
+
def test_migration_update(self):
migration = db.migration_create(self.context.elevated(),
{'instance_uuid': 'fake-uuid',