Don't warn on missing dmidecode

Missing dmidecode is only relevant for RSD backend, but the warning will
appear on all systems since this is logged on the get_connector_properties.

We don't really need dmidecode to get the UUID, we can just go and read
the contents of /sys/class/dmi/id/product_uuid

To better support systems that don't have dmidecode in the system, we
will check sysfs first, and then try dmidecode (in case it covers some
additional cases), and log it as a debug level message if dmidecode is
not present.

Closes-Bug: #1811822
Change-Id: Ibfaed6503bd91ad64987deecdc2e9a1471441005
This commit is contained in:
Gorka Eguileor 2019-01-15 13:52:27 +01:00
parent 322554c386
commit 08c8ef4ccf
1 changed files with 13 additions and 16 deletions

View File

@ -47,24 +47,21 @@ class NVMeConnector(base.BaseLinuxConnector):
# RSD requires system_uuid to let Cinder RSD Driver identify
# Nova node for later RSD volume attachment.
try:
out, err = self._execute("dmidecode",
out, err = self._execute('cat', '/sys/class/dmi/id/product_uuid',
root_helper=self._root_helper,
run_as_root=True)
if err:
LOG.warning("dmidecode execute error: %s", err)
return ""
for line in out.split("\n"):
line = line.strip()
if line.startswith("UUID:"):
uuid = line.split(" ")[1]
LOG.debug("got system uuid: %s", uuid)
return uuid
LOG.warning("Cannot get system uuid from %s", out)
return ""
except putils.ProcessExecutionError as e:
LOG.warning("Unable to locate dmidecode. For Cinder RSD Backend, "
"please make sure it is installed: %s", e)
return ""
except putils.ProcessExecutionError:
try:
out, err = self._execute('dmidecode', '-ssystem-uuid',
root_helper=self._root_helper,
run_as_root=True)
if not out:
LOG.warning('dmidecode returned empty system-uuid')
except putils.ProcessExecutionError as e:
LOG.debug("Unable to locate dmidecode. For Cinder RSD Backend,"
" please make sure it is installed: %s", e)
out = ""
return out
@staticmethod
def get_connector_properties(root_helper, *args, **kwargs):