diff --git a/nova/scheduler/multi.py b/nova/scheduler/multi.py index c6de3f82..59e1212c 100644 --- a/nova/scheduler/multi.py +++ b/nova/scheduler/multi.py @@ -89,6 +89,9 @@ class MultiScheduler(driver.Scheduler): def schedule_prep_resize(self, *args, **kwargs): return self.drivers['compute'].schedule_prep_resize(*args, **kwargs) + def schedule_create_volume(self, *args, **kwargs): + return self.drivers['volume'].schedule_create_volume(*args, **kwargs) + def update_service_capabilities(self, service_name, host, capabilities): # Multi scheduler is only a holder of sub-schedulers, so # pass the capabilities to the schedulers that matter diff --git a/nova/scheduler/rpcapi.py b/nova/scheduler/rpcapi.py index 84d0286a..8ff564a5 100644 --- a/nova/scheduler/rpcapi.py +++ b/nova/scheduler/rpcapi.py @@ -41,6 +41,7 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy): 1.4 - Remove update_db from prep_resize 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() ''' BASE_RPC_API_VERSION = '1.0' @@ -73,14 +74,21 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy): return self.call(ctxt, self.make_msg('show_host_resources', host=host)) def live_migration(self, ctxt, block_migration, disk_over_commit, - instance, dest, topic): + instance, dest): # NOTE(comstud): Call vs cast so we can get exceptions back, otherwise # this call in the scheduler driver doesn't return anything. instance_p = jsonutils.to_primitive(instance) return self.call(ctxt, self.make_msg('live_migration', block_migration=block_migration, disk_over_commit=disk_over_commit, instance=instance_p, - dest=dest, topic=topic), version='1.3') + dest=dest), version='1.7') + + 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') def update_service_capabilities(self, ctxt, service_name, host, capabilities): diff --git a/nova/scheduler/simple.py b/nova/scheduler/simple.py index f8a1e415..273bb2cf 100644 --- a/nova/scheduler/simple.py +++ b/nova/scheduler/simple.py @@ -54,7 +54,8 @@ class SimpleScheduler(chance.ChanceScheduler): super(SimpleScheduler, self).schedule_run_instance(context, request_spec, reservations, *_args, **_kwargs) - def schedule_create_volume(self, context, volume_id, *_args, **_kwargs): + def schedule_create_volume(self, context, volume_id, snapshot_id, + reservations): """Picks a host that is up and has the fewest volumes.""" deprecated.warn(_('nova-volume functionality is deprecated in Folsom ' 'and will be removed in Grizzly. Volumes are now handled ' @@ -72,7 +73,8 @@ class SimpleScheduler(chance.ChanceScheduler): if not utils.service_is_up(service): raise exception.WillNotSchedule(host=host) driver.cast_to_volume_host(context, host, 'create_volume', - volume_id=volume_id, **_kwargs) + volume_id=volume_id, snapshot_id=snapshot_id, + reservations=reservations) return None results = db.service_get_all_volume_sorted(elevated) @@ -86,7 +88,8 @@ class SimpleScheduler(chance.ChanceScheduler): raise exception.NoValidHost(reason=msg) if utils.service_is_up(service) and not service['disabled']: driver.cast_to_volume_host(context, service['host'], - 'create_volume', volume_id=volume_id, **_kwargs) + 'create_volume', volume_id=volume_id, + snapshot_id=snapshot_id, reservations=reservations) return None msg = _("Is the appropriate service running?") raise exception.NoValidHost(reason=msg) diff --git a/nova/tests/scheduler/test_multi_scheduler.py b/nova/tests/scheduler/test_multi_scheduler.py index fd79fffb..6fce5bc3 100644 --- a/nova/tests/scheduler/test_multi_scheduler.py +++ b/nova/tests/scheduler/test_multi_scheduler.py @@ -46,9 +46,6 @@ class FakeVolumeScheduler(driver.Scheduler): super(FakeVolumeScheduler, self).__init__() self.is_update_caps_called = False - def schedule_create_volume(self, *args, **kwargs): - pass - def schedule_create_volumes(self, *args, **kwargs): pass @@ -97,7 +94,7 @@ class MultiDriverTestCase(test_scheduler.SchedulerTestCase): #no compute methods are proxied at this time test_methods = {compute_driver: [], - volume_driver: ['create_volume', 'create_volumes']} + volume_driver: ['create_volumes']} for driver, methods in test_methods.iteritems(): for method in methods: diff --git a/nova/tests/scheduler/test_rpcapi.py b/nova/tests/scheduler/test_rpcapi.py index a2fee64b..95133622 100644 --- a/nova/tests/scheduler/test_rpcapi.py +++ b/nova/tests/scheduler/test_rpcapi.py @@ -86,10 +86,16 @@ 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', topic='fake_topic', - version='1.3') + instance='fake_instance', dest='fake_dest', + version='1.7') def test_update_service_capabilities(self): self._test_scheduler_api('update_service_capabilities', rpc_method='fanout_cast', service_name='fake_name', host='fake_host', capabilities='fake_capabilities') + + 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')