summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceGCE.py
diff options
context:
space:
mode:
authorWayne Witzel III <wayne.witzel@canonical.com>2014-12-19 11:28:35 -0500
committerWayne Witzel III <wayne.witzel@canonical.com>2014-12-19 11:28:35 -0500
commitb7632baa817a8425c2dcab4a01e2f7f0983e5f9e (patch)
tree162cc39eec5a262f2be404af2c88943cd9976cc8 /cloudinit/sources/DataSourceGCE.py
parentfa5ce8c40621c78e61c7d9bd073903101f7d6a5e (diff)
downloadvyos-cloud-init-b7632baa817a8425c2dcab4a01e2f7f0983e5f9e.tar.gz
vyos-cloud-init-b7632baa817a8425c2dcab4a01e2f7f0983e5f9e.zip
add user-data encoding support for gce
Diffstat (limited to 'cloudinit/sources/DataSourceGCE.py')
-rw-r--r--cloudinit/sources/DataSourceGCE.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py
index 7091e3c1..e6f3651c 100644
--- a/cloudinit/sources/DataSourceGCE.py
+++ b/cloudinit/sources/DataSourceGCE.py
@@ -15,6 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from base64 import b64decode
+
from cloudinit import log as logging
from cloudinit import util
from cloudinit import sources
@@ -58,6 +60,7 @@ class DataSourceGCE(sources.DataSource):
('local-hostname', 'instance/hostname', True),
('public-keys', 'project/attributes/sshKeys', False),
('user-data', 'instance/attributes/user-data', False),
+ ('user-data-encoding', 'instance/attributes/user-data-encoding', False),
]
# if we cannot resolve the metadata server, then no point in trying
@@ -101,6 +104,12 @@ class DataSourceGCE(sources.DataSource):
lines = self.metadata['public-keys'].splitlines()
self.metadata['public-keys'] = [self._trim_key(k) for k in lines]
+ if self.metadata.get('user-data-encoding'):
+ if self.metadata['user-data-encoding'] == 'base64':
+ self.metadata['user-data'] = b64decode(self.metadata['user-data'])
+ else:
+ LOG.warn('user-data-encoding: unknown encoding specified', None, None)
+
return found
@property