diff --git a/nova/common/__init__.py b/nova/common/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/nova/common/config.py b/nova/common/config.py new file mode 100644 index 000000000000..4f4557d0299e --- /dev/null +++ b/nova/common/config.py @@ -0,0 +1,40 @@ +# 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_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-Identity-Status', + 'X-Roles', + 'X-Service-Catalog', + 'X-User-Id', + 'X-Tenant-Id'], + expose_headers=['X-Auth-Token', + 'X-Openstack-Request-Id', + 'X-Subject-Token', + 'X-Service-Token'], + allow_methods=['GET', + 'PUT', + 'POST', + 'DELETE', + 'PATCH'] + ) diff --git a/nova/config.py b/nova/config.py index b9c025915a2f..7c3606475996 100644 --- a/nova/config.py +++ b/nova/config.py @@ -20,13 +20,13 @@ from oslo_config import cfg from oslo_db import options from oslo_log import log +from nova.common import config from nova.db.sqlalchemy import api as sqlalchemy_api from nova import debugger from nova import paths from nova import rpc from nova import version - CONF = cfg.CONF _DEFAULT_SQL_CONNECTION = 'sqlite:///' + paths.state_path_def('nova.sqlite') @@ -57,6 +57,8 @@ def parse_args(argv, default_config_files=None, configure_db=True, rpc.set_defaults(control_exchange='nova') cache.configure(CONF) debugger.register_cli_opts() + config.set_middleware_defaults() + CONF(argv[1:], project='nova', version=version.version_string(), diff --git a/setup.cfg b/setup.cfg index 9a3133e1f2c2..f27bb97bb6a6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,6 +36,9 @@ oslo.config.opts = nova.virt = nova.virt.opts:list_opts nova.cache_utils = nova.cache_utils:list_opts +oslo.config.opts.defaults = + oslo.middleware = nova.common.config:set_middleware_defaults + nova.compute.monitors.cpu = virt_driver = nova.compute.monitors.cpu.virt_driver:Monitor nova.compute.resources =