summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-03-14 09:21:02 -0400
committerScott Moser <smoser@ubuntu.com>2016-03-14 09:21:02 -0400
commit03f80fa62eb85270a7a96850c5e689a1c4bc0049 (patch)
tree2be047c5111118b18f6c959db7e5e264c7d5958e /cloudinit/util.py
parentbe38478cd8e11b0e29c70bb881a676628e9f74d5 (diff)
downloadvyos-cloud-init-03f80fa62eb85270a7a96850c5e689a1c4bc0049.tar.gz
vyos-cloud-init-03f80fa62eb85270a7a96850c5e689a1c4bc0049.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.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 1a517c79..caae17ce 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)
@@ -2193,7 +2193,10 @@ def read_dmi_data(key):
dmidecode_path = which('dmidecode')
if dmidecode_path:
- return _call_dmidecode(key, dmidecode_path)
+ ret = _call_dmidecode(key, dmidecode_path)
+ if ret is not None and ret.replace(".", "") == "":
+ return ""
+ return ret
LOG.warn("did not find either path %s or dmidecode command",
DMI_SYS_PATH)