mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Show friendlier error message if nova.ini is not found.
Signed-off-by: Hector Acosta <hector.acosta@gmail.com>
This commit is contained in:
parent
ab956e8e4a
commit
a080873e7c
1 changed files with 12 additions and 12 deletions
|
@ -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"))
|
|
||||||
path3 = "/etc/ansible/nova.ini"
|
|
||||||
|
|
||||||
if os.path.exists(path1):
|
for path in NOVA_CONFIG_FILES:
|
||||||
p.read(path1)
|
if os.path.exists(path):
|
||||||
elif os.path.exists(path2):
|
p.read(path)
|
||||||
p.read(path2)
|
|
||||||
elif os.path.exists(path3):
|
|
||||||
p.read(path3)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
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…
Reference in a new issue