diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-30 09:30:17 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-09-30 09:30:17 -0400 |
commit | 497972223afd5193a40e3e9c4e69ce31319a1ebc (patch) | |
tree | bda83abe5575a0d51b01f3e4c04916c667520346 /cloudinit/config/cc_ssh_authkey_fingerprints.py | |
parent | a28d7fe46cf8e3277a13c35c5dd0185f65ab1d0c (diff) | |
parent | 72fc1f762e5c5df563380e9ed90bfaba131e811b (diff) | |
download | vyos-cloud-init-497972223afd5193a40e3e9c4e69ce31319a1ebc.tar.gz vyos-cloud-init-497972223afd5193a40e3e9c4e69ce31319a1ebc.zip |
rework the rest of the users of old single 'user' to support lists
Rework the rest of the locations that used the previous 'user' and make
those locations go through the new distros functions to select the default
user or the user list (depending on usage).
Adjust the tests to check the new 'default' field that signifies the
default user + test the new method to extract just the default user from a
normalized user dictionary.
"default" user is now marked in the user dict and get_default_user uses
that.
Diffstat (limited to 'cloudinit/config/cc_ssh_authkey_fingerprints.py')
-rw-r--r-- | cloudinit/config/cc_ssh_authkey_fingerprints.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/cloudinit/config/cc_ssh_authkey_fingerprints.py b/cloudinit/config/cc_ssh_authkey_fingerprints.py index f9bdf5fc..8c9a8806 100644 --- a/cloudinit/config/cc_ssh_authkey_fingerprints.py +++ b/cloudinit/config/cc_ssh_authkey_fingerprints.py @@ -21,7 +21,11 @@ import hashlib from prettytable import PrettyTable -from cloudinit import distros +# Ensure this is aliased to a name not 'distros' +# since the module attribute 'distros' +# is a list of distros that are supported, not a sub-module +from cloudinit import distros as ds + from cloudinit import ssh_util from cloudinit import util @@ -41,8 +45,10 @@ def _gen_fingerprint(b64_text, hash_meth='md5'): hasher = hashlib.new(hash_meth) hasher.update(base64.b64decode(b64_text)) return ":".join(_split_hash(hasher.hexdigest())) - except TypeError: + except (TypeError, ValueError): # Raised when b64 not really b64... + # or when the hash type is not really + # a known/supported hash type... return '?' @@ -92,8 +98,8 @@ def handle(name, cfg, cloud, log, _args): hash_meth = util.get_cfg_option_str(cfg, "authkey_hash", "md5") extract_func = ssh_util.extract_authorized_keys - (users, _groups) = distros.normalize_users_groups(cfg, cloud.distro) + (users, _groups) = ds.normalize_users_groups(cfg, cloud.distro) for (user_name, _cfg) in users.items(): (auth_key_fn, auth_key_entries) = extract_func(user_name, cloud.paths) - _pprint_key_entries(user_name, auth_key_fn, auth_key_entries, - hash_meth) + _pprint_key_entries(user_name, auth_key_fn, + auth_key_entries, hash_meth) |