]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove paste configuration details to a seperate file.
authorGary Kotton <gkotton@redhat.com>
Thu, 21 Jun 2012 13:06:44 +0000 (09:06 -0400)
committerGary Kotton <gkotton@redhat.com>
Sun, 24 Jun 2012 05:45:27 +0000 (01:45 -0400)
blueprint use-common-cfg

In addition this ensures that the cisco extension units are working
with the common cfg code.

Change-Id: I8c1f81e295e7ed593f0b58885efeeb15339b7733

etc/api-paste.ini [new file with mode: 0644]
etc/quantum.conf
quantum/common/config.py
quantum/plugins/cisco/tests/unit/api-paste.ini.cisco.test [new file with mode: 0644]
quantum/plugins/cisco/tests/unit/quantum.conf.cisco.test [moved from etc/quantum/plugins/cisco/quantum.conf.ciscoext with 52% similarity]
quantum/plugins/cisco/tests/unit/test_cisco_extension.py
quantum/service.py
quantum/tests/etc/api-paste.ini.test [new file with mode: 0644]
quantum/tests/etc/quantum.conf.test
quantum/tests/unit/test_extensions.py
setup.py

diff --git a/etc/api-paste.ini b/etc/api-paste.ini
new file mode 100644 (file)
index 0000000..8c0ccdf
--- /dev/null
@@ -0,0 +1,54 @@
+[composite:quantum]
+use = egg:Paste#urlmap
+/: quantumversions
+/v1.0: quantumapi_v1_0
+/v1.1: quantumapi_v1_1
+/v2.0: quantumapi_v2_0
+
+[pipeline:quantumapi_v1_0]
+# By default, authentication is disabled.
+# To enable Keystone integration comment out the
+# following line and uncomment the next one
+pipeline = extensions quantumapiapp_v1_0
+# pipeline = authtoken keystonecontext extensions quantumapiapp_v1_0
+
+[pipeline:quantumapi_v1_1]
+# By default, authentication is disabled.
+# To enable Keystone integration comment out the
+# following line and uncomment the next one
+pipeline = extensions quantumapiapp_v1_1
+# pipeline = authtoken keystonecontext extensions quantumapiapp_v1_1
+
+[pipeline:quantumapi_v2_0]
+# By default, authentication is disabled.
+# To enable Keystone integration comment out the
+# following line and uncomment the next one
+pipeline = extensions quantumapiapp_v2_0
+# pipeline = authtoken keystonecontext extensions quantumapiapp_v2_0
+
+[filter:keystonecontext]
+paste.filter_factory = quantum.auth:QuantumKeystoneContext.factory
+
+[filter:authtoken]
+paste.filter_factory = keystone.middleware.auth_token:filter_factory
+auth_host = 127.0.0.1
+auth_port = 35357
+auth_protocol = http
+admin_tenant_name = %SERVICE_TENANT_NAME%
+admin_user = %SERVICE_USER%
+admin_password = %SERVICE_PASSWORD%
+
+[filter:extensions]
+paste.filter_factory = quantum.extensions.extensions:plugin_aware_extension_middleware_factory
+
+[app:quantumversions]
+paste.app_factory = quantum.api.versions:Versions.factory
+
+[app:quantumapiapp_v1_0]
+paste.app_factory = quantum.api:APIRouterV10.factory
+
+[app:quantumapiapp_v1_1]
+paste.app_factory = quantum.api:APIRouterV11.factory
+
+[app:quantumapiapp_v2_0]
+paste.app_factory = quantum.api.v2.router:APIRouter.factory
index b96d0ef7215a65b40c433fb4a12f0b8bb89df2b8..e55bca08cf4390e5d49aa2475c40dc1998caf886 100644 (file)
@@ -21,57 +21,5 @@ api_extensions_path =
 # Quantum plugin provider module
 core_plugin = quantum.plugins.sample.SamplePlugin.FakePlugin
 
-[composite:quantum]
-use = egg:Paste#urlmap
-/: quantumversions
-/v1.0: quantumapi_v1_0
-/v1.1: quantumapi_v1_1
-/v2.0: quantumapi_v2_0
-
-[pipeline:quantumapi_v1_0]
-# By default, authentication is disabled.
-# To enable Keystone integration comment out the
-# following line and uncomment the next one
-pipeline = extensions quantumapiapp_v1_0
-# pipeline = authtoken keystonecontext extensions quantumapiapp_v1_0
-
-[pipeline:quantumapi_v1_1]
-# By default, authentication is disabled.
-# To enable Keystone integration comment out the
-# following line and uncomment the next one
-pipeline = extensions quantumapiapp_v1_1
-# pipeline = authtoken keystonecontext extensions quantumapiapp_v1_1
-
-[pipeline:quantumapi_v2_0]
-# By default, authentication is disabled.
-# To enable Keystone integration comment out the
-# following line and uncomment the next one
-pipeline = extensions quantumapiapp_v2_0
-# pipeline = authtoken keystonecontext extensions quantumapiapp_v2_0
-
-[filter:keystonecontext]
-paste.filter_factory = quantum.auth:QuantumKeystoneContext.factory
-
-[filter:authtoken]
-paste.filter_factory = keystone.middleware.auth_token:filter_factory
-auth_host = 127.0.0.1
-auth_port = 35357
-auth_protocol = http
-admin_tenant_name = %SERVICE_TENANT_NAME%
-admin_user = %SERVICE_USER%
-admin_password = %SERVICE_PASSWORD%
-
-[filter:extensions]
-paste.filter_factory = quantum.extensions.extensions:plugin_aware_extension_middleware_factory
-
-[app:quantumversions]
-paste.app_factory = quantum.api.versions:Versions.factory
-
-[app:quantumapiapp_v1_0]
-paste.app_factory = quantum.api:APIRouterV10.factory
-
-[app:quantumapiapp_v1_1]
-paste.app_factory = quantum.api:APIRouterV11.factory
-
-[app:quantumapiapp_v2_0]
-paste.app_factory = quantum.api.v2.router:APIRouter.factory
+# Paste configuration file
+api_paste_config = api-paste.ini
index 1e608c013e42379fe302017048687ec54fb23113..505bf233bdbb446224cd2cd06be1fff2e5f47b53 100644 (file)
@@ -35,6 +35,7 @@ LOG = logging.getLogger(__name__)
 bind_opts = [
     cfg.StrOpt('bind_host', default='0.0.0.0'),
     cfg.IntOpt('bind_port', default=9696),
+    cfg.StrOpt('api_paste_config', default="api-paste.ini"),
     cfg.StrOpt('api_extensions_path', default=""),
     cfg.StrOpt('core_plugin',
                default='quantum.plugins.sample.SamplePlugin.FakePlugin'),
@@ -96,17 +97,17 @@ def setup_logging(conf):
     root_logger.addHandler(handler)
 
 
-def load_paste_app(app_name, config_file):
+def load_paste_app(app_name):
     """
     Builds and returns a WSGI app from a paste config file.
 
     :param app_name: Name of the application to load
-    :param config_file: name of the configuration file
     :raises RuntimeError when config file cannot be located or application
             cannot be loaded from config file
     """
 
-    config_path = os.path.abspath(cfg.CONF.find_file(config_file))
+    config_path = os.path.abspath(cfg.CONF.find_file(
+        cfg.CONF.api_paste_config))
     LOG.info("Config paste file: %s", config_path)
 
     try:
diff --git a/quantum/plugins/cisco/tests/unit/api-paste.ini.cisco.test b/quantum/plugins/cisco/tests/unit/api-paste.ini.cisco.test
new file mode 100644 (file)
index 0000000..9163752
--- /dev/null
@@ -0,0 +1,8 @@
+[pipeline:extensions_app_with_filter]
+pipeline = extensions extensions_test_app
+
+[filter:extensions]
+paste.filter_factory = quantum.extensions.extensions:plugin_aware_extension_middleware_factory
+
+[app:extensions_test_app]
+paste.app_factory = quantum.plugins.cisco.tests.unit.test_cisco_extension:app_factory
similarity index 52%
rename from etc/quantum/plugins/cisco/quantum.conf.ciscoext
rename to quantum/plugins/cisco/tests/unit/quantum.conf.cisco.test
index b63faed913b020c526523f4aa958082cae5d2f53..f7ca99b9c12e16a7592996a043d03c2472884176 100644 (file)
@@ -14,11 +14,7 @@ bind_port = 9696
 # Path to the extensions
 api_extensions_path = ../../../../extensions
 
-[pipeline:extensions_app_with_filter]
-pipeline = extensions extensions_test_app
+# Paste configuration file
+api_paste_config = api-paste.ini.cisco.test
 
-[filter:extensions]
-paste.filter_factory = quantum.extensions.extensions:plugin_aware_extension_middleware_factory
-
-[app:extensions_test_app]
-paste.app_factory = quantum.plugins.cisco.tests.unit.test_cisco_extension:app_factory
+core_plugin = quantum.plugins.cisco.l2network_plugin.L2Network
index 94c2c7788ad5e00b13aa7f92007be8810a6d102c..4e272f9f87853142afa004d9f70a6019d94e2957 100644 (file)
@@ -52,11 +52,20 @@ from quantum import wsgi
 LOG = logging.getLogger('quantum.plugins.cisco.tests.test_cisco_extensions')
 
 
-TEST_CONF_FILE = config.find_config_file({'plugin': 'cisco'},
-                                         'quantum.conf.ciscoext')
 EXTENSIONS_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
                                os.pardir, os.pardir, "extensions")
 
+ROOTDIR = os.path.dirname(os.path.dirname(__file__))
+UNITDIR = os.path.join(ROOTDIR, 'unit')
+
+
+def testsdir(*p):
+    return os.path.join(UNITDIR, *p)
+
+config_file = 'quantum.conf.cisco.test'
+args = ['--config-file', testsdir(config_file)]
+config.parse(args=args)
+
 
 class ExtensionsTestApp(wsgi.Router):
 
@@ -97,10 +106,7 @@ class PortprofileExtensionTest(unittest.TestCase):
         }
         self.tenant_id = "test_tenant"
         self.network_name = "test_network"
-        options = {}
-        options['plugin_provider'] = ('quantum.plugins.cisco.l2network_plugin'
-                                      '.L2Network')
-        self.api = server.APIRouterV10(options)
+        self.api = server.APIRouterV10()
         self._l2network_plugin = l2network_plugin.L2Network()
 
     def test_list_portprofile(self):
@@ -1147,10 +1153,7 @@ class MultiPortExtensionTest(unittest.TestCase):
         }
         self.tenant_id = "test_tenant"
         self.network_name = "test_network"
-        options = {}
-        options['plugin_provider'] = (
-            'quantum.plugins.cisco.l2network_plugin.L2Network')
-        self.api = server.APIRouterV10(options)
+        self.api = server.APIRouterV10()
         self._l2network_plugin = l2network_plugin.L2Network()
 
     def create_request(self, path, body, content_type, method='GET'):
@@ -1255,8 +1258,7 @@ def setup_extensions_middleware(extension_manager=None):
     extension_manager = (extension_manager or
                          PluginAwareExtensionManager(EXTENSIONS_PATH,
                                                      L2Network()))
-    options = {'config_file': TEST_CONF_FILE}
-    app = config.load_paste_app('extensions_test_app', options, None)
+    app = config.load_paste_app('extensions_test_app')
     return ExtensionMiddleware(app, ext_mgr=extension_manager)
 
 
index d6432ac15fafd21d7d06348378a9074f015f40c6..48ef432e2ae732b5fea5389b6ee75bad647545e8 100644 (file)
@@ -86,7 +86,7 @@ def serve_wsgi(cls):
 
 
 def _run_wsgi(app_name):
-    app = config.load_paste_app(app_name, "quantum.conf")
+    app = config.load_paste_app(app_name)
     if not app:
         LOG.error(_('No known API applications configured.'))
         return
diff --git a/quantum/tests/etc/api-paste.ini.test b/quantum/tests/etc/api-paste.ini.test
new file mode 100644 (file)
index 0000000..5a17e83
--- /dev/null
@@ -0,0 +1,8 @@
+[pipeline:extensions_app_with_filter]
+pipeline = extensions extensions_test_app
+
+[filter:extensions]
+paste.filter_factory = quantum.common.extensions:plugin_aware_extension_middleware_factory
+
+[app:extensions_test_app]
+paste.app_factory = quantum.tests.unit.test_extensions:app_factory
index 6157d5b0284e9c88396e7a63e3b215590651d621..0dbb4a2a2739cfba58bbff2d2df403a300372189 100644 (file)
@@ -14,11 +14,5 @@ bind_port = 9696
 # Path to the extensions
 api_extensions_path = unit/extensions
 
-[pipeline:extensions_app_with_filter]
-pipeline = extensions extensions_test_app
-
-[filter:extensions]
-paste.filter_factory = quantum.common.extensions:plugin_aware_extension_middleware_factory
-
-[app:extensions_test_app]
-paste.app_factory = quantum.tests.unit.test_extensions:app_factory
+# Paste configuration file
+api_paste_config = api-paste.ini.test
index 9c64d36cd73b5d2dc7bc79f5db50e4b476d1a53c..a2719025b01c913e1e0d47b8ff3e343839c5df39 100644 (file)
@@ -467,7 +467,7 @@ def setup_base_app():
     config_file = 'quantum.conf.test'
     args = ['--config-file', etcdir(config_file)]
     config.parse(args=args)
-    app = config.load_paste_app('extensions_test_app', config_file)
+    app = config.load_paste_app('extensions_test_app')
     return app
 
 
@@ -478,7 +478,7 @@ def setup_extensions_middleware(extension_manager=None):
     config_file = 'quantum.conf.test'
     args = ['--config-file', etcdir(config_file)]
     config.parse(args=args)
-    app = config.load_paste_app('extensions_test_app', config_file)
+    app = config.load_paste_app('extensions_test_app')
     return ExtensionMiddleware(app, ext_mgr=extension_manager)
 
 
index 4d2854279419029ffa8ced758c2b7a6b764760d1..e046a1ae817b0105a524786b3ea500a1f80863ef 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -51,7 +51,7 @@ ryu_plugin_config_path = 'etc/quantum/plugins/ryu'
 
 DataFiles = [
     (config_path,
-        ['etc/quantum.conf']),
+        ['etc/quantum.conf', 'etc/api-paste.ini', 'etc/policy.json']),
     (init_path, ['etc/init.d/quantum-server']),
     (ovs_plugin_config_path,
         ['etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini']),