summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-02-17 16:59:04 -0500
committerScott Moser <smoser@ubuntu.com>2012-02-17 16:59:04 -0500
commit3b3386dd794c9063db99fc0c9422119e8536b18d (patch)
treef269dc243eb57bae47e67625b3cea8cf00ec8998
parent316f9ee4bfb27375ae92027664a59b94922f11ec (diff)
downloadvyos-cloud-init-3b3386dd794c9063db99fc0c9422119e8536b18d.tar.gz
vyos-cloud-init-3b3386dd794c9063db99fc0c9422119e8536b18d.zip
ConfigDrive: better support public-keys in meta flags
This makes the user able to pass in multi-line input to the public-key flag, and it will be handled correctly (just as if it came from the authorized_keys file)
-rw-r--r--cloudinit/DataSourceConfigDrive.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/cloudinit/DataSourceConfigDrive.py b/cloudinit/DataSourceConfigDrive.py
index f44344a2..2db4a76a 100644
--- a/cloudinit/DataSourceConfigDrive.py
+++ b/cloudinit/DataSourceConfigDrive.py
@@ -162,6 +162,7 @@ def read_config_drive_dir(source_dir):
flist = ("etc/network/interfaces", "root/.ssh/authorized_keys", "meta.js")
found = [f for f in flist if os.path.isfile("%s/%s" % (source_dir, f))]
+ keydata = ""
if len(found) == 0:
raise nonConfigDriveDir("%s: %s" % (source_dir, "no files found"))
@@ -172,10 +173,7 @@ def read_config_drive_dir(source_dir):
if "root/.ssh/authorized_keys" in found:
with open("%s/%s" % (source_dir, "root/.ssh/authorized_keys")) as fp:
- content = fp.read()
- lines = content.splitlines()
- keys = [l for l in lines if len(l) and not l.startswith("#")]
- md['public-keys'] = keys
+ keydata = fp.read()
meta_js = {}
@@ -190,7 +188,14 @@ def read_config_drive_dir(source_dir):
raise nonConfigDriveDir("%s: %s" %
(source_dir, "invalid json in meta.js"))
- for copy in ('public-keys', 'dsmode', 'instance-id', 'dscfg'):
+ keydata = meta_js.get('public-keys', keydata)
+
+ if keydata:
+ lines = keydata.splitlines()
+ md['public-keys'] = [l for l in lines
+ if len(l) and not l.startswith("#")]
+
+ for copy in ('dsmode', 'instance-id', 'dscfg'):
if copy in meta_js:
md[copy] = meta_js[copy]