与机器人框架的多个并发 ssh 连接

Multiple concurrent ssh connections with robot framework

如何使用 Robot Framework 来拥有多个 ssh 进程运行?全部到集群上的不同节点。我已经使用 for 循环,或者在进程库中使用 start process 关键字为我需要的每个节点启动一个。我需要检查每个节点上的 OpenSSH_ 版本。

我对机器人框架还很陌生。

@{nodes}   Create List     1  2  3  4   5   6   7   8
    :FOR    ${node}   IN   @{nodes}
    \  Open Connection    ${node}
    \  Enable SSH Logging    ${output}
    \  Run Keyword And Ignore Error     Login  user    pass
    \  Log     all output:${output}
    \  File Should not be empty     ${output}
    \  ${version}=     Grep File      ${output}   OpenSSH_
    \  Should contain  ${version}  OpenSSH_6.9
    \  Close Connection

Robot Framework 的 SSHLibrary 库支持到不同主机的多个连接。理想情况下,您最终会得到这样的结果:

:FOR    ${host}    IN    @{hosts}
    Open Connection    ${host}
    Comment    Do something with current ${host}
    Close Connection

使用以下关键字在不同的 SSH 会话之间切换:

Switch Connection    index_or_alias