diff options
author | Riccardo Pittau <elfosardo@gmail.com> | 2020-04-23 16:32:23 +0200 |
---|---|---|
committer | Riccardo Pittau <elfosardo@gmail.com> | 2020-04-27 15:07:54 +0200 |
commit | 8d210638a8f69766f64a173bf34250c12aa326fd (patch) | |
tree | 75cd3a7290fe54ca171270ba10848b84b2747183 /ironic_python_agent/hardware.py | |
parent | 2738e57f2a6cacd44cf78331d6d77f3ae9f6a254 (diff) | |
download | ironic-python-agent-8d210638a8f69766f64a173bf34250c12aa326fd.tar.gz |
Fix TypeError with newer version of lshw
The issue with json output in lshw was fixed in version B.02.19
This patch makes the memory calculation compatible with that
version and later versions that are included in recent distributions
(e.g. Ubuntu 20.04, Fedora 31)
Change-Id: Id5a30028b139c51cae6232cac73a50b917fea233
Story: 2007588
Task: 39527
Diffstat (limited to 'ironic_python_agent/hardware.py')
-rw-r--r-- | ironic_python_agent/hardware.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 71e0c287..ea54300a 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -1003,13 +1003,14 @@ class GenericHardwareManager(HardwareManager): total = None LOG.exception(("Cannot fetch total memory size using psutil " "version %s"), psutil.version_info[0]) - sys_dict = None try: sys_dict = _get_system_lshw_dict() except (processutils.ProcessExecutionError, OSError, ValueError) as e: LOG.warning('Could not get real physical RAM from lshw: %s', e) physical = None else: + if isinstance(sys_dict, str): + sys_dict = json.loads(sys_dict) physical = _calc_memory(sys_dict) if not physical: |