Merge pull request #34844 from vutny/fix-grains-load-in-config-init

Fix getting total available memory without `psutil` installed
This commit is contained in:
Mike Place 2016-07-21 11:12:37 -06:00 committed by GitHub
commit 650674d14a
2 changed files with 4 additions and 3 deletions

View File

@ -86,7 +86,7 @@
# Set the default output file used by the salt command. Default is to output
# to the CLI and not to a file. Functions the same way as the "--out-file"
CLI option, only sets this to a single file for all salt commands.
# CLI option, only sets this to a single file for all salt commands.
#output_file: None
# Return minions that timeout when running commands like test.ping

View File

@ -47,6 +47,7 @@ try:
HAS_PSUTIL = True
except ImportError:
HAS_PSUTIL = False
import platform
import salt.grains.core
log = logging.getLogger(__name__)
@ -80,8 +81,8 @@ def _gather_buffer_space():
# Oh good, we have psutil. This will be quick.
total_mem = psutil.virtual_memory().total
else:
# We need to load up some grains. This will be slow.
os_data = salt.grains.core.os_data()
# 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)
total_mem = grains['mem_total']
# Return the higher number between 5% of the system memory and 100MB