@@ -50,7 +50,7 @@ def __init__(self, hosts,
5050 user = None , password = None , port = None , pkey = None ,
5151 forward_ssh_agent = True , num_retries = DEFAULT_RETRIES , timeout = 120 ,
5252 pool_size = 10 , proxy_host = None , proxy_port = 22 ,
53- agent = None , host_config = None ):
53+ agent = None , host_config = None , channel_timeout = None ):
5454 """
5555 :param hosts: Hosts to connect to
5656 :type hosts: list(str)
@@ -76,10 +76,9 @@ def __init__(self, hosts,
7676 Defaults to True if not set.
7777 :type forward_ssh_agent: bool
7878 :param pool_size: (Optional) Greenlet pool size. Controls on how many\
79- hosts to execute tasks in parallel. Defaults to number of hosts or 10, \
80- whichever is lower. Pool size will be *equal to* number of hosts if number\
81- of hosts is lower than the pool size specified as that would only \
82- increase overhead with no benefits.
79+ hosts to execute tasks in parallel. Defaults to 10. Values over 500 \
80+ are not likely to increase performance due to overhead in the single \
81+ thread running our event loop.
8382 :type pool_size: int
8483 :param proxy_host: (Optional) SSH host to tunnel connection through \
8584 so that SSH clients connect to self.host via client -> proxy_host -> \
@@ -94,6 +93,9 @@ def __init__(self, hosts,
9493 :param host_config: (Optional) Per-host configuration for cases where \
9594 not all hosts use the same configuration values.
9695 :type host_config: dict
96+ :param channel_timeout: (Optional) Time in seconds before an SSH operation \
97+ times out.
98+ :type channel_timeout: int
9799
98100 **Example Usage**
99101
@@ -244,6 +246,7 @@ def __init__(self, hosts,
244246 self .host_clients = {}
245247 self .agent = agent
246248 self .host_config = host_config if host_config else {}
249+ self .channel_timeout = channel_timeout
247250
248251 def run_command (self , * args , ** kwargs ):
249252 """Run command on all hosts in parallel, honoring self.pool_size,
@@ -448,7 +451,7 @@ def _get_host_config_values(self, host):
448451 _password = self .host_config .get (host , {}).get ('password' , self .password )
449452 _pkey = self .host_config .get (host , {}).get ('private_key' , self .pkey )
450453 return _user , _port , _password , _pkey
451-
454+
452455 def _exec_command (self , host , * args , ** kwargs ):
453456 """Make SSHClient, run command on host"""
454457 if not host in self .host_clients or not self .host_clients [host ]:
@@ -461,7 +464,8 @@ def _exec_command(self, host, *args, **kwargs):
461464 timeout = self .timeout ,
462465 proxy_host = self .proxy_host ,
463466 proxy_port = self .proxy_port ,
464- agent = self .agent )
467+ agent = self .agent ,
468+ channel_timeout = self .channel_timeout )
465469 return self .host_clients [host ].exec_command (* args , ** kwargs )
466470
467471 def get_output (self , cmd , output ):
@@ -652,6 +656,7 @@ def _copy_file(self, host, local_file, remote_file, recurse=False):
652656 timeout = self .timeout ,
653657 proxy_host = self .proxy_host ,
654658 proxy_port = self .proxy_port ,
655- agent = self .agent )
659+ agent = self .agent ,
660+ channel_timeout = self .channel_timeout )
656661 return self .host_clients [host ].copy_file (local_file , remote_file ,
657662 recurse = recurse )
0 commit comments