Fix pyobjects renderer to use new loader

This commit is contained in:
Thomas Jackson 2015-02-02 13:38:57 -08:00
parent 6cd7cee87b
commit f47663a59e

View File

@ -266,7 +266,8 @@ import re
from salt.ext.six import exec_
import salt.utils
from salt.loader import _create_loader
import salt.loader
from salt.fileclient import get_file_client
from salt.utils.pyobjects import Registry, StateFactory, SaltObject, Map
@ -293,23 +294,12 @@ def load_states():
__opts__['grains'] = __grains__
__opts__['pillar'] = __pillar__
# we need to build our own loader so that we can process the virtual names
# in our own way.
load = _create_loader(__opts__, 'states', 'states')
load.load_modules()
for mod in load.modules:
module_name = mod.__name__.rsplit('.', 1)[-1]
(virtual_ret, virtual_name, _) = load.process_virtual(mod, module_name)
# if the module returned a True value and a new name use that
# otherwise use the default module name
if virtual_ret and virtual_name != module_name:
module_name = virtual_name
# load our functions from the module, pass None in as the module_name
# so that our function names come back unprefixed
states[module_name] = load.load_functions(mod, None)
# TODO: some way to lazily do this? This requires loading *all* state modules
for key, func in salt.loader.states(__opts__, __salt__).iteritems():
mod_name, func_name = key.split('.', 1)
if mod_name not in states:
states[mod_name] = {}
states[mod_name][func_name] = func
__context__['pyobjects_states'] = states