summaryrefslogtreecommitdiff
path: root/ec2init/DataSourceEc2.py
diff options
context:
space:
mode:
authorScott Moser <smoser@nelson>2010-01-07 20:18:26 -0500
committerScott Moser <smoser@nelson>2010-01-07 20:18:26 -0500
commit399f9ede1081a01b3c4d0e461ab269d3a42a5f71 (patch)
tree8bbbe8a6a8edd1a16b039412d4352164818d74b4 /ec2init/DataSourceEc2.py
parent49d3df468a94fef41a036dfa5d886449d180e006 (diff)
downloadvyos-cloud-init-399f9ede1081a01b3c4d0e461ab269d3a42a5f71.tar.gz
vyos-cloud-init-399f9ede1081a01b3c4d0e461ab269d3a42a5f71.zip
support getting public ssh keys from ec2 metadata service
Diffstat (limited to 'ec2init/DataSourceEc2.py')
-rw-r--r--ec2init/DataSourceEc2.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/ec2init/DataSourceEc2.py b/ec2init/DataSourceEc2.py
index cc12c97c..5d3bab88 100644
--- a/ec2init/DataSourceEc2.py
+++ b/ec2init/DataSourceEc2.py
@@ -120,5 +120,14 @@ class DataSourceEc2(DataSource.DataSource):
elif availability_zone.startswith('eu-'):
return 'eu'
raise Exception('Could not determine location')
-
+ def get_public_ssh_keys(self):
+ keys = []
+ if not self.metadata.has_key('public-keys'): return([])
+ for keyname, klist in self.metadata['public-keys'].items():
+ for pkey in klist:
+ # there is an empty string at the end of the keylist, trim it
+ if pkey:
+ keys.append(pkey)
+
+ return(keys)