summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceGCE.py
diff options
context:
space:
mode:
authorVaidas Jablonskis <jablonskis@gmail.com>2014-02-07 13:12:48 +0000
committerVaidas Jablonskis <jablonskis@gmail.com>2014-02-07 13:12:48 +0000
commit64b35a9c3b201aed5073823fd4a15ecb15195aea (patch)
treeb078fe4c699b2663cc4447228ff00dbae2496b3f /cloudinit/sources/DataSourceGCE.py
parente1710e06fd09c3f643fdca851c011da3a3eb7a98 (diff)
downloadvyos-cloud-init-64b35a9c3b201aed5073823fd4a15ecb15195aea.tar.gz
vyos-cloud-init-64b35a9c3b201aed5073823fd4a15ecb15195aea.zip
Forgot to include _trim_key function
Got removed somehow
Diffstat (limited to 'cloudinit/sources/DataSourceGCE.py')
-rw-r--r--cloudinit/sources/DataSourceGCE.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py
index f9cdc1da..8a46f933 100644
--- a/cloudinit/sources/DataSourceGCE.py
+++ b/cloudinit/sources/DataSourceGCE.py
@@ -30,6 +30,16 @@ class DataSourceGCE(sources.DataSource):
self.metadata_address = MD_URL
self.metadata = {}
+ # GCE takes sshKeys attribute in the format of '<user>:<public_key>'
+ # so we have to trim each key to remove the username part
+ def _trim_key(self, public_key):
+ try:
+ index = public_key.index(':')
+ if index > 0:
+ return public_key[(index + 1):]
+ except:
+ return public_key
+
def get_data(self):
# GCE metadata server requires a custom header since v1
headers = {'X-Google-Metadata-Request': True}