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

Proposed by Lars Kellogg-Stedman
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/__init__.py (+2/-0)
Reviewer Review Type Date Requested Status
Scott Moser Pending
Review via email: mp+312612@code.launchpad.net

Description of the change

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

  127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

Then in sources/__init__.py 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.
Revision history for this message
Scott Moser (smoser) wrote :

one question inline

Revision history for this message
Lars Kellogg-Stedman (larsks) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py
index 13fb7c6..ea05c4d 100644
--- a/cloudinit/sources/__init__.py
+++ b/cloudinit/sources/__init__.py
@@ -194,6 +194,8 @@ class DataSource(object):
194 fqdn = util.get_fqdn_from_hosts(hostname)194 fqdn = util.get_fqdn_from_hosts(hostname)
195 if fqdn and fqdn.find(".") > 0:195 if fqdn and fqdn.find(".") > 0:
196 toks = str(fqdn).split(".")196 toks = str(fqdn).split(".")
197 elif hostname and hostname.find(".") > 0:
198 toks = str(hostname).split(".")
197 elif hostname:199 elif hostname:
198 toks = [hostname, defdomain]200 toks = [hostname, defdomain]
199 else:201 else:

Subscribers

People subscribed via source and target branches