mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #32450 from cachedout/issue_31738
Pass parser options into batch mode
This commit is contained in:
commit
7bf44aea72
3 changed files with 13 additions and 2 deletions
|
@ -26,12 +26,13 @@ class Batch(object):
|
|||
'''
|
||||
Manage the execution of batch runs
|
||||
'''
|
||||
def __init__(self, opts, eauth=None, quiet=False):
|
||||
def __init__(self, opts, eauth=None, quiet=False, parser=None):
|
||||
self.opts = opts
|
||||
self.eauth = eauth if eauth else {}
|
||||
self.quiet = quiet
|
||||
self.local = salt.client.get_local_client(opts['conf_file'])
|
||||
self.minions, self.ping_gen = self.__gather_minions()
|
||||
self.options = parser
|
||||
|
||||
def __gather_minions(self):
|
||||
'''
|
||||
|
@ -96,6 +97,11 @@ class Batch(object):
|
|||
ret = {}
|
||||
iters = []
|
||||
|
||||
if self.options:
|
||||
show_jid = self.options.show_jid
|
||||
else:
|
||||
show_jid = False
|
||||
|
||||
# the minion tracker keeps track of responses and iterators
|
||||
# - it removes finished iterators from iters[]
|
||||
# - if a previously detected minion does not respond, its
|
||||
|
@ -131,6 +137,7 @@ class Batch(object):
|
|||
*args,
|
||||
raw=self.opts.get('raw', False),
|
||||
ret=self.opts.get('return', ''),
|
||||
show_jid=show_jid,
|
||||
**self.eauth)
|
||||
# add it to our iterators and to the minion_tracker
|
||||
iters.append(new_iter)
|
||||
|
|
|
@ -90,7 +90,7 @@ class SaltCMD(parsers.SaltCMDOptionParser):
|
|||
|
||||
else:
|
||||
try:
|
||||
batch = salt.cli.batch.Batch(self.config, eauth=eauth)
|
||||
batch = salt.cli.batch.Batch(self.config, eauth=eauth, parser=self.options)
|
||||
except salt.exceptions.SaltClientError as exc:
|
||||
# We will print errors to the console further down the stack
|
||||
sys.exit(1)
|
||||
|
|
|
@ -671,6 +671,7 @@ class LocalClient(object):
|
|||
expr_form='glob',
|
||||
ret='',
|
||||
kwarg=None,
|
||||
show_jid=False,
|
||||
**kwargs):
|
||||
'''
|
||||
Yields the individual minion returns as they come in, or None
|
||||
|
@ -714,6 +715,9 @@ class LocalClient(object):
|
|||
tgt_type=expr_form,
|
||||
block=False,
|
||||
**kwargs):
|
||||
if fn_ret and show_jid:
|
||||
for minion in fn_ret.keys():
|
||||
fn_ret[minion]['jid'] = pub_data['jid']
|
||||
yield fn_ret
|
||||
|
||||
self._clean_up_subscriptions(pub_data['jid'])
|
||||
|
|
Loading…
Add table
Reference in a new issue