diff --git a/aodh/conf/__init__.py b/aodh/conf/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/aodh/conf/defaults.py b/aodh/conf/defaults.py new file mode 100644 index 000000000..33fa73dcb --- /dev/null +++ b/aodh/conf/defaults.py @@ -0,0 +1,35 @@ +# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_config import cfg +from oslo_middleware import cors + + +def set_cors_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-Subject-Token'], + expose_headers=['X-Auth-Token', + 'X-Openstack-Request-Id', + 'X-Subject-Token'], + allow_methods=['GET', + 'PUT', + 'POST', + 'DELETE', + 'PATCH'] + ) diff --git a/aodh/service.py b/aodh/service.py index 0d7d1279d..1e8c92df3 100644 --- a/aodh/service.py +++ b/aodh/service.py @@ -22,6 +22,7 @@ import oslo_i18n from oslo_log import log from oslo_policy import opts as policy_opts +from aodh.conf import defaults from aodh import keystone_client from aodh import messaging @@ -54,6 +55,7 @@ def prepare_service(argv=None, config_files=None): log_levels = (conf.default_log_levels + ['stevedore=INFO', 'keystoneclient=INFO']) log.set_defaults(default_log_levels=log_levels) + defaults.set_cors_middleware_defaults() db_options.set_defaults(conf) policy_opts.set_defaults(conf) from aodh import opts diff --git a/aodh/tests/functional/gabbi/gabbi_paste.ini b/aodh/tests/functional/gabbi/gabbi_paste.ini index c4034ee14..77ee25ae4 100644 --- a/aodh/tests/functional/gabbi/gabbi_paste.ini +++ b/aodh/tests/functional/gabbi/gabbi_paste.ini @@ -19,6 +19,3 @@ paste.filter_factory = oslo_middleware:RequestId.factory [filter:cors] paste.filter_factory = oslo_middleware.cors:filter_factory oslo_config_project = aodh -latent_allow_headers = X-Auth-Token, X-Openstack-Request-Id, X-Subject-Token -latent_expose_headers = X-Auth-Token, X-Openstack-Request-Id, X-Subject-Token -latent_allow_methods = GET, PUT, POST, DELETE, PATCH diff --git a/etc/aodh/api_paste.ini b/etc/aodh/api_paste.ini index fc58aa67f..fdfca9118 100644 --- a/etc/aodh/api_paste.ini +++ b/etc/aodh/api_paste.ini @@ -19,7 +19,4 @@ paste.filter_factory = oslo_middleware:RequestId.factory [filter:cors] paste.filter_factory = oslo_middleware.cors:filter_factory -oslo_config_project = aodh -latent_allow_headers = X-Auth-Token, X-Openstack-Request-Id, X-Subject-Token -latent_expose_headers = X-Auth-Token, X-Openstack-Request-Id, X-Subject-Token -latent_allow_methods = GET, PUT, POST, DELETE, PATCH \ No newline at end of file +oslo_config_project = aodh \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 3fcf30171..61a0e9fb2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -114,6 +114,9 @@ oslo.config.opts = aodh = aodh.opts:list_opts aodh-auth = aodh.opts:list_keystoneauth_opts +oslo.config.opts.defaults = + oslo.middleware.cors = aodh.conf.defaults:set_cors_middleware_defaults + keystoneauth1.plugin = password-aodh-legacy = aodh.keystone_client:LegacyAodhKeystoneLoader