diff options
author | Scott Moser <smoser@ubuntu.com> | 2011-01-24 18:59:32 +0000 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2011-01-24 18:59:32 +0000 |
commit | 0b7f896201348ab791e89bb9f736d62a2941c14d (patch) | |
tree | 2c8f23a6551fbf8b6062aaa56c5454a6c3d615d5 /cloudinit/CloudConfig/cc_update_hostname.py | |
parent | 733c43becee50e29350f17f4b49b4e5a823e6f4f (diff) | |
download | vyos-cloud-init-0b7f896201348ab791e89bb9f736d62a2941c14d.tar.gz vyos-cloud-init-0b7f896201348ab791e89bb9f736d62a2941c14d.zip |
cc_update_hostname: fix error handling
Diffstat (limited to 'cloudinit/CloudConfig/cc_update_hostname.py')
-rw-r--r-- | cloudinit/CloudConfig/cc_update_hostname.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cloudinit/CloudConfig/cc_update_hostname.py b/cloudinit/CloudConfig/cc_update_hostname.py index 6d92157a..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,7 +51,7 @@ 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, prev_file, log): @@ -61,9 +62,9 @@ def update_hostname(hostname, prev_file, 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: |