summaryrefslogtreecommitdiffstats
path: root/nova/scheduler/manager.py
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2012-08-29 09:21:03 +0100
committerMark McLoughlin <markmc@redhat.com>2012-08-29 12:06:36 +0100
commit8cf635b08a57a9e3be2bef980ef38cf857b6525a (patch)
treedb4eb0485f03c6445db8e61274022dc43da26b50 /nova/scheduler/manager.py
parent6727b259af491177514f075a3db91d55810c66e4 (diff)
downloadnova-8cf635b08a57a9e3be2bef980ef38cf857b6525a.tar.gz
nova-8cf635b08a57a9e3be2bef980ef38cf857b6525a.tar.xz
nova-8cf635b08a57a9e3be2bef980ef38cf857b6525a.zip
Stop using scheduler RPC API magic
If a scheduler RPC message isn't handled directly by a SchedulerManager method, the __getattr__() fallback passes the message to a driver method in the form of schedule_${method}() and, if that doesn't exist, instead calls the schedule() method supplying the topic and method args. This is pretty bizarre stuff and we appear to only use it in two cases: 1) live_migration - this is how the schedule_live_migration() method in the driver gets called, but the side-effect is that we require the client to pass a topic argument which is never used. This would be much more sanely handled with an explicit SchedulerManager.live_migration() method. 2) create_volume - the volume API asks the scheduler to pick a target host for create_volume() using this method. This would be easily handled with an SchedulerManager.create_volume() method. Change-Id: I1047489d85ac51d8d36fea1c4eb858df638ce349
Diffstat (limited to 'nova/scheduler/manager.py')
-rw-r--r--nova/scheduler/manager.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index e1030121a..36e9a8473 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -53,7 +53,7 @@ QUOTAS = quota.QUOTAS
class SchedulerManager(manager.Manager):
"""Chooses a host to run instances on."""
- RPC_API_VERSION = '1.6'
+ RPC_API_VERSION = '1.7'
def __init__(self, scheduler_driver=None, *args, **kwargs):
if not scheduler_driver:
@@ -66,6 +66,8 @@ class SchedulerManager(manager.Manager):
# NOTE(russellb) Because of what this is doing, we must be careful
# when changing the API of the scheduler drivers, as that changes
# the rpc API as well, and the version should be updated accordingly.
+ # NOTE(markmc): This remains only for backwards compat support
+ # and can be removed when we bump the major version
return functools.partial(self._schedule, key)
def get_host_list(self, context):
@@ -91,6 +93,30 @@ class SchedulerManager(manager.Manager):
self.driver.update_service_capabilities(service_name, host,
capabilities)
+ def create_volume(self, context, volume_id, snapshot_id, reservations):
+ try:
+ self.driver.schedule_create_volume(
+ context, volume_id, snapshot_id, reservations)
+ except Exception as ex:
+ with excutils.save_and_reraise_exception():
+ self._set_vm_state_and_notify('create_volume',
+ {'vm_state': vm_states.ERROR},
+ context, ex, {})
+
+ def live_migration(self, context, dest,
+ block_migration=False, disk_over_commit=False,
+ instance=None, instance_id=None, topic=None):
+ try:
+ return self.driver.schedule_live_migration(
+ context, dest,
+ block_migration, disk_over_commit,
+ instance, instance_id)
+ except Exception as ex:
+ with excutils.save_and_reraise_exception():
+ self._set_vm_state_and_notify('live_migration',
+ {'vm_state': vm_states.ERROR},
+ context, ex, {})
+
def _schedule(self, method, context, topic, *args, **kwargs):
"""Tries to call schedule_* method on the driver to retrieve host.
Falls back to schedule(context, topic) if method doesn't exist.