From aa3e33bb32e179a0a69e0819f20ed7857a1e448b Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Fri, 9 Jun 2017 14:19:28 -0700 Subject: [PATCH] Shuffling things around and adding the ability to return an event on the event bus when a runner function is unavailale --- salt/runner.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/salt/runner.py b/salt/runner.py index a010bfdf0f..aabfd3905f 100644 --- a/salt/runner.py +++ b/salt/runner.py @@ -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)