]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Use openstack.common.cfg.CONF.
authorRussell Bryant <rbryant@redhat.com>
Fri, 1 Jun 2012 18:42:32 +0000 (14:42 -0400)
committerMark McLoughlin <markmc@redhat.com>
Thu, 19 Jul 2012 16:20:18 +0000 (17:20 +0100)
Part of blueprint common-rpc.

This patch makes the rpc code use the global config object from
openstack-common.  Based on some recent discussions on the mailing list,
this may not be the final way configuration handling is done here, but
it is certainly better than the register_opts() hack that is removed by
this patch.

Change-Id: Id128126e0bc064a2a1c710c6bd32fb3d137dc7f6

bin/cinder-manage
bin/clear_rabbit_queues
cinder/rpc/__init__.py
cinder/rpc/impl_fake.py
cinder/rpc/impl_kombu.py
cinder/rpc/impl_qpid.py
cinder/service.py
cinder/tests/__init__.py
cinder/tests/rpc/test_kombu.py
cinder/tests/rpc/test_kombu_ssl.py
cinder/tests/rpc/test_qpid.py

index 1fc33dc80cb7ef8f539b4d7d72d0ad394d72d651..93f3f862a02efdb0abcb45edbdf422764a6d67cf 100755 (executable)
@@ -528,7 +528,6 @@ def methods_of(obj):
 
 def main():
     """Parse options and call the appropriate class/method."""
-    rpc.register_opts(FLAGS)
 
     try:
         argv = flags.parse_args(sys.argv)
index 1baa31c6f2b2d4d776e2d582d86535495071119b..d1b0b4a015069f4c839c2597eb92acff82415f9d 100755 (executable)
@@ -72,7 +72,6 @@ def delete_queues(queues):
 if __name__ == '__main__':
     args = flags.parse_args(sys.argv)
     logging.setup()
-    rpc.register_opts(flags.FLAGS)
     delete_queues(args[1:])
     if FLAGS.delete_exchange:
         delete_exchange(FLAGS.control_exchange)
index 266e89b4fbc3ef99b8c8cec9061c4c1e0ebfb555..07e4364b054425d3bce4223424b3e783b756032b 100644 (file)
@@ -54,14 +54,7 @@ rpc_opts = [
                 help='If passed, use a fake RabbitMQ provider'),
     ]
 
-_CONF = None
-
-
-def register_opts(conf):
-    global _CONF
-    _CONF = conf
-    _CONF.register_opts(rpc_opts)
-    _get_impl().register_opts(_CONF)
+cfg.CONF.register_opts(rpc_opts)
 
 
 def create_connection(new=True):
@@ -77,7 +70,7 @@ def create_connection(new=True):
 
     :returns: An instance of cinder.rpc.common.Connection
     """
-    return _get_impl().create_connection(_CONF, new=new)
+    return _get_impl().create_connection(cfg.CONF, new=new)
 
 
 def call(context, topic, msg, timeout=None):
@@ -100,7 +93,7 @@ def call(context, topic, msg, timeout=None):
     :raises: cinder.rpc.common.Timeout if a complete response is not received
              before the timeout is reached.
     """
-    return _get_impl().call(_CONF, context, topic, msg, timeout)
+    return _get_impl().call(cfg.CONF, context, topic, msg, timeout)
 
 
 def cast(context, topic, msg):
@@ -118,7 +111,7 @@ def cast(context, topic, msg):
 
     :returns: None
     """
-    return _get_impl().cast(_CONF, context, topic, msg)
+    return _get_impl().cast(cfg.CONF, context, topic, msg)
 
 
 def fanout_cast(context, topic, msg):
@@ -139,7 +132,7 @@ def fanout_cast(context, topic, msg):
 
     :returns: None
     """
-    return _get_impl().fanout_cast(_CONF, context, topic, msg)
+    return _get_impl().fanout_cast(cfg.CONF, context, topic, msg)
 
 
 def multicall(context, topic, msg, timeout=None):
@@ -169,7 +162,7 @@ def multicall(context, topic, msg, timeout=None):
     :raises: cinder.rpc.common.Timeout if a complete response is not received
              before the timeout is reached.
     """
-    return _get_impl().multicall(_CONF, context, topic, msg, timeout)
+    return _get_impl().multicall(cfg.CONF, context, topic, msg, timeout)
 
 
 def notify(context, topic, msg):
@@ -182,7 +175,7 @@ def notify(context, topic, msg):
 
     :returns: None
     """
-    return _get_impl().notify(_CONF, context, topic, msg)
+    return _get_impl().notify(cfg.CONF, context, topic, msg)
 
 
 def cleanup():
@@ -210,7 +203,7 @@ def cast_to_server(context, server_params, topic, msg):
 
     :returns: None
     """
-    return _get_impl().cast_to_server(_CONF, context, server_params, topic,
+    return _get_impl().cast_to_server(cfg.CONF, context, server_params, topic,
                                       msg)
 
 
@@ -226,7 +219,7 @@ def fanout_cast_to_server(context, server_params, topic, msg):
 
     :returns: None
     """
-    return _get_impl().fanout_cast_to_server(_CONF, context, server_params,
+    return _get_impl().fanout_cast_to_server(cfg.CONF, context, server_params,
                                              topic, msg)
 
 
@@ -242,5 +235,5 @@ def _get_impl():
     """Delay import of rpc_backend until configuration is loaded."""
     global _RPCIMPL
     if _RPCIMPL is None:
-        _RPCIMPL = importutils.import_module(_CONF.rpc_backend)
+        _RPCIMPL = importutils.import_module(cfg.CONF.rpc_backend)
     return _RPCIMPL
index a1ca192b09d168df8818f291f66c8d46c3c303ad..d8de6f7494ecc62ded133a1bcce4a91b944f1e85 100644 (file)
@@ -177,7 +177,3 @@ def fanout_cast(conf, context, topic, msg):
             consumer.call(context, method, args, None)
         except Exception:
             pass
-
-
-def register_opts(conf):
-    pass
index ca24cde50464e6be315dc47c224a0f2f4a05c010..71dfc12f40e9d1b2d49752370e5c88b981e0088c 100644 (file)
@@ -81,6 +81,8 @@ kombu_opts = [
 
     ]
 
+cfg.CONF.register_opts(kombu_opts)
+
 LOG = rpc_common.LOG
 
 
@@ -740,7 +742,3 @@ def notify(conf, context, topic, msg):
 
 def cleanup():
     return rpc_amqp.cleanup(Connection.pool)
-
-
-def register_opts(conf):
-    conf.register_opts(kombu_opts)
index e4db9d99ed694d1847ca56039b192de3ad461c19..878ab9dd3cf9f38668abfb409ef6073b2b191df5 100644 (file)
@@ -77,6 +77,8 @@ qpid_opts = [
                 help='Disable Nagle algorithm'),
     ]
 
+cfg.CONF.register_opts(qpid_opts)
+
 
 class ConsumerBase(object):
     """Consumer base class."""
@@ -562,7 +564,3 @@ def notify(conf, context, topic, msg):
 
 def cleanup():
     return rpc_amqp.cleanup(Connection.pool)
-
-
-def register_opts(conf):
-    conf.register_opts(qpid_opts)
index 4f6cd54b3292ed6da2a294d136b03b28016e2705..ded8bdc2cd691932bda26d0de6f77f2d4aa454e3 100644 (file)
@@ -156,7 +156,6 @@ class Service(object):
         vcs_string = version.version_string_with_vcs()
         LOG.audit(_('Starting %(topic)s node (version %(vcs_string)s)'),
                   {'topic': self.topic, 'vcs_string': vcs_string})
-        rpc.register_opts(FLAGS)
         self.manager.init_host()
         self.model_disconnected = False
         ctxt = context.get_admin_context()
@@ -375,7 +374,6 @@ class WSGIService(object):
         :returns: None
 
         """
-        rpc.register_opts(FLAGS)
         if self.manager:
             self.manager.init_host()
         self.server.start()
index 3b5e43e05640197f8be842ccb4f1b22a38fa5629..3b95e052e48cc5725dd70f6d9da4c5e5dd800101 100644 (file)
@@ -59,9 +59,6 @@ def reset_db():
 def setup():
     import mox  # Fail fast if you don't have mox. Workaround for bug 810424
 
-    from cinder import rpc  # Register rpc_backend before fake_flags sets it
-    FLAGS.register_opts(rpc.rpc_opts)
-
     from cinder.db import migration
     from cinder.tests import fake_flags
     fake_flags.set_defaults(FLAGS)
index b9c5ea354f4f2fbf0a01352a191503763feb0c76..2001be01ecf201e0408d1893c2e92655e1a73c28 100644 (file)
@@ -61,7 +61,6 @@ class RpcKombuTestCase(common.BaseRpcAMQPTestCase):
     def setUp(self):
         if kombu:
             self.rpc = impl_kombu
-            impl_kombu.register_opts(FLAGS)
         else:
             self.rpc = None
         super(RpcKombuTestCase, self).setUp()
index cc4ff03c14ba1d05f5a8b52f857e73ca9d7c9fa6..8f7329ae74ddd07ad1be568ce063c94bc66f70b5 100644 (file)
@@ -44,7 +44,6 @@ class RpcKombuSslTestCase(test.TestCase):
     def setUp(self):
         super(RpcKombuSslTestCase, self).setUp()
         if kombu:
-            impl_kombu.register_opts(FLAGS)
             self.flags(kombu_ssl_keyfile=SSL_KEYFILE,
                        kombu_ssl_ca_certs=SSL_CA_CERT,
                        kombu_ssl_certfile=SSL_CERT,
index 9b33b578c3fed680a030105dfc62e0e010057928..4f28a76a3b46a36e46a23ae1f180e3ca64cfde91 100644 (file)
@@ -66,7 +66,6 @@ class RpcQpidTestCase(test.TestCase):
         self.mock_receiver = None
 
         if qpid:
-            impl_qpid.register_opts(FLAGS)
             self.orig_connection = qpid.messaging.Connection
             self.orig_session = qpid.messaging.Session
             self.orig_sender = qpid.messaging.Sender