warn on failure of the hostname command when setting hostname

This commit is contained in:
Scott Moser 2011-09-01 10:16:36 -04:00
parent 963b164d56
commit 415b2e47e4
2 changed files with 3 additions and 2 deletions

View File

@ -47,6 +47,7 @@
- change the mechanism for handling .ssh/authorized_keys, to update entries
rather than appending. This ensures that the authorized_keys that are being
inserted actually do something (LP: #434076, LP: #833499)
- log warning on failure to set hostname (LP: #832175)
0.6.1:
- fix bug in fixing permission on /var/log/cloud-init.log (LP: #704509)

View File

@ -28,11 +28,11 @@ def handle(name,cfg,cloud,log,args):
set_hostname(hostname, log)
except Exception as e:
util.logexc(log)
log.warn("failed to set hostname\n")
log.warn("failed to set hostname to %s\n", hostname)
return(True)
def set_hostname(hostname, log):
subprocess.Popen(['hostname', hostname]).communicate()
util.subp(['hostname', hostname])
util.write_file("/etc/hostname","%s\n" % hostname, 0644)
log.debug("populated /etc/hostname with %s on first boot", hostname)