Shuffling things around and adding the ability to return an event on the event bus when a runner function is unavailale

This commit is contained in:
Gareth J. Greenaway 2017-06-09 14:19:28 -07:00
parent 6f392c5301
commit aa3e33bb32

View File

@ -175,6 +175,10 @@ class Runner(RunnerClient):
else:
low = {'fun': self.opts['fun']}
try:
# Allocate a jid
async_pub = self._gen_async_pub()
self.jid = async_pub['jid']
verify_fun(self.functions, low['fun'])
args, kwargs = salt.minion.load_args_and_kwargs(
self.functions[low['fun']],
@ -216,10 +220,6 @@ class Runner(RunnerClient):
else:
user = salt.utils.get_specific_user()
# Allocate a jid
async_pub = self._gen_async_pub()
self.jid = async_pub['jid']
if low['fun'] == 'state.orchestrate':
low['kwarg']['orchestration_jid'] = async_pub['jid']
@ -256,6 +256,13 @@ class Runner(RunnerClient):
async_pub['jid'],
daemonize=False)
except salt.exceptions.SaltException as exc:
evt = salt.utils.event.get_event('master', opts=self.opts)
evt.fire_event({'success': False,
'comment': 'Runner function {0} is not '
'available'.format(low['fun']),
'fun': low['fun'],
'jid': self.jid},
tag='salt/run/{0}/ret'.format(self.jid))
ret = '{0}'.format(exc)
if not self.opts.get('quiet', False):
display_output(ret, 'nested', self.opts)