Commit f762daf1 authored by Andrii Salnikov's avatar Andrii Salnikov
Browse files

Fallback to /etc/arc.conf if no config in prefix and default path is used

parent 9d8efd2c
......@@ -26,7 +26,7 @@ __runconfig = '/tmp/.arcctl.arc.run.conf'
def get_parser():
parser = argparse.ArgumentParser(description='Nordugrid ARC Computing Element Control Tool')
parser.add_argument('-c', '--config', action='store',
help='config file location (default is %(default)s)', default=config.arcconf_defpath())
help='config file location (default is {0})'.format(config.arcconf_defpath()))
parser.add_argument('-d', '--debug', action='store',
help='verbosity level (default is %(default)s)', default='WARNING',
choices=['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'])
......@@ -40,7 +40,23 @@ def get_parser():
# Return parsed arc.conf (conditionally dump and load config with included defaults)
def get_arcconfig(conf_f):
runconf_load = os.path.exists(__runconfig)
# handle default
def_conf_f = config.arcconf_defpath()
if conf_f is None:
if os.path.exists(def_conf_f):
conf_f = def_conf_f
elif def_conf_f != '/etc/arc.conf' and os.path.exists('/etc/arc.conf'):
conf_f = '/etc/arc.conf'
logger.warning('There is no arc.conf in ARC installation prefix (%s). '
'Using /etc/arc.conf that exists.', def_conf_f)
else:
logger.error('Cannot find ARC configuration file in the default location.')
return None
runconf_load = os.path.exists(__runconfig)
else:
logger.debug('Custom ARC configuration file location used. Cached running configuration will not be used.')
runconf_load = False
try:
logger.debug('Getting ARC configuration (config file: %s)', conf_f)
if runconf_load:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment