Fix dmidecode grains

This fixes #22033
This commit is contained in:
Mathieu Le Marec - Pasquet 2015-03-26 13:40:40 +01:00
parent 0e91175992
commit 2fe7340c77

View File

@ -19,6 +19,7 @@ import re
import platform
import logging
import locale
import salt.exceptions
# Extend the default list of supported distros. This will be used for the
# /etc/DISTRO-release checking that is part of platform.linux_distribution()
@ -1577,11 +1578,17 @@ def _dmidecode_data(regex_dict):
return {}
# No use running if dmidecode/smbios isn't in the path
if salt.utils.which('dmidecode'):
out = __salt__['cmd.run']('dmidecode')
elif salt.utils.which('smbios'):
out = __salt__['cmd.run']('smbios')
else:
no_dmidecode = False
try:
if salt.utils.which('dmidecode'):
out = __salt__['cmd.run']('dmidecode')
elif salt.utils.which('smbios'):
out = __salt__['cmd.run']('smbios')
else:
no_dmidecode = True
except (salt.exceptions.CommandExecutionError,) as exc:
no_dmidecode = True
if no_dmidecode:
log.debug(
'The `dmidecode` binary is not available on the system. GPU '
'grains will not be available.'