Merge pull request #7678 from hacosta/devel

Show friendlier error message if nova.ini is not found.
pull/7579/merge
James Cammarata 11 years ago
commit 4c5a765986

@ -144,23 +144,23 @@ except:
# executed with no parameters, return the list of # executed with no parameters, return the list of
# all groups and hosts # all groups and hosts
NOVA_CONFIG_FILES = [os.getcwd() + "/nova.ini",
os.path.expanduser(os.environ.get('ANSIBLE_CONFIG', "~/nova.ini")),
"/etc/ansible/nova.ini"]
def nova_load_config_file(): def nova_load_config_file():
p = ConfigParser.SafeConfigParser() p = ConfigParser.SafeConfigParser()
path1 = os.getcwd() + "/nova.ini"
path2 = os.path.expanduser(os.environ.get('ANSIBLE_CONFIG', "~/nova.ini")) for path in NOVA_CONFIG_FILES:
path3 = "/etc/ansible/nova.ini" if os.path.exists(path):
p.read(path)
if os.path.exists(path1): return p
p.read(path1)
elif os.path.exists(path2): return None
p.read(path2)
elif os.path.exists(path3):
p.read(path3)
else:
return None
return p
config = nova_load_config_file() config = nova_load_config_file()
if not config:
sys.exit('Unable to find configfile in %s' % ', '.join(NOVA_CONFIG_FILES))
client = nova_client.Client( client = nova_client.Client(
version = config.get('openstack', 'version'), version = config.get('openstack', 'version'),

Loading…
Cancel
Save