Remove paste configuration details to a seperate file.

blueprint use-common-cfg

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

Change-Id: I8c1f81e295e7ed593f0b58885efeeb15339b7733
This commit is contained in:
Gary Kotton 2012-06-21 09:06:44 -04:00
parent 43d2ed6342
commit 842584f3ef
11 changed files with 99 additions and 88 deletions

54
etc/api-paste.ini Normal file
View File

@ -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

View 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

View 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:

View File

@ -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

View 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

View 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)

View 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

View File

@ -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

View 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

View 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)

View File

@ -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']),