Skip to content

Commit 5b4020e

Browse files
Judpkittenis
authored andcommitted
Allow passing in host tuples to create clients
1 parent 4971730 commit 5b4020e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

pssh.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ class ParallelSSHClient(object):
103103
"""Uses SSHClient, runs command on multiple hosts in parallel"""
104104

105105
def __init__(self, hosts,
106-
pool_size=10,
107-
user=None,
108-
password=None):
106+
pool_size=10):
109107

110108
"""Connect to hosts
111109
:type: list(str)
@@ -120,11 +118,9 @@ def __init__(self, hosts,
120118
self.pool = gevent.pool.Pool(size = pool_size)
121119
self.pool_size = pool_size
122120
self.hosts = hosts
123-
self.user = user
124-
self.password = password
125121

126122
# Initialise connections to all hosts
127-
self.host_clients = dict((host, SSHClient(host, user=user, password=password)) for host in hosts)
123+
self.host_clients = dict((host[0], SSHClient(host[0], user=host[1] password=host[2])) for host in hosts)
128124

129125
def exec_command(self, *args, **kwargs):
130126
"""Run command on all hosts in parallel, honoring self.pool_size"""

0 commit comments

Comments
 (0)