def scp_main(iplist,file_path,dst_path): try: infolist=get_userinfo.getinfo() user=infolist[0][0] passwd=infolist[0][1] threads=[] for ip in iplist: scp_main=threading.Thread(target=scp.scp_cmd,args=(ip,user,passwd,file_path,dst_path)) scp_main.start() print ip ,'scp',file_path,' is ok' except Exception,e: scp_mainerr = '%s %s' % (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),' scp_main-execute scp_main failed') with open(r'./log/error.log','a') as error_log: print >> error_log,('%s %s' % (scp_mainerr,e)) return scp_mainerr
def ssh_main(iplist,cmdlist): try: infolist=get_userinfo.getinfo() username=infolist[0][0] passwd=infolist[0][1] port=22 threads = [] for ip in iplist: ssh_main=threading.Thread(target=ssh.ssh_cmd,args=(ip,port,username,passwd,cmdlist)) ssh_main.start() print ip,'is ok' except Exception,e: ssh_mainerr='%s %s' % (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),'ssh_main-execute ssh_main() falied') with open(r'./log/error.log','a') as error_log: print >> error_log,('%s %s' %(ssh_mainerr,e)) return ssh_mainerr
def ssh_main(iplist, cmdlist): try: infolist = get_userinfo.getinfo() username = infolist[0][0] passwd = infolist[0][1] port = 22 threads = [] for i in iplist: ip = i[0] hostname = i[1] ssh_main = threading.Thread(target=ssh.ssh_cmd, args=(ip, port, username, passwd, cmdlist)) ssh_main.start() print ip, hostname, cmdlist[0], "is ok" except Exception, e: ssh_mainerr = "%s %s" % ( datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "ssh_main-execute ssh_main() falied", ) with open(r"./log/error.log", "a") as error_log: print >> error_log, ("%s %s" % (ssh_mainerr, e)) return ssh_mainerr