Add initial code for external job cache

This commit is contained in:
Thomas S Hatch 2012-10-31 16:48:00 -06:00
parent 16640a8284
commit 556d108ef5

View File

@ -10,11 +10,9 @@ import salt.client
import salt.payload
import salt.utils
import salt.output
from salt._compat import string_types
from salt.exceptions import SaltException
# Import Third party libs
import yaml
import salt.minion
#from salt._compat import string_types
#from salt.exceptions import SaltException
def active():
@ -51,14 +49,20 @@ def active():
continue
if os.path.exists(os.path.join(jid_dir, minion)):
ret[jid]['Returned'].append(minion)
print(yaml.dump(ret))
salt.output.display_output(ret, 'yaml')
return ret
def lookup_jid(jid):
def lookup_jid(jid, ext_source=None):
'''
Return the printout from a previously executed job
'''
if __opts__['ext_job_cache'] or ext_source:
returner = ext_source if ext_source else __opts__['ext_job_cache']
mminion = salt.minion.MasterMinion(__opts__)
return mminion.returners['{0}.get_jid'.format(returner)](jid)
# Fall back to the local job cache
client = salt.client.LocalClient(__opts__['conf_file'])
ret = {}
@ -89,7 +93,7 @@ def list_jobs():
'Arguments': list(load['arg']),
'Target': load['tgt'],
'Target-type': load['tgt_type']}
print(yaml.dump(ret))
salt.output.display_output(ret, 'yaml')
return ret
def print_job(job_id):