add code to cache jobs on the minion if option is set

This commit is contained in:
Thomas S Hatch 2012-01-17 23:45:42 -07:00
parent f63a38d025
commit b2151521bb
2 changed files with 16 additions and 2 deletions

View File

@ -80,6 +80,7 @@ def minion_config(path):
'pki_dir': '/etc/salt/pki',
'id': socket.getfqdn(),
'cachedir': '/var/cache/salt',
'cache_jobs': False,
'conf_file': path,
'renderer': 'yaml_jinja',
'failhard': False,

View File

@ -312,8 +312,21 @@ class Minion(object):
except KeyError:
pass
payload['load'] = self.crypticle.dumps(load)
socket.send(self.serial.dumps(payload))
return socket.recv()
data = self.serial.dumps(payload)
socket.send(data)
ret = socket.recv()
if self.opts['cache_jobs']:
# Local job cache has been enabled
fn_ = os.path.join(
self.opts['cachedir'],
'minion_jobs',
load['jid'],
'return.p')
jdir = os.path.dirname(fn_)
if not os.path.isdir(jdir):
os.makedirs(jdir)
open(fn_, 'w+').write(load)
return ret
def authenticate(self):
'''