Python 使用ParallelsShcClient读取SSH协议横幅时发生SSHException错误
我正在使用ParallelSSHClient连接到多个服务器。 当我运行Python函数时,它工作得非常好。 然而,当我在Robot框架中从测试用例调用函数时,我得到以下错误 SSHException:读取SSH协议标题时出错('此操作将导致 永远封锁',) 我使用的Python函数是:Python 使用ParallelsShcClient读取SSH协议横幅时发生SSHException错误,python,robotframework,paramiko,Python,Robotframework,Paramiko,我正在使用ParallelSSHClient连接到多个服务器。 当我运行Python函数时,它工作得非常好。 然而,当我在Robot框架中从测试用例调用函数时,我得到以下错误 SSHException:读取SSH协议标题时出错('此操作将导致 永远封锁',) 我使用的Python函数是: from pssh.pssh_client import ParallelSSHClient from pssh.utils import load_private_key from robot.librari
from pssh.pssh_client import ParallelSSHClient
from pssh.utils import load_private_key
from robot.libraries.BuiltIn import BuiltIn
def check101():
pkey = load_private_key('/root/test.pem')
hosts = ['2.2.2.2', '1.1.1.1']
client = ParallelSSHClient(hosts, pkey=pkey)
try:
output = client.run_command("<command>")
except (AuthenticationException):
print 'Error'
node=0
for host in output:
for line in output[host].stdout:
node=node+1
if (int(line)>0):
return node
break
return -1
从pssh.pssh\u客户端导入并行客户端
从pssh.utils导入加载\u私钥
从robot.libraries.BuiltIn导入内置
def check101():
pkey=load_private_key('/root/test.pem'))
hosts=['2.2.2','1.1.1.1']
client=parallelshclient(主机,pkey=pkey)
尝试:
输出=客户端。运行_命令(“”)
除外(AuthenticationException):
打印“错误”
节点=0
对于主机输入输出:
对于输出[host]中的行。标准输出:
节点=节点+1
如果(int(line)>0):
返回节点
打破
返回-1
在开头添加以下内容-
from gevent import monkey
monkey.patch_all()