diff options
author | Scott Moser <smoser@ubuntu.com> | 2011-01-14 16:00:47 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2011-01-14 16:00:47 -0500 |
commit | 1a35587abb5226c3b008f1a034c56145cb878489 (patch) | |
tree | 55155bf38556bc1789222456434961f905921761 /cloudinit/CloudConfig/cc_ssh_import_id.py | |
parent | 1843c842bb38c964cb20c08a74cb73b90d3d2979 (diff) | |
download | vyos-cloud-init-1a35587abb5226c3b008f1a034c56145cb878489.tar.gz vyos-cloud-init-1a35587abb5226c3b008f1a034c56145cb878489.zip |
add support for specifying ssh-import-id on the kernel command line
Diffstat (limited to 'cloudinit/CloudConfig/cc_ssh_import_id.py')
-rw-r--r-- | cloudinit/CloudConfig/cc_ssh_import_id.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/cloudinit/CloudConfig/cc_ssh_import_id.py b/cloudinit/CloudConfig/cc_ssh_import_id.py index bf1314be..9dd2159a 100644 --- a/cloudinit/CloudConfig/cc_ssh_import_id.py +++ b/cloudinit/CloudConfig/cc_ssh_import_id.py @@ -20,15 +20,30 @@ import subprocess import traceback def handle(name,cfg,cloud,log,args): + ids = [ ] if len(args) != 0: user = args[0] - ids = [ ] if len(args) > 1: ids = args[1:] else: user = util.get_cfg_option_str(cfg,"user","ubuntu") ids = util.get_cfg_option_list_or_str(cfg,"ssh_import_id",[]) + try: + fp = open("/proc/cmdline") + cmdline = fp.read() + fp.close() + names = [ "ssh_import_id", "ssh_import" ] + cmd_ids = [ ] + for i in cmdline.strip().split(): + for n in names: + if i.startswith(n + "="): + print i + cmd_ids=i[len(n)+1:].split(",") + ids.extend(cmd_ids) + except: + log.warn("failed to read /proc/cmdline for import_id") + if len(ids) == 0: return cmd = [ "sudo", "-Hu", user, "ssh-import-id" ] + ids |