cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #00556
[Merge] lp:~harlowja/cloud-init/ssh-key-types into lp:cloud-init
Joshua Harlow has proposed merging lp:~harlowja/cloud-init/ssh-key-types into lp:cloud-init.
Requested reviews:
cloud init development team (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~harlowja/cloud-init/ssh-key-types/+merge/239121
Instead of only expected a list, tuple, or set type
allow for a string type and dict to be passed in for 'ssh_authorized_keys',
and add log message that occurs if some other type is used that
can not be correctly processed.
--
https://code.launchpad.net/~harlowja/cloud-init/ssh-key-types/+merge/239121
Your team cloud init development team is requested to review the proposed merge of lp:~harlowja/cloud-init/ssh-key-types into lp:cloud-init.
=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py 2014-09-10 18:32:37 +0000
+++ cloudinit/distros/__init__.py 2014-10-21 19:04:56 +0000
@@ -387,8 +387,19 @@
# 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 isinstance(keys, dict):
+ keys = list(keys.values())
+ if not isinstance(keys, (tuple, list, set)):
+ util.multi_log("Invalid type detected for"
+ " 'ssh_authorized_keys', expected list, string"
+ " , dict, or set.")
+ else:
+ keys = set(keys) or []
+ ssh_util.setup_user_keys(keys, name, options=None)
return True
Follow ups