From 77f212bc3fb8f927c6c2c2c21c1b62d39c1c51ec Mon Sep 17 00:00:00 2001 From: Zhiteng Huang Date: Mon, 26 Nov 2012 16:13:22 +0800 Subject: Clean up unused methods in scheduler/driver The cast_to_volume_host() and cast_to_host() methods have not been used since compute RPC API is introduced. This patch removes these methods and the coresponding tests as well. Change-Id: Icd2b4b2245cc7662c8dcb6fd35d6c33b77d0429b --- nova/scheduler/driver.py | 29 ------------- nova/tests/scheduler/test_scheduler.py | 74 ---------------------------------- 2 files changed, 103 deletions(-) (limited to 'nova') diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index c5523f229..99636379e 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -96,35 +96,6 @@ def instance_update_db(context, instance_uuid): return db.instance_update(context, instance_uuid, values) -def cast_to_compute_host(context, host, method, **kwargs): - """Cast request to a compute host queue""" - - instance_uuid = kwargs.get('instance_uuid', None) - if instance_uuid: - instance_update_db(context, instance_uuid) - - rpc.cast(context, - rpc.queue_get_for(context, CONF.compute_topic, host), - {"method": method, "args": kwargs}) - LOG.debug(_("Casted '%(method)s' to compute '%(host)s'") % locals()) - - -def cast_to_host(context, topic, host, method, **kwargs): - """Generic cast to host""" - - topic_mapping = {CONF.compute_topic: cast_to_compute_host} - - func = topic_mapping.get(topic) - if func: - cast_to_compute_host(context, host, method, **kwargs) - else: - rpc.cast(context, - rpc.queue_get_for(context, topic, host), - {"method": method, "args": kwargs}) - LOG.debug(_("Casted '%(method)s' to %(topic)s '%(host)s'") - % locals()) - - def encode_instance(instance, local=True): """Encode locally created instance for return via RPC""" # TODO(comstud): I would love to be able to return the full diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 475807b3b..105240775 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -639,80 +639,6 @@ class SchedulerDriverModuleTestCase(test.TestCase): super(SchedulerDriverModuleTestCase, self).setUp() self.context = context.RequestContext('fake_user', 'fake_project') - def test_cast_to_compute_host_update_db_with_instance_uuid(self): - host = 'fake_host1' - method = 'fake_method' - fake_kwargs = {'instance_uuid': 'fake_uuid', - 'extra_arg': 'meow'} - queue = 'fake_queue' - - self.mox.StubOutWithMock(timeutils, 'utcnow') - self.mox.StubOutWithMock(db, 'instance_update') - self.mox.StubOutWithMock(rpc, 'queue_get_for') - self.mox.StubOutWithMock(rpc, 'cast') - - timeutils.utcnow().AndReturn('fake-now') - db.instance_update(self.context, 'fake_uuid', - {'host': None, 'node': None, 'scheduled_at': 'fake-now'}) - rpc.queue_get_for(self.context, 'compute', host).AndReturn(queue) - rpc.cast(self.context, queue, - {'method': method, - 'args': fake_kwargs}) - - self.mox.ReplayAll() - driver.cast_to_compute_host(self.context, host, method, - **fake_kwargs) - - def test_cast_to_compute_host_update_db_without_instance_uuid(self): - host = 'fake_host1' - method = 'fake_method' - fake_kwargs = {'extra_arg': 'meow'} - queue = 'fake_queue' - - self.mox.StubOutWithMock(rpc, 'queue_get_for') - self.mox.StubOutWithMock(rpc, 'cast') - - rpc.queue_get_for(self.context, 'compute', host).AndReturn(queue) - rpc.cast(self.context, queue, - {'method': method, - 'args': fake_kwargs}) - - self.mox.ReplayAll() - driver.cast_to_compute_host(self.context, host, method, - **fake_kwargs) - - def test_cast_to_host_compute_topic(self): - host = 'fake_host1' - method = 'fake_method' - fake_kwargs = {'extra_arg': 'meow'} - - self.mox.StubOutWithMock(driver, 'cast_to_compute_host') - driver.cast_to_compute_host(self.context, host, method, - **fake_kwargs) - - self.mox.ReplayAll() - driver.cast_to_host(self.context, 'compute', host, method, - **fake_kwargs) - - def test_cast_to_host_unknown_topic(self): - host = 'fake_host1' - method = 'fake_method' - fake_kwargs = {'extra_arg': 'meow'} - topic = 'unknown' - queue = 'fake_queue' - - self.mox.StubOutWithMock(rpc, 'queue_get_for') - self.mox.StubOutWithMock(rpc, 'cast') - - rpc.queue_get_for(self.context, topic, host).AndReturn(queue) - rpc.cast(self.context, queue, - {'method': method, - 'args': fake_kwargs}) - - self.mox.ReplayAll() - driver.cast_to_host(self.context, topic, host, method, - **fake_kwargs) - def test_encode_instance(self): instance = {'id': 31337, 'test_arg': 'meow'} -- cgit