From fe1ec4d4cbb682731e8f65be5dab60f4593ed9d6 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 10 Oct 2012 16:59:40 -0700 Subject: Add comment explaining why the '_apply_hostname' function will not be permanent and catch the exception that occurs if it fails and log that instead of blowing up (which isn't typically useful for something that is temporary anyway). --- cloudinit/distros/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 07f03159..c6427401 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -128,8 +128,16 @@ class Distro(object): raise NotImplementedError() def _apply_hostname(self, hostname): - LOG.debug("Setting system hostname to %s", hostname) - util.subp(['hostname', hostname]) + # This really only sets the hostname + # temporarily (until reboot so it should + # not be depended on). Use the write + # hostname functions for 'permanent' adjustments. + LOG.debug("Temporarily setting the system hostname to %s", hostname) + try: + util.subp(['hostname', hostname]) + except util.ProcessExecutionError: + util.logexc(LOG, ("Failed to temporarily adjust" + " the system hostname to %s"), hostname) def update_hostname(self, hostname, prev_hostname_fn): if not hostname: -- cgit v1.2.3