From 2263cf7db7672699e29a76d68dbe91cad2071b86 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 30 May 2012 15:24:41 -0700 Subject: [PATCH] Fix topics so that the do not collide with nova. * Without this, there are issues running cinder if you have previously run n-vol * Fix pep8 Change-Id: Id56dbfd6c4f62a74cc57edcc7859753dd7e36229 --- cinder/db/sqlalchemy/api.py | 2 +- cinder/flags.py | 4 ++-- cinder/scheduler/driver.py | 4 ++-- cinder/service.py | 5 +++-- cinder/tests/scheduler/test_scheduler.py | 9 ++++++--- cinder/volume/manager.py | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index 435ace854..05dd90fcf 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -297,7 +297,7 @@ def _service_get_all_topic_subquery(context, session, topic, subq, label): def service_get_all_volume_sorted(context): session = get_session() with session.begin(): - topic = 'volume' + topic = FLAGS.volume_topic label = 'volume_gigabytes' subq = model_query(context, models.Volume.host, func.sum(models.Volume.size).label(label), diff --git a/cinder/flags.py b/cinder/flags.py index 3f1d9f5d8..60e86999b 100644 --- a/cinder/flags.py +++ b/cinder/flags.py @@ -155,10 +155,10 @@ global_opts = [ help='A list of the glance api servers available to cinder ' '([hostname|ip]:port)'), cfg.StrOpt('scheduler_topic', - default='scheduler', + default='cinder-scheduler', help='the topic scheduler nodes listen on'), cfg.StrOpt('volume_topic', - default='volume', + default='cinder-volume', help='the topic volume nodes listen on'), cfg.StrOpt('rabbit_host', default='localhost', diff --git a/cinder/scheduler/driver.py b/cinder/scheduler/driver.py index d84893ee6..1696cbd28 100644 --- a/cinder/scheduler/driver.py +++ b/cinder/scheduler/driver.py @@ -53,9 +53,9 @@ def cast_to_volume_host(context, host, method, update_db=True, **kwargs): db.volume_update(context, volume_id, {'host': host, 'scheduled_at': now}) rpc.cast(context, - db.queue_get_for(context, 'volume', host), + db.queue_get_for(context, FLAGS.volume_topic, host), {"method": method, "args": kwargs}) - LOG.debug(_("Casted '%(method)s' to volume '%(host)s'") % locals()) + LOG.debug(_("Casted '%(method)s' to host '%(host)s'") % locals()) def cast_to_host(context, topic, host, method, update_db=True, **kwargs): diff --git a/cinder/service.py b/cinder/service.py index 363b3d967..0db2bf598 100644 --- a/cinder/service.py +++ b/cinder/service.py @@ -238,9 +238,10 @@ class Service(object): if not binary: binary = os.path.basename(inspect.stack()[-1][1]) if not topic: - topic = binary.rpartition('cinder-')[2] + topic = binary if not manager: - manager = FLAGS.get('%s_manager' % topic, None) + subtopic = topic.rpartition('cinder-')[2] + manager = FLAGS.get('%s_manager' % subtopic, None) if report_interval is None: report_interval = FLAGS.report_interval if periodic_interval is None: diff --git a/cinder/tests/scheduler/test_scheduler.py b/cinder/tests/scheduler/test_scheduler.py index 346132a7d..cb1adce90 100644 --- a/cinder/tests/scheduler/test_scheduler.py +++ b/cinder/tests/scheduler/test_scheduler.py @@ -244,7 +244,8 @@ class SchedulerDriverModuleTestCase(test.TestCase): utils.utcnow().AndReturn('fake-now') db.volume_update(self.context, 31337, {'host': host, 'scheduled_at': 'fake-now'}) - db.queue_get_for(self.context, 'volume', host).AndReturn(queue) + db.queue_get_for(self.context, + FLAGS.volume_topic, host).AndReturn(queue) rpc.cast(self.context, queue, {'method': method, 'args': fake_kwargs}) @@ -262,7 +263,8 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.StubOutWithMock(db, 'queue_get_for') self.mox.StubOutWithMock(rpc, 'cast') - db.queue_get_for(self.context, 'volume', host).AndReturn(queue) + db.queue_get_for(self.context, + FLAGS.volume_topic, host).AndReturn(queue) rpc.cast(self.context, queue, {'method': method, 'args': fake_kwargs}) @@ -280,7 +282,8 @@ class SchedulerDriverModuleTestCase(test.TestCase): self.mox.StubOutWithMock(db, 'queue_get_for') self.mox.StubOutWithMock(rpc, 'cast') - db.queue_get_for(self.context, 'volume', host).AndReturn(queue) + db.queue_get_for(self.context, + FLAGS.volume_topic, host).AndReturn(queue) rpc.cast(self.context, queue, {'method': method, 'args': fake_kwargs}) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 8266a6470..b53eb5b14 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -25,7 +25,7 @@ intact. **Related Flags** -:volume_topic: What :mod:`rpc` topic to listen to (default: `volume`). +:volume_topic: What :mod:`rpc` topic to listen to (default: `cinder-volume`). :volume_manager: The module name of a class derived from :class:`manager.Manager` (default: :class:`cinder.volume.manager.Manager`). -- 2.45.2