Add quantum.exceptions path to configed ext paths
Change-Id: Ica9e1de290d963ef8919e15a242655f933df5b03
This commit is contained in:
parent
87dbc61c34
commit
e85d007c07
|
@ -26,6 +26,7 @@ import webob.exc
|
|||
from gettext import gettext as _
|
||||
from abc import ABCMeta
|
||||
from quantum.common import exceptions
|
||||
import quantum.extensions
|
||||
from quantum.manager import QuantumManager
|
||||
from quantum import wsgi
|
||||
|
||||
|
@ -219,7 +220,7 @@ class ExtensionMiddleware(wsgi.Middleware):
|
|||
|
||||
self.ext_mgr = (ext_mgr
|
||||
or ExtensionManager(
|
||||
config_params.get('api_extensions_path', '')))
|
||||
get_extensions_path(config_params)))
|
||||
mapper = routes.Mapper()
|
||||
|
||||
# extended resources
|
||||
|
@ -336,7 +337,7 @@ class ExtensionMiddleware(wsgi.Middleware):
|
|||
def plugin_aware_extension_middleware_factory(global_config, **local_config):
|
||||
"""Paste factory."""
|
||||
def _factory(app):
|
||||
extensions_path = global_config.get('api_extensions_path', '')
|
||||
extensions_path = get_extensions_path(global_config)
|
||||
ext_mgr = PluginAwareExtensionManager(extensions_path,
|
||||
QuantumManager.get_plugin())
|
||||
return ExtensionMiddleware(app, global_config, ext_mgr=ext_mgr)
|
||||
|
@ -532,3 +533,13 @@ class ResourceExtension(object):
|
|||
self.parent = parent
|
||||
self.collection_actions = collection_actions
|
||||
self.member_actions = member_actions
|
||||
|
||||
|
||||
# Returns the extention paths from a config entry and the __path__
|
||||
# of quantum.extensions
|
||||
def get_extensions_path(config=None):
|
||||
paths = ':'.join(quantum.extensions.__path__)
|
||||
if config:
|
||||
paths = ':'.join([config.get('api_extensions_path', ''), paths])
|
||||
|
||||
return paths
|
||||
|
|
|
@ -14,7 +14,9 @@ bind_port = 9696
|
|||
# Path to the extensions. Note that this can be a colon-separated list of
|
||||
# paths. For example:
|
||||
# api_extensions_path = extensions:/path/to/more/extensions:/even/more/extensions
|
||||
api_extensions_path = extensions
|
||||
# The __path__ of quantum.extensions is appended to this, so if your
|
||||
# extensions are in there you don't need to specify them here
|
||||
api_extensions_path = server/lib/quantum/extensions
|
||||
|
||||
[composite:quantum]
|
||||
use = egg:Paste#urlmap
|
||||
|
|
|
@ -30,6 +30,7 @@ from quantum.tests.unit.extension_stubs import (StubExtension, StubPlugin,
|
|||
StubPluginInterface,
|
||||
StubBaseAppController,
|
||||
ExtensionExpectingPluginInterface)
|
||||
import quantum.tests.unit.extensions
|
||||
from quantum.common.extensions import (ExtensionManager,
|
||||
PluginAwareExtensionManager,
|
||||
ExtensionMiddleware)
|
||||
|
@ -37,7 +38,7 @@ from quantum.common.extensions import (ExtensionManager,
|
|||
LOG = logging.getLogger('test_extensions')
|
||||
|
||||
test_conf_file = config.find_config_file({}, None, "quantum.conf.test")
|
||||
extensions_path = os.path.join(os.path.dirname(__file__), "extensions")
|
||||
extensions_path = ':'.join(quantum.tests.unit.extensions.__path__)
|
||||
|
||||
|
||||
class ExtensionsTestApp(wsgi.Router):
|
||||
|
|
Loading…
Reference in New Issue