From ef2631c90703724568f2c025ac1efe93a3270f29 Mon Sep 17 00:00:00 2001 From: masumotok Date: Thu, 26 Jan 2012 04:38:41 -0800 Subject: [PATCH] Adding live migration server actions Change-Id: I5e1f5dddaf45d1c6eae8666647425bff748b639e --- nova/scheduler/api.py | 12 ++++++++++++ nova/scheduler/driver.py | 5 ----- nova/scheduler/manager.py | 4 ---- nova/tests/scheduler/test_scheduler.py | 8 -------- nova/tests/test_compute.py | 1 + 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index b05148651..59f93b952 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -419,3 +419,15 @@ def redirect_handler(f): raise e.results return e.results return new_f + + +def live_migration(context, block_migration, disk_over_commit, + instance_id, dest, topic): + """Migrate a server to a new host""" + params = {"instance_id": instance_id, + "dest": dest, + "topic": topic, + "block_migration": block_migration, + "disk_over_commit": disk_over_commit} + return _call_scheduler("live_migration", context=context, + params=params) diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 28975e004..06f613a45 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -446,11 +446,6 @@ class Scheduler(object): # if disk_over_commit is True, # otherwise virtual disk size < available disk size. - # Refresh compute_nodes table - topic = db.queue_get_for(context, FLAGS.compute_topic, dest) - rpc.call(context, topic, - {"method": "update_available_resource"}) - # Getting total available disk of host available_gb = self._get_compute_info(context, dest, 'disk_available_least') diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index 99f51fab2..4a701496c 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -143,10 +143,6 @@ class SchedulerManager(manager.Manager): 'local_gb_used': 64} """ - # Update latest compute_node table - topic = db.queue_get_for(context, FLAGS.compute_topic, host) - rpc.call(context, topic, {"method": "update_available_resource"}) - # Getting compute node info and related instances info compute_ref = db.service_get_all_compute_by_host(context, host) compute_ref = compute_ref[0] diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 26e1aaaba..7f8645db8 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -446,10 +446,6 @@ class SchedulerTestCase(test.TestCase): db.instance_get_all_by_host(self.context, dest).AndReturn( [dict(memory_mb=256), dict(memory_mb=512)]) # assert_compute_node_has_enough_disk() - db.queue_get_for(self.context, FLAGS.compute_topic, - dest).AndReturn('dest_queue1') - rpc.call(self.context, 'dest_queue1', - {'method': 'update_available_resource'}) self.driver._get_compute_info(self.context, dest, 'disk_available_least').AndReturn(1025) db.queue_get_for(self.context, FLAGS.compute_topic, @@ -698,10 +694,6 @@ class SchedulerTestCase(test.TestCase): instance, dest) # Not enough disk - db.queue_get_for(self.context, FLAGS.compute_topic, - dest).AndReturn('dest_queue') - rpc.call(self.context, 'dest_queue', - {'method': 'update_available_resource'}) self.driver._get_compute_info(self.context, dest, 'disk_available_least').AndReturn(1023) db.queue_get_for(self.context, FLAGS.compute_topic, diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index f416e4a51..81b7cd48a 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -151,6 +151,7 @@ class BaseTestCase(test.TestCase): type_id = instance_types.get_instance_type_by_name(type_name)['id'] inst['instance_type_id'] = type_id inst['ami_launch_index'] = 0 + inst['memory_mb'] = 0 inst['root_gb'] = 0 inst['ephemeral_gb'] = 0 inst.update(params)