Merge "genpwd: handle lack of password file nicer"

This commit is contained in:
Zuul 2022-05-25 06:03:04 +00:00 committed by Gerrit Code Review
commit 9549e8ccfe

View File

@ -56,8 +56,12 @@ def generate_RSA(bits=4096):
def genpwd(passwords_file, length, uuid_keys, ssh_keys, blank_keys, def genpwd(passwords_file, length, uuid_keys, ssh_keys, blank_keys,
fernet_keys, hmac_md5_keys): fernet_keys, hmac_md5_keys):
try:
with open(passwords_file, 'r') as f: with open(passwords_file, 'r') as f:
passwords = yaml.safe_load(f.read()) passwords = yaml.safe_load(f.read())
except FileNotFoundError:
print(f"ERROR: Passwords file \"{passwords_file}\" is missing")
sys.exit(1)
if not isinstance(passwords, dict): if not isinstance(passwords, dict):
print("ERROR: Passwords file not in expected key/value format") print("ERROR: Passwords file not in expected key/value format")