mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Load core grains only if required.
As per discussion on github, these grains should only be loaded if absolutely required.
This commit is contained in:
parent
4966011cb5
commit
73a8c6d121
1 changed files with 3 additions and 2 deletions
|
@ -15,7 +15,6 @@ import codecs
|
|||
import logging
|
||||
from copy import deepcopy
|
||||
import types
|
||||
import platform
|
||||
|
||||
# Import third party libs
|
||||
import yaml
|
||||
|
@ -41,7 +40,6 @@ import salt.utils.xdg
|
|||
import salt.exceptions
|
||||
from salt.utils.locales import sdecode
|
||||
import salt.defaults.exitcodes
|
||||
import salt.grains.core
|
||||
|
||||
try:
|
||||
import psutil
|
||||
|
@ -80,6 +78,9 @@ def _gather_buffer_space():
|
|||
# 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)
|
||||
|
|
Loading…
Add table
Reference in a new issue