Merge ~larsks/cloud-init:bug/1647910 into cloud-init:master

Proposed by Lars Kellogg-Stedman on 2016-12-07
Status: Merged
Merged at revision: c01129492f046fdf745b432b6035605c9c613655
Proposed branch: ~larsks/cloud-init:bug/1647910
Merge into: cloud-init:master
Diff against target: 13 lines (+2/-0)
1 file modified
cloudinit/sources/ (+2/-0)
Reviewer Review Type Date Requested Status
Scott Moser 2016-12-07 Pending
Review via email:

Description of the change

If no data source is available and the local hostname is set to "localhost.localdomain", and /etc/hosts looks like: localhost localhost.localdomain localhost4 localhost4.localdomain4

Then in sources/ in get_hostname:

- util.get_hostname() will return 'localhost.localdomain'
- util.get_fqdn_from_hosts(hostname) will return 'localhost'
- 'toks' will be set to [ 'localhost.localdomain', 'localdomain'

And ultimately the system hostname will be set to 'localhost.localdomain.localdomain', which isn't useful to anybody.

To post a comment you must log in.
Scott Moser (smoser) wrote :

one question inline

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/sources/ b/cloudinit/sources/
2index 13fb7c6..ea05c4d 100644
3--- a/cloudinit/sources/
4+++ b/cloudinit/sources/
5@@ -194,6 +194,8 @@ class DataSource(object):
6 fqdn = util.get_fqdn_from_hosts(hostname)
7 if fqdn and fqdn.find(".") > 0:
8 toks = str(fqdn).split(".")
9+ elif hostname and hostname.find(".") > 0:
10+ toks = str(hostname).split(".")
11 elif hostname:
12 toks = [hostname, defdomain]
13 else:


People subscribed via source and target branches