Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[1LP][RFR] [NOTEST] Fix KeyError in show-credential script #10192

Merged
merged 1 commit into from
Jun 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions cfme/scripting/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ def show_credential(cred_or_provider_key, only_credentials):
endpoints_data = data['management_systems'][cred_or_provider_key].get('endpoints', {})
for endpoint in endpoints_data:
print(endpoint)
cred_key = endpoints_data[endpoint]['credentials']
cred_key = endpoints_data[endpoint].get('credentials')
if not cred_key:
print(" No credentials defined for this endpoint.")
continue
cred_dict = conf.credentials[cred_key]
for k in cred_dict:
print(" {}: {}".format(k, cred_dict[k]))
for k, v in cred_dict.items():
print(f" {k}: {v}")
elif cred_or_provider_key in conf.credentials:
cred_dict = conf.credentials[cred_or_provider_key]
for k in cred_dict:
print("{}: {}".format(k, cred_dict[k]))
for k, v in cred_dict.items():
print(f"{k}: {v}")
else:
print("Key couldn't be found in providers or credentials YAMLS")

Expand Down