Merge lp:~darkmuggle-deactivatedaccount/cloud-init/lp1383794 into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Ben Howard
Status: Merged
Merged at revision: 1049
Proposed branch: lp:~darkmuggle-deactivatedaccount/cloud-init/lp1383794
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 38 lines (+6/-4)
2 files modified
cloudinit/sources/DataSourceGCE.py (+2/-1)
tests/unittests/test_datasource/test_gce.py (+4/-3)
To merge this branch: bzr merge lp:~darkmuggle-deactivatedaccount/cloud-init/lp1383794
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+246433@code.launchpad.net

Description of the change

Use the GCE short hostname.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/sources/DataSourceGCE.py'
2--- cloudinit/sources/DataSourceGCE.py 2015-01-06 16:41:05 +0000
3+++ cloudinit/sources/DataSourceGCE.py 2015-01-14 14:53:06 +0000
4@@ -124,7 +124,8 @@
5 return self.metadata['public-keys']
6
7 def get_hostname(self, fqdn=False, _resolve_ip=False):
8- return self.metadata['local-hostname']
9+ # GCE has long FDQN's and has asked for short hostnames
10+ return self.metadata['local-hostname'].split('.')[0]
11
12 def get_userdata_raw(self):
13 return self.metadata['user-data']
14
15=== modified file 'tests/unittests/test_datasource/test_gce.py'
16--- tests/unittests/test_datasource/test_gce.py 2015-01-06 17:09:00 +0000
17+++ tests/unittests/test_datasource/test_gce.py 2015-01-14 14:53:06 +0000
18@@ -99,7 +99,8 @@
19 body=_new_request_callback())
20 self.ds.get_data()
21
22- self.assertEqual(GCE_META.get('instance/hostname'),
23+ shostname = GCE_META.get('instance/hostname').split('.')[0]
24+ self.assertEqual(shostname,
25 self.ds.get_hostname())
26
27 self.assertEqual(GCE_META.get('instance/id'),
28@@ -126,8 +127,8 @@
29 self.assertEqual(GCE_META_PARTIAL.get('instance/id'),
30 self.ds.get_instance_id())
31
32- self.assertEqual(GCE_META_PARTIAL.get('instance/hostname'),
33- self.ds.get_hostname())
34+ shostname = GCE_META_PARTIAL.get('instance/hostname').split('.')[0]
35+ self.assertEqual(shostname, self.ds.get_hostname())
36
37 @httpretty.activate
38 def test_metadata_encoding(self):