Use ConfigOpts.find_file() to locate policy.json
Use cfg's new helper method to find policy config file. The basic behavior is "look alongside the config file" with a fall back to the standard default config paths. Change-Id: I763097107c53fc9b7d4e783ee92bf16989d92cff
This commit is contained in:
parent
e0d891ea0d
commit
f926d86530
|
@ -17,6 +17,8 @@
|
|||
|
||||
"""Policy Engine For Nova"""
|
||||
|
||||
import os.path
|
||||
|
||||
from nova.common import policy
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
|
@ -52,7 +54,11 @@ def init():
|
|||
global _POLICY_PATH
|
||||
global _POLICY_CACHE
|
||||
if not _POLICY_PATH:
|
||||
_POLICY_PATH = utils.find_config(FLAGS.policy_file)
|
||||
_POLICY_PATH = FLAGS.policy_file
|
||||
if not os.path.exists(_POLICY_PATH):
|
||||
_POLICY_PATH = FLAGS.find_file(_POLICY_PATH)
|
||||
if not _POLICY_PATH:
|
||||
raise exception.ConfigNotFound(path=FLAGS.policy_file)
|
||||
utils.read_cached_file(_POLICY_PATH, _POLICY_CACHE,
|
||||
reload_func=_set_brain)
|
||||
|
||||
|
|
|
@ -43,4 +43,3 @@ FLAGS.set_default('flat_network_bridge', 'br100')
|
|||
FLAGS.set_default('sqlite_synchronous', False)
|
||||
flags.DECLARE('policy_file', 'nova.policy')
|
||||
flags.DECLARE('compute_scheduler_driver', 'nova.scheduler.multi')
|
||||
FLAGS.set_default('policy_file', 'nova/tests/policy.json')
|
||||
|
|
|
@ -1332,6 +1332,7 @@ def read_cached_file(filename, cache_info, reload_func=None):
|
|||
"""
|
||||
mtime = os.path.getmtime(filename)
|
||||
if not cache_info or mtime != cache_info.get('mtime'):
|
||||
LOG.debug(_("Reloading cached file %s") % filename)
|
||||
with open(filename) as fap:
|
||||
cache_info['data'] = fap.read()
|
||||
cache_info['mtime'] = mtime
|
||||
|
|
Loading…
Reference in New Issue