Merge "policy: don't hack around oslo.config path search algorithm"

This commit is contained in:
Jenkins 2015-03-10 22:12:06 +00:00 committed by Gerrit Code Review
commit 52ee955dd9
2 changed files with 9 additions and 11 deletions

View File

@ -22,14 +22,12 @@ import itertools
import logging
import re
from oslo_config import cfg
from oslo_utils import excutils
from oslo_utils import importutils
from neutron.api.v2 import attributes
from neutron.common import constants as const
from neutron.common import exceptions
import neutron.common.utils as utils
from neutron.i18n import _LE, _LI, _LW
from neutron.openstack.common import log
from neutron.openstack.common import policy
@ -71,11 +69,6 @@ def init():
global _ENFORCER
if not _ENFORCER:
_ENFORCER = policy.Enforcer()
# NOTE: Method _get_policy_path in common.policy can not always locate
# neutron policy file (when init() is called in tests),
# so set it explicitly.
_ENFORCER.policy_path = utils.find_config_file({},
cfg.CONF.policy_file)
_ENFORCER.load_rules(True)

View File

@ -41,12 +41,12 @@ CONF = cfg.CONF
CONF.import_opt('state_path', 'neutron.common.config')
LOG_FORMAT = sub_base.LOG_FORMAT
ROOTDIR = os.path.dirname(__file__)
ETCDIR = os.path.join(ROOTDIR, 'etc')
ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..')
TEST_ROOT_DIR = os.path.dirname(__file__)
def etcdir(*p):
return os.path.join(ETCDIR, *p)
def etcdir(filename, root=TEST_ROOT_DIR):
return os.path.join(root, 'etc', filename)
def fake_use_fatal_exceptions(*args):
@ -68,6 +68,11 @@ class BaseTestCase(sub_base.SubBaseTestCase):
# neutron.conf.test includes rpc_backend which needs to be cleaned up
if args is None:
args = ['--config-file', etcdir('neutron.conf.test')]
# this is needed to add ROOT_DIR to the list of paths that oslo.config
# will try to traverse when searching for a new config file (it's
# needed so that policy module can locate policy_file)
args += ['--config-file', etcdir('neutron.conf', root=ROOT_DIR)]
if conf is None:
config.init(args=args)
else: