修改bug

pull/6/head
halcyon 2015-01-04 11:12:38 +08:00
parent a4b3a07885
commit ccb4876d88
1 changed files with 3 additions and 3 deletions

View File

@ -341,14 +341,14 @@ def connect(username, password, host, port, login_name):
def remote_exec_cmd(ip, port, username, password, cmd): def remote_exec_cmd(ip, port, username, password, cmd):
try: try:
time.sleep(3) time.sleep(5)
ssh = paramiko.SSHClient() ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, port, username, password, key_filename=USER_KEY_FILE, timeout=5) ssh.connect(ip, port, username, password, key_filename=USER_KEY_FILE, timeout=5)
stdin, stdout, stderr = ssh.exec_command("bash -l -c '%s'" % cmd) stdin, stdout, stderr = ssh.exec_command("bash -l -c '%s'" % cmd)
out = stdout.readlines() out = stdout.readlines()
err = stderr.readlines() err = stderr.readlines()
color_print('%s:', 'blue') color_print('%s:' %ip, 'blue')
for i in out: for i in out:
color_print(" " * 4 + i.strip(), 'green') color_print(" " * 4 + i.strip(), 'green')
for j in err: for j in err:
@ -360,7 +360,7 @@ def remote_exec_cmd(ip, port, username, password, cmd):
def multi_remote_exec_cmd(hosts, username, cmd): def multi_remote_exec_cmd(hosts, username, cmd):
pool = Pool(processes=3) pool = Pool(processes=5)
for host in hosts: for host in hosts:
username, password, ip, port = get_connect_item(username, host) username, password, ip, port = get_connect_item(username, host)
pool.apply_async(remote_exec_cmd, (ip, port, username, password, cmd)) pool.apply_async(remote_exec_cmd, (ip, port, username, password, cmd))