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

Method handle_ssh

salt/client/ssh/__init__.py:775–872  ·  view source on GitHub ↗

Spin up the needed threads or processes and execute the subsequent routines

(self, mine=False)

Source from the content-addressed store, hash-verified

773 que.put((ret, retcode))
774
775 def handle_ssh(self, mine=False):
776 """
777 Spin up the needed threads or processes and execute the subsequent
778 routines
779 """
780 que = multiprocessing.Queue()
781 running = {}
782 target_iter = iter(self.targets)
783 returned = set()
784 rets = set()
785 init = False
786 while True:
787 if not self.targets:
788 log.error("No matching targets found in roster.")
789 break
790 if len(running) < self.opts.get("ssh_max_procs", 25) and not init:
791 try:
792 host = next(target_iter)
793 except StopIteration:
794 init = True
795 continue
796 for default in self.defaults:
797 if default not in self.targets[host]:
798 self.targets[host][default] = self.defaults[default]
799 if "host" not in self.targets[host]:
800 self.targets[host]["host"] = host
801 if self.targets[host].get("winrm") and not HAS_WINSHELL:
802 returned.add(host)
803 rets.add(host)
804 log_msg = (
805 "Please contact sales@saltstack.com for access to the"
806 " enterprise saltwinshell module."
807 )
808 log.debug(log_msg)
809 no_ret = {
810 "fun_args": [],
811 "jid": None,
812 "return": log_msg,
813 "retcode": 1,
814 "fun": "",
815 "id": host,
816 }
817 yield {host: no_ret}, 1
818 continue
819 args = (
820 que,
821 self.opts,
822 host,
823 self.targets[host],
824 mine,
825 )
826 routine = Process(target=self.handle_routine, args=args)
827 routine.start()
828 running[host] = {"thread": routine}
829 continue
830 ret = {}
831 retcode = salt.defaults.exitcodes.EX_OK
832 try:

Callers 2

run_iterMethod · 0.95
runMethod · 0.95

Calls 10

ProcessClass · 0.90
debugMethod · 0.80
formatMethod · 0.80
setFunction · 0.50
errorMethod · 0.45
getMethod · 0.45
addMethod · 0.45
startMethod · 0.45
popMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected