Moves find config to utils because it is useful
This is to prepare for a future patch will will use find config to load other config files. Change-Id: Ic9bd9027baf518734c3f51f516651b80d1e752f2
This commit is contained in:
@@ -77,6 +77,29 @@ def import_object(import_str):
|
||||
return cls()
|
||||
|
||||
|
||||
def find_config(config_path):
|
||||
"""Find a configuration file using the given hint.
|
||||
|
||||
:param config_path: Full or relative path to the config.
|
||||
:returns: Full path of the config, if it exists.
|
||||
:raises: `nova.exception.ConfigNotFound`
|
||||
|
||||
"""
|
||||
possible_locations = [
|
||||
config_path,
|
||||
os.path.join(FLAGS.state_path, "etc", "nova", config_path),
|
||||
os.path.join(FLAGS.state_path, "etc", config_path),
|
||||
os.path.join(FLAGS.state_path, config_path),
|
||||
"/etc/nova/%s" % config_path,
|
||||
]
|
||||
|
||||
for path in possible_locations:
|
||||
if os.path.exists(path):
|
||||
return os.path.abspath(path)
|
||||
|
||||
raise exception.ConfigNotFound(path=os.path.abspath(config_path))
|
||||
|
||||
|
||||
def vpn_ping(address, port, timeout=0.05, session_id=None):
|
||||
"""Sends a vpn negotiation packet and returns the server session.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user