我使用ParallelSSHClient连接到多个服务器。 当我运行Python函数时,它运行得非常好。 然而,当我从Robot框架中的测试用例调用函数时,我得到了以下错误。在
SSHException: Error reading SSH protocol banner('This operation would block forever', )
我使用的Python函数是:
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
在开头添加以下内容-
相关问题 更多 >
编程相关推荐