summaryrefslogtreecommitdiff
path: root/cloudinit/distros/__init__.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-10-10 16:59:40 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-10-10 16:59:40 -0700
commitfe1ec4d4cbb682731e8f65be5dab60f4593ed9d6 (patch)
tree719a37911c99f9793604b3eebe4de9fc2167b1ae /cloudinit/distros/__init__.py
parentb2901994e4310c255a6edf64dcf35c7bf12295ef (diff)
downloadvyos-cloud-init-fe1ec4d4cbb682731e8f65be5dab60f4593ed9d6.tar.gz
vyos-cloud-init-fe1ec4d4cbb682731e8f65be5dab60f4593ed9d6.zip
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).
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r--cloudinit/distros/__init__.py12
1 files 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: