Correct default policy_file in the sample config

When the sample config is generated, the policy_file default value
specified by oslo.policy is showing up, not the default value that
Cinder is using.  Correct this by enhancing the function specified
for cinder in the oslo.config.opts.defaults entry point.

This patch exposed Bug #1807184 in oslo.policy.  The requirements
and lower-constraints changes on this patch bump the minimum
version of oslo.policy we use to include the fix (1.44.1).  This
version was already included in upper-constraints by Change
I50bb9d48106376f5baaafae372492c0744182da2.

Change-Id: Ic28d660a9d876139f47f98cf1024a30b005cd0e0
Closes-bug: #1807071
This commit is contained in:
Brian Rosmaita 2018-12-05 22:12:13 -05:00
parent 27304275d7
commit 8c13219392
5 changed files with 19 additions and 4 deletions

View File

@ -30,8 +30,11 @@ import socket
from oslo_config import cfg
from oslo_log import log as logging
from oslo_middleware import cors
from oslo_policy import opts as policy_opts
from oslo_utils import netutils
from cinder.policy import DEFAULT_POLICY_FILENAME
CONF = cfg.CONF
logging.register_options(CONF)
@ -210,3 +213,14 @@ def set_middleware_defaults():
'PATCH',
'HEAD']
)
def set_external_library_defaults():
"""Set default configuration options for external openstack libraries."""
# This function is required so that our settings will override the defaults
# set by the libraries when the Cinder config files are generated. This
# function is declared as an entry point for oslo.config.opts.defaults in
# setup.cfg.
set_middleware_defaults()
policy_opts.set_defaults(CONF, policy_file=DEFAULT_POLICY_FILENAME)

View File

@ -28,7 +28,8 @@ from cinder import policies
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
policy_opts.set_defaults(cfg.CONF, 'policy.yaml')
DEFAULT_POLICY_FILENAME = 'policy.yaml'
policy_opts.set_defaults(cfg.CONF, DEFAULT_POLICY_FILENAME)
_ENFORCER = None

View File

@ -76,7 +76,7 @@ oslo.i18n==3.15.3
oslo.log==3.36.0
oslo.messaging==6.4.0
oslo.middleware==3.31.0
oslo.policy==1.30.0
oslo.policy==1.44.1
oslo.privsep==1.23.0
oslo.reports==1.18.0
oslo.rootwrap==5.8.0

View File

@ -23,7 +23,7 @@ oslo.db>=4.27.0 # Apache-2.0
oslo.log>=3.36.0 # Apache-2.0
oslo.messaging>=6.4.0 # Apache-2.0
oslo.middleware>=3.31.0 # Apache-2.0
oslo.policy>=1.30.0 # Apache-2.0
oslo.policy>=1.44.1 # Apache-2.0
oslo.privsep>=1.23.0 # Apache-2.0
oslo.reports>=1.18.0 # Apache-2.0
oslo.rootwrap>=5.8.0 # Apache-2.0

View File

@ -52,7 +52,7 @@ cinder.scheduler.weights =
oslo.config.opts =
cinder = cinder.opts:list_opts
oslo.config.opts.defaults =
cinder = cinder.common.config:set_middleware_defaults
cinder = cinder.common.config:set_external_library_defaults
oslo.policy.enforcer =
cinder = cinder.policy:get_enforcer
oslo.policy.policies =