1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145 | ------------------------------------------------------------
revno: 1052
fixes bug: https://launchpad.net/bugs/1246485
committer: Scott Moser <smoser@ubuntu.com>
branch nick: trunk.1246485
timestamp: Fri 2015-01-16 14:29:48 -0500
message:
hostname: apply hostname same as is written
on RHEL, we were writing to persistent configuration the fqdn, but
invoking 'hostname' on the first boot with just the shortname. On 'reboot',
then the hostname would differ.
Now, whatever we write, invoke hostname with.
Also remove some duplicate code.
diff:
=== modified file 'ChangeLog'
--- ChangeLog 2015-01-16 18:11:06 +0000
+++ ChangeLog 2015-01-16 19:29:48 +0000
@@ -18,6 +18,8 @@
- GCE: Allow base64 encoded user-data (LP: #1404311) [Wayne Witzell III]
- GCE: use short hostname rather than fqdn (LP: #1383794) [Ben Howard]
- systemd: make init stage run before login prompts shown [Steve Langasek]
+ - hostname: on first boot apply hostname to be same as is written for
+ persistent hostname. (LP: #1246485)
0.7.6:
- open 0.7.6
- Enable vendordata on CloudSigma datasource (LP: #1303986)
=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py 2014-11-25 19:46:10 +0000
+++ cloudinit/distros/__init__.py 2015-01-16 19:29:48 +0000
@@ -86,7 +86,7 @@
def set_hostname(self, hostname, fqdn=None):
writeable_hostname = self._select_hostname(hostname, fqdn)
self._write_hostname(writeable_hostname, self.hostname_conf_fn)
- self._apply_hostname(hostname)
+ self._apply_hostname(writeable_hostname)
@abc.abstractmethod
def package_command(self, cmd, args=None, pkgs=None):
@@ -160,9 +160,12 @@
util.logexc(LOG, "Failed to non-persistently adjust the system "
"hostname to %s", hostname)
- @abc.abstractmethod
def _select_hostname(self, hostname, fqdn):
- raise NotImplementedError()
+ # Prefer the short hostname over the long
+ # fully qualified domain name
+ if not hostname:
+ return fqdn
+ return hostname
@staticmethod
def expand_osfamily(family_list):
=== modified file 'cloudinit/distros/arch.py'
--- cloudinit/distros/arch.py 2014-09-10 18:32:37 +0000
+++ cloudinit/distros/arch.py 2015-01-16 19:29:48 +0000
@@ -118,13 +118,6 @@
return False
return True
- def _select_hostname(self, hostname, fqdn):
- # Prefer the short hostname over the long
- # fully qualified domain name
- if not hostname:
- return fqdn
- return hostname
-
def _write_hostname(self, your_hostname, out_fn):
conf = None
try:
=== modified file 'cloudinit/distros/debian.py'
--- cloudinit/distros/debian.py 2014-09-10 18:32:37 +0000
+++ cloudinit/distros/debian.py 2015-01-16 19:29:48 +0000
@@ -86,13 +86,6 @@
else:
return distros.Distro._bring_up_interfaces(self, device_names)
- def _select_hostname(self, hostname, fqdn):
- # Prefer the short hostname over the long
- # fully qualified domain name
- if not hostname:
- return fqdn
- return hostname
-
def _write_hostname(self, your_hostname, out_fn):
conf = None
try:
=== modified file 'cloudinit/distros/freebsd.py'
--- cloudinit/distros/freebsd.py 2015-01-06 17:02:38 +0000
+++ cloudinit/distros/freebsd.py 2015-01-16 19:29:48 +0000
@@ -150,11 +150,6 @@
return default
return hostname
- def _select_hostname(self, hostname, fqdn):
- if not hostname:
- return fqdn
- return hostname
-
def _write_hostname(self, hostname, filename):
self.updatercconf('hostname', hostname)
=== modified file 'cloudinit/distros/gentoo.py'
--- cloudinit/distros/gentoo.py 2014-09-10 18:32:37 +0000
+++ cloudinit/distros/gentoo.py 2015-01-16 19:29:48 +0000
@@ -97,13 +97,6 @@
else:
return distros.Distro._bring_up_interfaces(self, device_names)
- def _select_hostname(self, hostname, fqdn):
- # Prefer the short hostname over the long
- # fully qualified domain name
- if not hostname:
- return fqdn
- return hostname
-
def _write_hostname(self, your_hostname, out_fn):
conf = None
try:
=== modified file 'cloudinit/distros/sles.py'
--- cloudinit/distros/sles.py 2014-01-23 19:06:13 +0000
+++ cloudinit/distros/sles.py 2015-01-16 19:29:48 +0000
@@ -115,13 +115,6 @@
conf.set_hostname(hostname)
util.write_file(out_fn, str(conf), 0644)
- def _select_hostname(self, hostname, fqdn):
- # Prefer the short hostname over the long
- # fully qualified domain name
- if not hostname:
- return fqdn
- return hostname
-
def _read_system_hostname(self):
host_fn = self.hostname_conf_fn
return (host_fn, self._read_hostname(host_fn))
|