summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/scheduler/manager.py74
-rw-r--r--nova/scheduler/rpcapi.py13
-rw-r--r--nova/tests/scheduler/test_rpcapi.py12
3 files changed, 85 insertions, 14 deletions
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index 36e9a8473..d0ff30c36 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -35,6 +35,7 @@ from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova.openstack.common.notifier import api as notifier
from nova.openstack.common.rpc import common as rpc_common
+from nova.openstack.common.rpc import dispatcher as rpc_dispatcher
from nova import quota
@@ -61,6 +62,15 @@ class SchedulerManager(manager.Manager):
self.driver = importutils.import_object(scheduler_driver)
super(SchedulerManager, self).__init__(*args, **kwargs)
+ def create_rpc_dispatcher(self):
+ """Get the rpc dispatcher for this manager.
+
+ Return a dispatcher which can call out to either SchedulerManager
+ or _V2SchedulerManagerProxy depending on the RPC API version.
+ """
+ return rpc_dispatcher.RpcDispatcher([self,
+ _V2SchedulerManagerProxy(self)])
+
def __getattr__(self, key):
"""Converts all method calls to use the schedule method"""
# NOTE(russellb) Because of what this is doing, we must be careful
@@ -318,3 +328,67 @@ class SchedulerManager(manager.Manager):
@manager.periodic_task
def _expire_reservations(self, context):
QUOTAS.expire(context)
+
+
+class _V2SchedulerManagerProxy(object):
+
+ RPC_API_VERSION = '2.0'
+
+ # Notes:
+ # - remove get_host_list()
+ # - remove get_service_capabilities()
+ # - add explicit live_migration() method
+ # - remove __getattr__ magic which is replaced by schedule()
+
+ def __init__(self, manager):
+ self.manager = manager
+
+ def create_volume(self, context, volume_id, snapshot_id, reservations):
+ return self.manager.create_volume(
+ context, volume_id, snapshot_id, reservations)
+
+ # Remove instance_id, require instance
+ # Remove topic
+ # Make block_migration and disk_over_commit required
+ def live_migration(self, context, instance, dest,
+ block_migration, disk_over_commit):
+ return self.manager.live_migration(
+ context, dest, instance=instance,
+ block_migration=block_migration,
+ disk_over_commit=disk_over_commit,
+ instance_id=None)
+
+ # Remove update_db
+ # Remove instance_uuid, require instance
+ # Remove instance_type_id, require instance_type
+ # Remove topic
+ # Make reservations required
+ def prep_resize(self, context, image, request_spec, filter_properties,
+ instance, instance_type, reservations):
+ return self.manager.prep_resize(
+ context, image=image, request_spec=request_spec,
+ filter_properties=filter_properties,
+ instance=instance, instance_type=instance_type,
+ reservations=reservations, topic=None,
+ update_db=None, instance_uuid=None, instance_type_id=None)
+
+ # Remove reservations and topic
+ # Require instance_uuids in request_spec
+ def run_instance(self, context, request_spec, admin_password,
+ injected_files, requested_networks, is_first_time,
+ filter_properties):
+ return self.manager.run_instance(
+ context, request_spec, admin_password, injected_files,
+ requested_networks, is_first_time, filter_properties,
+ reservations=None, topic=None)
+
+ def show_host_resources(self, context, host):
+ return self.manager.show_host_resources(context, host)
+
+ # remove kwargs
+ # require service_name, host and capabilities
+ def update_service_capabilities(self, context, service_name,
+ host, capabilities):
+ return self.manager.update_service_capabilities(
+ context, service_name=service_name, host=host,
+ capabilities=capabilities)
diff --git a/nova/scheduler/rpcapi.py b/nova/scheduler/rpcapi.py
index 8ff564a59..b7f6b3113 100644
--- a/nova/scheduler/rpcapi.py
+++ b/nova/scheduler/rpcapi.py
@@ -42,9 +42,11 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.5 - Add reservations argument to prep_resize()
1.6 - Remove reservations argument to run_instance()
1.7 - Add create_volume() method, remove topic from live_migration()
+
+ 2.0 - Remove 1.x backwards compat
'''
- BASE_RPC_API_VERSION = '1.0'
+ BASE_RPC_API_VERSION = '2.0'
def __init__(self):
super(SchedulerAPI, self).__init__(topic=FLAGS.scheduler_topic,
@@ -58,7 +60,7 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
injected_files=injected_files,
requested_networks=requested_networks,
is_first_time=is_first_time,
- filter_properties=filter_properties), version='1.6')
+ filter_properties=filter_properties))
def prep_resize(self, ctxt, instance, instance_type, image,
request_spec, filter_properties, reservations):
@@ -68,7 +70,7 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
instance=instance_p, instance_type=instance_type_p,
image=image, request_spec=request_spec,
filter_properties=filter_properties,
- reservations=reservations), version='1.5')
+ reservations=reservations))
def show_host_resources(self, ctxt, host):
return self.call(ctxt, self.make_msg('show_host_resources', host=host))
@@ -81,14 +83,13 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
return self.call(ctxt, self.make_msg('live_migration',
block_migration=block_migration,
disk_over_commit=disk_over_commit, instance=instance_p,
- dest=dest), version='1.7')
+ dest=dest))
def create_volume(self, ctxt, volume_id, snapshot_id, reservations):
self.cast(ctxt,
self.make_msg('create_volume',
volume_id=volume_id, snapshot_id=snapshot_id,
- reservations=reservations),
- version='1.7')
+ reservations=reservations))
def update_service_capabilities(self, ctxt, service_name, host,
capabilities):
diff --git a/nova/tests/scheduler/test_rpcapi.py b/nova/tests/scheduler/test_rpcapi.py
index 95133622b..1ff278a20 100644
--- a/nova/tests/scheduler/test_rpcapi.py
+++ b/nova/tests/scheduler/test_rpcapi.py
@@ -67,16 +67,14 @@ class SchedulerRpcAPITestCase(test.TestCase):
request_spec='fake_request_spec',
admin_password='pw', injected_files='fake_injected_files',
requested_networks='fake_requested_networks',
- is_first_time=True, filter_properties='fake_filter_properties',
- version='1.6')
+ is_first_time=True, filter_properties='fake_filter_properties')
def test_prep_resize(self):
self._test_scheduler_api('prep_resize', rpc_method='cast',
instance='fake_instance',
instance_type='fake_type', image='fake_image',
request_spec='fake_request_spec',
- filter_properties='fake_props', reservations=list('fake_res'),
- version='1.5')
+ filter_properties='fake_props', reservations=list('fake_res'))
def test_show_host_resources(self):
self._test_scheduler_api('show_host_resources', rpc_method='call',
@@ -86,8 +84,7 @@ class SchedulerRpcAPITestCase(test.TestCase):
self._test_scheduler_api('live_migration', rpc_method='call',
block_migration='fake_block_migration',
disk_over_commit='fake_disk_over_commit',
- instance='fake_instance', dest='fake_dest',
- version='1.7')
+ instance='fake_instance', dest='fake_dest')
def test_update_service_capabilities(self):
self._test_scheduler_api('update_service_capabilities',
@@ -97,5 +94,4 @@ class SchedulerRpcAPITestCase(test.TestCase):
def test_create_volume(self):
self._test_scheduler_api('create_volume',
rpc_method='cast', volume_id="fake_volume",
- snapshot_id="fake_snapshots", reservations=list('fake_res'),
- version='1.7')
+ snapshot_id="fake_snapshots", reservations=list('fake_res'))