summaryrefslogtreecommitdiff
path: root/cloudinit/sources
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-01-22 12:09:52 -0500
committerScott Moser <smoser@ubuntu.com>2015-01-22 12:09:52 -0500
commitde32623e6b34e3648958f1a08ef721ed9a03f2f8 (patch)
treed10ae9a3770fad0bdeb83a597523b8d30e259c9e /cloudinit/sources
parentc80892c9c326716724c3ff06d9a82516a4152c74 (diff)
parent8d453d2a4da4492857a4487b14fe7b11a014115b (diff)
downloadvyos-cloud-init-de32623e6b34e3648958f1a08ef721ed9a03f2f8.tar.gz
vyos-cloud-init-de32623e6b34e3648958f1a08ef721ed9a03f2f8.zip
merge from trunk
Diffstat (limited to 'cloudinit/sources')
-rw-r--r--cloudinit/sources/DataSourceGCE.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py
index 92e5a28e..2cf8fdcd 100644
--- a/cloudinit/sources/DataSourceGCE.py
+++ b/cloudinit/sources/DataSourceGCE.py
@@ -29,6 +29,7 @@ BUILTIN_DS_CONFIG = {
}
REQUIRED_FIELDS = ('instance-id', 'availability-zone', 'local-hostname')
+
class DataSourceGCE(sources.DataSource):
def __init__(self, sys_cfg, distro, paths):
sources.DataSource.__init__(self, sys_cfg, distro, paths)
@@ -59,7 +60,8 @@ 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),
+ ('user-data-encoding', 'instance/attributes/user-data-encoding',
+ False),
]
# if we cannot resolve the metadata server, then no point in trying
@@ -106,7 +108,8 @@ class DataSourceGCE(sources.DataSource):
encoding = self.metadata.get('user-data-encoding')
if encoding:
if encoding == 'base64':
- self.metadata['user-data'] = b64decode(self.metadata['user-data'])
+ self.metadata['user-data'] = b64decode(
+ self.metadata['user-data'])
else:
LOG.warn('unknown user-data-encoding: %s, ignoring', encoding)
@@ -124,7 +127,8 @@ class DataSourceGCE(sources.DataSource):
return self.metadata['public-keys']
def get_hostname(self, fqdn=False, _resolve_ip=False):
- return self.metadata['local-hostname']
+ # GCE has long FDQN's and has asked for short hostnames
+ return self.metadata['local-hostname'].split('.')[0]
def get_userdata_raw(self):
return self.metadata['user-data']