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

Method run

salt/client/ssh/__init__.py:953–1119  ·  view source on GitHub ↗

Execute the overall routine, print results via outputters

(self, jid=None)

Source from the content-addressed store, hash-verified

951 )
952
953 def run(self, jid=None):
954 """
955 Execute the overall routine, print results via outputters
956 """
957 # Recursion protection for nested salt-ssh calls (e.g. mine.get)
958 if "salt_ssh_recursion_depth" not in self.opts:
959 self.opts["salt_ssh_recursion_depth"] = 0
960 self.opts["salt_ssh_recursion_depth"] += 1
961 if self.opts["salt_ssh_recursion_depth"] > 10:
962 log.error("salt-ssh recursion depth limit exceeded (10)")
963 return {"error": "salt-ssh recursion depth limit exceeded"}
964
965 if self.opts.get("list_hosts"):
966 self._get_roster()
967 ret = {}
968 for roster_file in self.__parsed_rosters:
969 if roster_file.startswith("#"):
970 continue
971 ret[roster_file] = {}
972 for host_id in self.__parsed_rosters[roster_file]:
973 hostname = self.__parsed_rosters[roster_file][host_id]["host"]
974 ret[roster_file][host_id] = hostname
975 salt.output.display_output(ret, "nested", self.opts)
976 sys.exit()
977
978 fstr = "{}.prep_jid".format(self.opts["master_job_cache"])
979 jid = self.returners[fstr](passed_jid=jid or self.opts.get("jid", None))
980
981 # Save the invocation information
982 argv = self.opts["argv"]
983
984 if self.opts.get("raw_shell", False):
985 fun = "ssh._raw"
986 args = argv
987 else:
988 fun = argv[0] if argv else ""
989 args = argv[1:]
990
991 job_load = {
992 "jid": jid,
993 "tgt_type": self.tgt_type,
994 "tgt": self.opts["tgt"],
995 "user": self.opts["user"],
996 "fun": fun,
997 "arg": args,
998 }
999
1000 # save load to the master job cache
1001 try:
1002 if isinstance(jid, bytes):
1003 jid = jid.decode("utf-8")
1004 if self.opts["master_job_cache"] == "local_cache":
1005 self.returners["{}.save_load".format(self.opts["master_job_cache"])](
1006 jid, job_load, minions=self.targets.keys()
1007 )
1008 else:
1009 self.returners["{}.save_load".format(self.opts["master_job_cache"])](
1010 jid, job_load

Calls 15

_get_rosterMethod · 0.95
handle_sshMethod · 0.95
cache_jobMethod · 0.95
key_deployMethod · 0.95
exitMethod · 0.80
formatMethod · 0.80
warningMethod · 0.80
errorMethod · 0.45
getMethod · 0.45
keysMethod · 0.45
writeMethod · 0.45