Merge pull request #20693 from rhealitycheck/feature-update-mongo-future-return

Feature update mongo future return and mongo return
This commit is contained in:
Thomas S Hatch 2015-02-13 16:46:09 -07:00
commit 5f8f0a5572
2 changed files with 27 additions and 12 deletions

View file

@ -127,12 +127,18 @@ def returner(ret):
else:
back = ret['return']
if isinstance(ret, dict):
full_ret = _remove_dots(ret)
else:
full_ret = ret
log.debug(back)
sdata = {'minion': ret['id'], 'jid': ret['jid'], 'return': back, 'fun': ret['fun'], 'full_ret': ret}
sdata = {'minion': ret['id'], 'jid': ret['jid'], 'return': back, 'fun': ret['fun'], 'full_ret': full_ret}
if 'out' in ret:
sdata['out'] = ret['out']
# save returns in the saltReturns collection in the json format:
# { 'minion': <minion_name>, 'jid': <job_id>, 'return': <return info with dots removed>, 'fun': <function>, 'full_ret': <unformatted return with dots removed>}
# { 'minion': <minion_name>, 'jid': <job_id>, 'return': <return info with dots removed>,
# 'fun': <function>, 'full_ret': <unformatted return with dots removed>}
mdb.saltReturns.insert(sdata)

View file

@ -126,11 +126,19 @@ def returner(ret):
else:
back = ret['return']
if isinstance(ret, dict):
full_ret = _remove_dots(ret)
else:
full_ret = ret
log.debug(back)
sdata = {ret['jid']: back, 'fun': ret['fun']}
sdata = {'minion': ret['id'], 'jid': ret['jid'], 'return': back, 'fun': ret['fun'], 'full_ret': full_ret}
if 'out' in ret:
sdata['out'] = ret['out']
col.insert(sdata)
# save returns in the saltReturns collection in the json format:
# { 'minion': <minion_name>, 'jid': <job_id>, 'return': <return info with dots removed>,
# 'fun': <function>, 'full_ret': <unformatted return with dots removed>}
mdb.saltReturns.insert(sdata)
def get_jid(jid):
@ -139,10 +147,12 @@ def get_jid(jid):
'''
conn, mdb = _get_conn(ret=None)
ret = {}
for collection in mdb.collection_names():
rdata = mdb[collection].find_one({jid: {'$exists': 'true'}})
if rdata:
ret[collection] = rdata
rdata = mdb.saltReturns.find({'jid': jid})
if rdata:
for data in rdata:
minion = data['minion']
# return data in the format {<minion>: { <unformatted full return data>}}
ret[minion] = data['full_ret']
return ret
@ -152,10 +162,9 @@ def get_fun(fun):
'''
conn, mdb = _get_conn(ret=None)
ret = {}
for collection in mdb.collection_names():
rdata = mdb[collection].find_one({'fun': fun})
if rdata:
ret[collection] = rdata
rdata = mdb.saltReturns.find_one({'fun': fun})
if rdata:
ret = rdata
return ret