Execute and yield returns as they come in, do not print to the display mine The Single objects will use mine_functions defined in the roster, pillar, or master config (they will be checked in that order) and will modify the argv with the argument
(self, mine=False, jid=None)
| 872 | time.sleep(0.1) |
| 873 | |
| 874 | def run_iter(self, mine=False, jid=None): |
| 875 | """ |
| 876 | Execute and yield returns as they come in, do not print to the display |
| 877 | |
| 878 | mine |
| 879 | The Single objects will use mine_functions defined in the roster, |
| 880 | pillar, or master config (they will be checked in that order) and |
| 881 | will modify the argv with the arguments from mine_functions |
| 882 | """ |
| 883 | fstr = "{}.prep_jid".format(self.opts["master_job_cache"]) |
| 884 | jid = self.returners[fstr](passed_jid=jid or self.opts.get("jid", None)) |
| 885 | |
| 886 | # Save the invocation information |
| 887 | argv = self.opts["argv"] |
| 888 | |
| 889 | if self.opts.get("raw_shell", False): |
| 890 | fun = "ssh._raw" |
| 891 | args = argv |
| 892 | else: |
| 893 | fun = argv[0] if argv else "" |
| 894 | args = argv[1:] |
| 895 | |
| 896 | job_load = { |
| 897 | "jid": jid, |
| 898 | "tgt_type": self.tgt_type, |
| 899 | "tgt": self.opts["tgt"], |
| 900 | "user": self.opts["user"], |
| 901 | "fun": fun, |
| 902 | "arg": args, |
| 903 | } |
| 904 | |
| 905 | # save load to the master job cache |
| 906 | if self.opts["master_job_cache"] == "local_cache": |
| 907 | self.returners["{}.save_load".format(self.opts["master_job_cache"])]( |
| 908 | jid, job_load, minions=self.targets.keys() |
| 909 | ) |
| 910 | else: |
| 911 | self.returners["{}.save_load".format(self.opts["master_job_cache"])]( |
| 912 | jid, job_load |
| 913 | ) |
| 914 | |
| 915 | for ret, retcode in self.handle_ssh(mine=mine): |
| 916 | host = next(iter(ret)) |
| 917 | self.cache_job(jid, host, ret[host], fun) |
| 918 | if self.event: |
| 919 | id_, data = next(iter(ret.items())) |
| 920 | if not isinstance(data, dict): |
| 921 | data = {"return": data} |
| 922 | if "id" not in data: |
| 923 | data["id"] = id_ |
| 924 | if "fun" not in data: |
| 925 | data["fun"] = fun |
| 926 | if "fun_args" not in data: |
| 927 | data["fun_args"] = args |
| 928 | if "retcode" not in data: |
| 929 | data["retcode"] = retcode |
| 930 | if "success" not in data: |
| 931 | data["success"] = data["retcode"] == salt.defaults.exitcodes.EX_OK |