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
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)
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):
# 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: