From bd0c29c2f298ad060bba88ddbb4d2d11ab07cafe Mon Sep 17 00:00:00 2001 From: Ben Howard Date: Wed, 14 Jan 2015 07:29:57 -0700 Subject: Use the short name for GCE hostnames per GCE's request (LP: #1383794). --- cloudinit/sources/DataSourceGCE.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cloudinit/sources') diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py index 92e5a28e..f877b3d1 100644 --- a/cloudinit/sources/DataSourceGCE.py +++ b/cloudinit/sources/DataSourceGCE.py @@ -124,7 +124,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'] -- cgit v1.2.3 From ae2f5123faab45e71e4dcf3237d7dac59a4c66b7 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 16 Jan 2015 13:21:08 -0500 Subject: pep8 fixes --- cloudinit/sources/DataSourceGCE.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cloudinit/sources') diff --git a/cloudinit/sources/DataSourceGCE.py b/cloudinit/sources/DataSourceGCE.py index f877b3d1..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) -- cgit v1.2.3