summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-03-14 09:53:04 -0400
committerScott Moser <smoser@ubuntu.com>2016-03-14 09:53:04 -0400
commit14c88d8c28a044776d011ed507f8f6465ec3e2c7 (patch)
tree2416265247ea39db4abb625fa36436a815d90f47
parent24bd640d20383116d1285361d7e86eda9e9d20e8 (diff)
parent8a929e66f2fe2aaed968ec23aeaf6d3b3c68cb65 (diff)
downloadvyos-cloud-init-14c88d8c28a044776d011ed507f8f6465ec3e2c7.tar.gz
vyos-cloud-init-14c88d8c28a044776d011ed507f8f6465ec3e2c7.zip
merge with trunk for dmidecode changes
-rw-r--r--cloudinit/util.py5
-rw-r--r--tests/unittests/test_util.py2
2 files changed, 5 insertions, 2 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)
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
index 0a986fec..37a984ac 100644
--- a/tests/unittests/test_util.py
+++ b/tests/unittests/test_util.py
@@ -389,7 +389,7 @@ class TestReadDMIData(helpers.FilesystemMockingTestCase):
# uninitialized dmi values show as \xff, return those as .
my_len = 32
dmi_value = b'\xff' * my_len + b'\n'
- expected = '.' * my_len
+ expected = ""
dmi_key = 'system-product-name'
sysfs_key = 'product_name'
self._create_sysfs_file(sysfs_key, dmi_value)