summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-03-11 10:35:54 -0500
committerScott Moser <smoser@ubuntu.com>2016-03-11 10:35:54 -0500
commitff47d211d507359ad508caafdb413ab9071cd165 (patch)
tree42acc467709c822b0502f819162a82cfc9321755 /cloudinit/util.py
parent781ded8127deefb49a8806e49bdb7bb6e4d4b245 (diff)
parent41470d29f5888baf7ec78e170cc0d6d981dcf63e (diff)
downloadvyos-cloud-init-ff47d211d507359ad508caafdb413ab9071cd165.tar.gz
vyos-cloud-init-ff47d211d507359ad508caafdb413ab9071cd165.zip
merge with trunk
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index e7407ea4..01dc7751 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -2140,13 +2140,19 @@ def _read_dmi_syspath(key):
LOG.debug("did not find %s", dmi_key_path)
return None
- key_data = load_file(dmi_key_path)
+ key_data = load_file(dmi_key_path, decode=False)
if not key_data:
LOG.debug("%s did not return any data", dmi_key_path)
return None
- LOG.debug("dmi data %s returned %s", dmi_key_path, key_data)
- return key_data.strip()
+ # uninitialized dmi values show as all \xff and /sys appends a '\n'.
+ # in that event, return a string of '.' in the same length.
+ if key_data == b'\xff' * (len(key_data) - 1) + b'\n':
+ key_data = b'.' * (len(key_data) - 1) + b'\n'
+
+ str_data = key_data.decode('utf8').strip()
+ LOG.debug("dmi data %s returned %s", dmi_key_path, str_data)
+ return str_data
except Exception:
logexc(LOG, "failed read of %s", dmi_key_path)