Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Changed lookup_jid runner to return empty dict instead of an exception #2209

Merged
merged 1 commit into from

2 participants

@whiteinge
Owner

No description provided.

@thatch45
Owner

Lets talk about this when you get in

@thatch45 thatch45 merged commit 498a242 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 34 deletions.
  1. +5 −32 salt/runners/jobs.py
  2. +1 −2  tests/integration/runners/jobs.py
View
37 salt/runners/jobs.py
@@ -58,41 +58,14 @@ def lookup_jid(jid):
'''
Return the printout from a previously executed job
'''
- def _format_ret(full_ret):
- '''
- Take the full return data and format it to simple output
- '''
- out = None
- ret = {}
- for key, data in full_ret.items():
- ret[key] = data['ret']
- if 'out' in data:
- out = data['out']
- return ret, out
-
client = salt.client.LocalClient(__opts__['conf_file'])
- full_ret = client.get_full_returns(jid, [], 0)
- formatted = _format_ret(full_ret)
- if all(formatted):
- ret = formatted[0]
- out = formatted[1]
- else:
- ret = SaltException(
- 'Job {0} hasn\'t finished. No data yet :('.format(jid)
- )
- out = ''
+ ret = {}
+ for mid, data in client.get_full_returns(jid, [], 0).items():
+ printout = salt.output.get_outputter(data.get('out', None))
+ ret[mid] = data.get('ret')
+ printout({mid: ret[mid]})
- # Determine the proper output method and run it
- get_outputter = salt.output.get_outputter
- if isinstance(ret, (list, dict, string_types)) and out:
- printout = get_outputter(out)
- # Pretty print any salt exceptions
- elif isinstance(ret, SaltException):
- printout = get_outputter("txt")
- else:
- printout = get_outputter(None)
- printout(ret)
return ret
View
3  tests/integration/runners/jobs.py
@@ -27,8 +27,7 @@ def test_lookup_jid(self):
jobs.lookup_jid
'''
ret = self.run_run_plus('jobs.lookup_jid', '', '23974239742394')
- self.assertTrue(str(ret['fun']).startswith('Job 23974239742394'))
- self.assertFalse(ret['out'][1])
+ self.assertFalse(ret['out'][0])
def test_list_jobs(self):
'''
Something went wrong with that request. Please try again.