Commit 9ba7ad14 authored by ibuler's avatar ibuler

修改multi拼写错误

parent b1e0a241
...@@ -357,12 +357,12 @@ def connect(username, password, host, port, login_name, login_type='L'): ...@@ -357,12 +357,12 @@ def connect(username, password, host, port, login_name, login_type='L'):
ssh.close() ssh.close()
def remote_exec_cmd(ip, port, username, passwd, cmd): def remote_exec_cmd(ip, port, username, password, cmd):
try: try:
time.sleep(3) time.sleep(3)
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, passwd, timeout=5) ssh.connect(ip, port, username, password, 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()
...@@ -377,18 +377,19 @@ def remote_exec_cmd(ip, port, username, passwd, cmd): ...@@ -377,18 +377,19 @@ def remote_exec_cmd(ip, port, username, passwd, cmd):
red_print(str(e)) red_print(str(e))
def mutli_remote_exec_cmd(hosts, username, cmd): def multi_remote_exec_cmd(hosts, username, cmd):
pool = Pool(processes=3) pool = Pool(processes=3)
for host in hosts: for host in hosts:
username, passwd, ip, port = get_connect_item(username, host) login_type, username, password, ip, port = get_connect_item(username, host)
pool.apply_async(remote_exec_cmd, (ip, port, username, passwd, cmd)) pool.apply_async(remote_exec_cmd, (ip, port, username, password, cmd))
pool.close() pool.close()
pool.join() pool.join()
def exec_cmd_servers(username): def exec_cmd_servers(username):
hosts = [] hosts = []
green_print("Input the Host IP(s),Separated by Commas, q/Q to Quit.\nYou can choose in the following IP(s), Use Linux / Unix glob.") green_print("Input the Host IP(s),Separated by Commas, q/Q to Quit.\n \
You can choose in the following IP(s), Use Linux / Unix glob.")
print_user_host(LOGIN_NAME) print_user_host(LOGIN_NAME)
while True: while True:
inputs = raw_input('\033[1;32mip(s)>: \033[0m') inputs = raw_input('\033[1;32mip(s)>: \033[0m')
...@@ -416,7 +417,7 @@ def exec_cmd_servers(username): ...@@ -416,7 +417,7 @@ def exec_cmd_servers(username):
f = open(filename, 'a') f = open(filename, 'a')
f.write("DateTime: %s User: %s Host: %s Cmds: %s\n" % f.write("DateTime: %s User: %s Host: %s Cmds: %s\n" %
(time.strftime('%Y/%m/%d %H:%M:%S'), username, hosts, cmd)) (time.strftime('%Y/%m/%d %H:%M:%S'), username, hosts, cmd))
mutli_remote_exec_cmd(hosts, username, cmd) multi_remote_exec_cmd(hosts, username, cmd)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment