Merge pull request #23399 from mattrobenolt/expose-grains

Add salt.loader.grain_funcs
This commit is contained in:
Thomas S Hatch 2015-05-08 08:37:30 -06:00
commit bfcee39e99
2 changed files with 24 additions and 4 deletions

View File

@ -67,6 +67,8 @@ Each module type has a corresponding loader function.
.. autofunction:: salt.loader.grains
.. autofunction:: salt.loader.grain_funcs
Salt's Client Interfaces
========================

View File

@ -441,6 +441,27 @@ def render(opts, functions, states=None):
return rend
def grain_funcs(opts):
'''
Returns the grain functions
.. code-block:: python
import salt.config
import salt.loader
__opts__ = salt.config.minion_config('/etc/salt/minion')
grainfuncs = salt.loader.grain_funcs(__opts__)
'''
return LazyLoader(_module_dirs(opts,
'grains',
'grain',
ext_type_dirs='grains_dirs'),
opts,
tag='grains',
)
def grains(opts, force_refresh=False):
'''
Return the functions for the dynamic grains and the values for the static
@ -513,10 +534,7 @@ def grains(opts, force_refresh=False):
opts['grains'] = {}
grains_data = {}
funcs = LazyLoader(_module_dirs(opts, 'grains', 'grain', ext_type_dirs='grains_dirs'),
opts,
tag='grains',
)
funcs = grain_funcs(opts)
if force_refresh: # if we refresh, lets reload grain modules
funcs.clear()
# Run core grains