From 08c8ef4ccf187a287d2714c5d528b22f7939446b Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Tue, 15 Jan 2019 13:52:27 +0100 Subject: [PATCH] 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 --- os_brick/initiator/connectors/nvme.py | 29 ++++++++++++--------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/os_brick/initiator/connectors/nvme.py b/os_brick/initiator/connectors/nvme.py index 0acac615e..6dff6f3dd 100644 --- a/os_brick/initiator/connectors/nvme.py +++ b/os_brick/initiator/connectors/nvme.py @@ -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):