diff options
author | Scott Moser <smoser@ubuntu.com> | 2010-06-18 14:24:48 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2010-06-18 14:24:48 -0400 |
commit | b9d39a834af1c6c30122f503aba695e49f4fecca (patch) | |
tree | 1a8f9fa89b3652510dc65d249f1bcb71c7b51787 /cloudinit | |
parent | 271e40c869046a892473ec33f94ead263a4d24c7 (diff) | |
download | vyos-cloud-init-b9d39a834af1c6c30122f503aba695e49f4fecca.tar.gz vyos-cloud-init-b9d39a834af1c6c30122f503aba695e49f4fecca.zip |
add ssh_import_id cloud-config module
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/CloudConfig/cc_ssh_import_id.py | 29 | ||||
-rw-r--r-- | cloudinit/__init__.py | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/cloudinit/CloudConfig/cc_ssh_import_id.py b/cloudinit/CloudConfig/cc_ssh_import_id.py new file mode 100644 index 00000000..e5d39ae9 --- /dev/null +++ b/cloudinit/CloudConfig/cc_ssh_import_id.py @@ -0,0 +1,29 @@ +import cloudinit.util as util +import subprocess +import traceback + +def handle(name,cfg,cloud,log,args): + 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",[]) + + log.warn("here, args = %s. user = %s ids = %s" % ( args, user, ids )) + if len(ids) == 0: return + + cmd = [ "sudo", "-Hu", user, "ssh-import-lp-id" ] + ids + + log.debug("importing ssh ids. cmd = %s" % cmd) + + try: + subprocess.check_call(cmd) + except subprocess.CalledProcessError as e: + log.debug(traceback.format_exc(e)) + raise Exception("Cmd returned %s: %s" % ( e.returncode, cmd)) + except OSError as e: + log.debug(traceback.format_exc(e)) + raise Exception("Cmd failed to execute: %s" % ( cmd )) diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py index 624b8ee8..50da30c0 100644 --- a/cloudinit/__init__.py +++ b/cloudinit/__init__.py @@ -39,6 +39,7 @@ disable_root: 1 cloud_config_modules: - mounts + - ssh-import-id - ssh - apt-update-upgrade - puppet |