← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~smoser/cloud-init/trunk.dmidecode-null into lp:cloud-init

 

Scott Moser has proposed merging lp:~smoser/cloud-init/trunk.dmidecode-null into lp:cloud-init.

Commit message:
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.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~smoser/cloud-init/trunk.dmidecode-null/+merge/288925
-- 
Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.dmidecode-null into lp:cloud-init.
=== modified file 'cloudinit/util.py'
--- cloudinit/util.py	2016-03-10 21:56:44 +0000
+++ cloudinit/util.py	2016-03-14 13:23:26 +0000
@@ -2148,7 +2148,7 @@
         # 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 @@
 
     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)

=== modified file 'tests/unittests/test_util.py'
--- tests/unittests/test_util.py	2016-03-10 21:56:44 +0000
+++ tests/unittests/test_util.py	2016-03-14 13:23:26 +0000
@@ -389,7 +389,7 @@
         # 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)


References