From 399f9ede1081a01b3c4d0e461ab269d3a42a5f71 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 7 Jan 2010 20:18:26 -0500 Subject: support getting public ssh keys from ec2 metadata service --- ec2init/DataSourceEc2.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ec2init/DataSourceEc2.py') 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) -- cgit v1.2.3