Update mongo_future_return.py

This commit is contained in:
rhealitycheck 2015-09-24 09:09:11 -05:00 committed by rallytime
parent 540b3f2690
commit b7ddc83b4d

View file

@ -129,11 +129,11 @@ def _get_conn(ret):
user = _options.get('user')
password = _options.get('password')
indexes = _options.get('indexes', False)
'''
at some point we should remove support for
pymongo versions < 2.3 until then there are
a bunch of these sections that need to be supported
'''
# at some point we should remove support for
# pymongo versions < 2.3 until then there are
# a bunch of these sections that need to be supported
if float(version) > 2.3:
conn = pymongo.MongoClient(host, port)
else:
@ -152,7 +152,7 @@ def _get_conn(ret):
mdb.saltReturns.ensure_index('minion')
mdb.saltReturns.ensure_index('jid')
mdb.jobs.ensure_index('jid')
return conn, mdb
@ -176,13 +176,13 @@ def returner(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>}
again we run into the issue with deprecated code from previous versions
'''
# 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>}
#
# again we run into the issue with deprecated code from previous versions
if float(version) > 2.3:
#using .copy() to ensure that the original data is not changed, raising issue with pymongo team
mdb.saltReturns.insert_one(sdata.copy())