mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
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:
commit
650674d14a
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user