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,
)
| 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 = {} |