Move to a class variable (and rename)

This commit is contained in:
Thomas Jackson 2014-02-28 15:45:09 -08:00
parent 089ea74928
commit 5a087e412d

View File

@ -595,10 +595,13 @@ class ReactWrap(object):
'''
Create a wrapper that executes low data for the reaction system
'''
# class-wide cache of clients
client_cache = None
def __init__(self, opts):
self.opts = opts
self.cachedict = salt.utils.cache.CacheDict(opts['reactor_refresh_interval'])
if ReactWrap.client_cache is None:
ReactWrap.client_cache = salt.utils.cache.CacheDict(opts['reactor_refresh_interval'])
def run(self, low):
'''
@ -621,25 +624,25 @@ class ReactWrap(object):
'''
Wrap LocalClient for running :ref:`execution modules <all-salt.modules>`
'''
if 'local' not in self.cachedict:
self.cachedict['local'] = salt.client.LocalClient(self.opts['conf_file'])
return self.cachedict['local'].cmd_async(*args, **kwargs)
if 'local' not in self.client_cache:
self.client_cache['local'] = salt.client.LocalClient(self.opts['conf_file'])
return self.client_cache['local'].cmd_async(*args, **kwargs)
def runner(self, fun, **kwargs):
'''
Wrap RunnerClient for executing :ref:`runner modules <all-salt.runners>`
'''
if 'runner' not in self.cachedict:
self.cachedict['runner'] = salt.runner.RunnerClient(self.opts)
return self.cachedict['runner'].low(fun, kwargs)
if 'runner' not in self.client_cache:
self.client_cache['runner'] = salt.runner.RunnerClient(self.opts)
return self.client_cache['runner'].low(fun, kwargs)
def wheel(self, fun, **kwargs):
'''
Wrap Wheel to enable executing :ref:`wheel modules <all-salt.wheel>`
'''
if 'wheel' not in self.cachedict:
self.cachedict['wheel'] = salt.wheel.Wheel(self.opts)
return self.cachedict['wheel'].call_func(fun, **kwargs)
if 'wheel' not in self.client_cache:
self.client_cache['wheel'] = salt.wheel.Wheel(self.opts)
return self.client_cache['wheel'].call_func(fun, **kwargs)
class StateFire(object):