mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #38929 from MTecknology/2016.11
Fix psutil regressions in 2016.11
This commit is contained in:
commit
de3b2cc97b
2 changed files with 7 additions and 3 deletions
|
@ -46,8 +46,6 @@ try:
|
|||
HAS_PSUTIL = True
|
||||
except ImportError:
|
||||
HAS_PSUTIL = False
|
||||
import platform
|
||||
import salt.grains.core
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -76,10 +74,13 @@ def _gather_buffer_space():
|
|||
|
||||
Result is in bytes.
|
||||
'''
|
||||
if HAS_PSUTIL:
|
||||
if HAS_PSUTIL and psutil.version_info >= (0, 6, 0):
|
||||
# Oh good, we have psutil. This will be quick.
|
||||
total_mem = psutil.virtual_memory().total
|
||||
else:
|
||||
# Avoid loading core grains unless absolutely required
|
||||
import platform
|
||||
import salt.grains.core
|
||||
# We need to load up ``mem_total`` grain. Let's mimic required OS data.
|
||||
os_data = {'kernel': platform.system()}
|
||||
grains = salt.grains.core._memdata(os_data)
|
||||
|
|
|
@ -496,6 +496,9 @@ def total_physical_memory():
|
|||
|
||||
salt '*' ps.total_physical_memory
|
||||
'''
|
||||
if psutil.version_info < (0, 6, 0):
|
||||
msg = 'virtual_memory is only available in psutil 0.6.0 or greater'
|
||||
raise CommandExecutionError(msg)
|
||||
try:
|
||||
return psutil.virtual_memory().total
|
||||
except AttributeError:
|
||||
|
|
Loading…
Add table
Reference in a new issue