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
1diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py
2index 13fb7c6..ea05c4d 100644
3--- a/cloudinit/sources/__init__.py
4+++ b/cloudinit/sources/__init__.py
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:

Subscribers

People subscribed via source and target branches