diff options
author | Scott Moser <smoser@ubuntu.com> | 2011-01-24 14:03:01 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2011-01-24 14:03:01 -0500 |
commit | b9b0a79b5a1b142b9e1176d64f294cf9c9f84157 (patch) | |
tree | 35e2bf3d87a451fdb1c87b8cbfa1216e46813126 /cloudinit/CloudConfig | |
parent | 9ebce731fe86e534ecb2bedca6dea27ce5179f44 (diff) | |
parent | 0b7f896201348ab791e89bb9f736d62a2941c14d (diff) | |
download | vyos-cloud-init-b9b0a79b5a1b142b9e1176d64f294cf9c9f84157.tar.gz vyos-cloud-init-b9b0a79b5a1b142b9e1176d64f294cf9c9f84157.zip |
merge in fixes to get to functioning point
Diffstat (limited to 'cloudinit/CloudConfig')
-rw-r--r-- | cloudinit/CloudConfig/cc_update_hostname.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/cloudinit/CloudConfig/cc_update_hostname.py b/cloudinit/CloudConfig/cc_update_hostname.py index c06a434b..3663c0ab 100644 --- a/cloudinit/CloudConfig/cc_update_hostname.py +++ b/cloudinit/CloudConfig/cc_update_hostname.py @@ -17,6 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import cloudinit.util as util import subprocess +import errno from cloudinit.CloudConfig import per_always frequency = per_always @@ -50,10 +51,10 @@ def read_hostname(filename, default=None): if line: return line except IOError, e: - if e.errno == errno.ENOENT: pass + if e.errno != errno.ENOENT: raise return default -def update_hostname(hostname, previous, log): +def update_hostname(hostname, prev_file, log): etc_file = "/etc/hostname" hostname_prev = None @@ -61,9 +62,9 @@ def update_hostname(hostname, previous, log): try: hostname_prev = read_hostname(prev_file) - except: - log.warn("Failed to open %s" % prev_file) - + except Exception, e: + log.warn("Failed to open %s: %s" % (prev_file, e)) + try: hostname_in_etc = read_hostname(etc_file) except: |