More detail in arg validation
There's no reason to forbid --list and --static-yaml-inventory Also, we should return an error if both --list and --host are defined. Change-Id: I94393de4a71a92c12f8d427748853d7ff2ce5a02
This commit is contained in:
parent
f840eb6b23
commit
040fd0486e
@ -86,6 +86,13 @@ def _parse_config():
|
||||
'variable missing or --os-cloud option is not set, '
|
||||
'unable to proceed.', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if (configs.static_yaml_inventory or configs.list) and configs.host:
|
||||
print(
|
||||
"ERROR: can't list (--list) all hosts or generate an inventory "
|
||||
"(--static-yaml-inventory) while looking for a specific host "
|
||||
"(--host)"
|
||||
)
|
||||
sys.exit(1)
|
||||
if configs.auth_url:
|
||||
if '/v2.0' in configs.auth_url:
|
||||
configs.auth_url = configs.auth_url.replace('/v2.0', '/v3')
|
||||
@ -214,7 +221,9 @@ def main():
|
||||
if configs.debug:
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
elif configs.static_yaml_inventory:
|
||||
elif configs.host:
|
||||
print(json.dumps(inventory.host()))
|
||||
if configs.static_yaml_inventory:
|
||||
try:
|
||||
inventory.write_static_inventory(configs.static_yaml_inventory)
|
||||
except Exception as e:
|
||||
@ -223,8 +232,6 @@ def main():
|
||||
if configs.debug:
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
elif configs.host:
|
||||
print(json.dumps(inventory.host()))
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user