diff --git a/etc/manila/api-paste.ini b/etc/manila/api-paste.ini index 3ddbf21a67..4e0f32eb0b 100644 --- a/etc/manila/api-paste.ini +++ b/etc/manila/api-paste.ini @@ -57,6 +57,3 @@ paste.filter_factory = keystonemiddleware.auth_token:filter_factory [filter:cors] paste.filter_factory = oslo_middleware.cors:filter_factory oslo_config_project = manila -latent_allow_headers = X-Auth-Token, X-OpenStack-Request-ID, X-Openstack-Manila-Api-Version, X-OpenStack-Manila-API-Experimental, X-Identity-Status, X-Roles, X-Service-Catalog, X-User-Id, X-Tenant-Id -latent_expose_headers = X-Auth-Token, X-OpenStack-Request-ID, X-Openstack-Manila-Api-Version, X-OpenStack-Manila-API-Experimental, X-Subject-Token, X-Service-Token -latent_allow_methods = GET, PUT, POST, DELETE, PATCH diff --git a/manila/cmd/all.py b/manila/cmd/all.py index bcd427179b..1893874b64 100755 --- a/manila/cmd/all.py +++ b/manila/cmd/all.py @@ -37,7 +37,7 @@ from oslo_log import log from manila import i18n i18n.enable_lazy() -from manila.common import config # Need to register global_opts # noqa +from manila.common import config # Need to register global_opts from manila.i18n import _LE from manila import service from manila import utils @@ -48,6 +48,7 @@ CONF = cfg.CONF def main(): log.register_options(CONF) + config.set_middleware_defaults() CONF(sys.argv[1:], project='manila', version=version.version_string()) log.setup(CONF, "manila") diff --git a/manila/common/config.py b/manila/common/config.py index 988c438746..d478265b4c 100644 --- a/manila/common/config.py +++ b/manila/common/config.py @@ -28,6 +28,7 @@ import socket from oslo_config import cfg from oslo_log import log +from oslo_middleware import cors from oslo_utils import netutils import six @@ -188,3 +189,31 @@ def verify_share_protocols(): # because of 'lazy' translations. msg = six.text_type(_(msg) % data) # noqa H701 raise exception.ManilaException(message=msg) + + +def set_middleware_defaults(): + """Update default configuration options for oslo.middleware.""" + # CORS Defaults + # TODO(krotscheck): Update with https://review.openstack.org/#/c/285368/ + cfg.set_defaults(cors.CORS_OPTS, + allow_headers=['X-Auth-Token', + 'X-OpenStack-Request-ID', + 'X-Openstack-Manila-Api-Version', + 'X-OpenStack-Manila-API-Experimental', + 'X-Identity-Status', + 'X-Roles', + 'X-Service-Catalog', + 'X-User-Id', + 'X-Tenant-Id'], + expose_headers=['X-Auth-Token', + 'X-OpenStack-Request-ID', + 'X-Openstack-Manila-Api-Version', + 'X-OpenStack-Manila-API-Experimental', + 'X-Subject-Token', + 'X-Service-Token'], + allow_methods=['GET', + 'PUT', + 'POST', + 'DELETE', + 'PATCH'] + ) diff --git a/manila/wsgi.py b/manila/wsgi.py index 1db0271f5f..eceec30d14 100644 --- a/manila/wsgi.py +++ b/manila/wsgi.py @@ -38,6 +38,7 @@ import routes.middleware import webob.dec import webob.exc +from manila.common import config from manila import exception from manila.i18n import _ from manila.i18n import _LE @@ -198,6 +199,7 @@ class Server(service.ServiceBase): # give bad file descriptor error. So duplicating the socket object, # to keep file descriptor usable. + config.set_middleware_defaults() dup_socket = self._socket.dup() if self._use_ssl: try: diff --git a/setup.cfg b/setup.cfg index 0bd48cc41f..41c56cda5e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -54,6 +54,8 @@ oslo_messaging.notify.drivers = manila.openstack.common.notifier.test_notifier = oslo_messaging.notify._impl_test:TestDriver oslo.config.opts = manila = manila.opts:list_opts +oslo.config.opts.defaults = + oslo.middleware = manila.common.config:set_middleware_defaults manila.share.drivers.emc.plugins = vnx = manila.share.drivers.emc.plugins.vnx.connection:VNXStorageConnection isilon = manila.share.drivers.emc.plugins.isilon.isilon:IsilonStorageConnection