diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2014-10-21 11:55:16 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2014-10-21 11:55:16 -0700 |
commit | e88f6ed4c46fcb1069fe899606a8b6d95411c13f (patch) | |
tree | 0da2366fd659162bee15a57e0e2664cf65359a16 /cloudinit/distros/__init__.py | |
parent | dd1853b5b64c43995e33c129bc71def9f4bad0ce (diff) | |
download | vyos-cloud-init-e88f6ed4c46fcb1069fe899606a8b6d95411c13f.tar.gz vyos-cloud-init-e88f6ed4c46fcb1069fe899606a8b6d95411c13f.zip |
Handle strings/text type for 'ssh_authorized_keys'
Instead of only expected a list, tuple, or set type
allow for a string type to be passed in, and add log
message that occurs if some other type is used that
can not be correctly processed.
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r-- | cloudinit/distros/__init__.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 2599d9f2..d30098eb 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -387,8 +387,17 @@ class Distro(object): # Import SSH keys if 'ssh_authorized_keys' in kwargs: - keys = set(kwargs['ssh_authorized_keys']) or [] - ssh_util.setup_user_keys(keys, name, options=None) + # Try to handle this in a smart manner. + keys = kwargs['ssh_authorized_keys'] + if isinstance(keys, (basestring, str)): + keys = [keys] + if not isinstance(keys, (tuple, list, set)): + util.multi_log("Invalid type detected for" + " 'ssh_authorized_keys', expected list, string" + " or set.") + else: + keys = set(keys) or [] + ssh_util.setup_user_keys(keys, name, options=None) return True |