MCPcopy Create free account
hub / github.com/saltstack/salt / cmd_batch

Method cmd_batch

salt/client/__init__.py:716–788  ·  view source on GitHub ↗

Iteratively execute a command on subsets of minions at a time The function signature is the same as :py:meth:`cmd` with the following exceptions. :param batch: The batch identifier of systems to execute on :returns: A generator of minion returns .

(
        self,
        tgt,
        fun,
        arg=(),
        tgt_type="glob",
        ret="",
        kwarg=None,
        batch="10%",
        **kwargs,
    )

Source from the content-addressed store, hash-verified

714 )
715
716 def cmd_batch(
717 self,
718 tgt,
719 fun,
720 arg=(),
721 tgt_type="glob",
722 ret="",
723 kwarg=None,
724 batch="10%",
725 **kwargs,
726 ):
727 """
728 Iteratively execute a command on subsets of minions at a time
729
730 The function signature is the same as :py:meth:`cmd` with the
731 following exceptions.
732
733 :param batch: The batch identifier of systems to execute on
734
735 :returns: A generator of minion returns
736
737 .. code-block:: python
738
739 >>> returns = local.cmd_batch('*', 'state.highstate', batch='10%')
740 >>> for ret in returns:
741 ... print(ret)
742 {'jerry': {...}}
743 {'dave': {...}}
744 {'stewart': {...}}
745 """
746 # We need to re-import salt.utils.args here
747 # even though it has already been imported.
748 # when cmd_batch is called via the NetAPI
749 # the module is unavailable.
750 # Late import - not used anywhere else in this file
751 import salt.cli.batch
752 import salt.utils.args
753
754 arg = salt.utils.args.condition_input(arg, kwarg)
755 opts = {
756 "tgt": tgt,
757 "fun": fun,
758 "arg": arg,
759 "tgt_type": tgt_type,
760 "ret": ret,
761 "batch": batch,
762 "failhard": kwargs.get("failhard", self.opts.get("failhard", False)),
763 "raw": kwargs.get("raw", False),
764 }
765
766 if "timeout" in kwargs:
767 opts["timeout"] = kwargs["timeout"]
768 if "gather_job_timeout" in kwargs:
769 opts["gather_job_timeout"] = kwargs["gather_job_timeout"]
770 if "batch_wait" in kwargs:
771 opts["batch_wait"] = int(kwargs["batch_wait"])
772
773 eauth = {}

Callers 3

local_batchMethod · 0.80
test_batchMethod · 0.80
test_batch_rawMethod · 0.80

Calls 4

runMethod · 0.95
getMethod · 0.45
popMethod · 0.45
itemsMethod · 0.45

Tested by 2

test_batchMethod · 0.64
test_batch_rawMethod · 0.64