summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-03-14 09:45:11 -0400
committerScott Moser <smoser@ubuntu.com>2016-03-14 09:45:11 -0400
commit97f81cbecf39c340b6c000d62536fcb7f1ef87b0 (patch)
tree7890a7ca3535cd66b22a462acd207fbae2305956 /cloudinit/util.py
parent41470d29f5888baf7ec78e170cc0d6d981dcf63e (diff)
parent001057f01e698c3ca0c078d9535f05fdebec2d80 (diff)
downloadvyos-cloud-init-97f81cbecf39c340b6c000d62536fcb7f1ef87b0.tar.gz
vyos-cloud-init-97f81cbecf39c340b6c000d62536fcb7f1ef87b0.zip
change return value for dmi data of all \xff to be ""
Previously we returned a string of "." the same length as the dmi field. That seems confusing to the user as "." would seem like a valid response when in fact this value should not be considered valid. So now, in this case, return empty string.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 01dc7751..20916e53 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -2148,7 +2148,7 @@ def _read_dmi_syspath(key):
# 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'
+ key_data = b""
str_data = key_data.decode('utf8').strip()
LOG.debug("dmi data %s returned %s", dmi_key_path, str_data)
@@ -2168,6 +2168,9 @@ def _call_dmidecode(key, dmidecode_path):
cmd = [dmidecode_path, "--string", key]
(result, _err) = subp(cmd)
LOG.debug("dmidecode returned '%s' for '%s'", result, key)
+ result = result.strip()
+ if result.replace(".", "") == "":
+ return ""
return result
except (IOError, OSError) as _err:
LOG.debug('failed dmidecode cmd: %s\n%s', cmd, _err.message)