robotframework封裝ssh關鍵字用於遠程控制和文件傳輸
*** Settings ***
Library SSHLibrary
Library String
*** Variables ***
*** Keywords ***
OpenConnectionAndLogin
[Documentation] ssh remote server
[Arguments] ${ip} ${user} ${password} ${alias}
Open Connection ${ip} alias=${alias}
Login ${user} ${password}
SwithConnectionAndLog
[Documentation] swith connection
[Arguments] ${machine}
Switch Connection ${${machine}_alias}
${myc} Get Connection ${${machine}_alias}
log ${myc.host}
SshExecuteCmd
[Documentation] ssh execute cmd, check return, 可指定機器
[Arguments] ${machine} ${cmd}
SwithConnectionAndLog ${machine}
${stdout} ${rc} = SSHLibrary.Execute Command ${cmd} return_rc=${true}
Return From Keyword ${stdout} ${rc}
SshPutFile
[Documentation] ssh執行命令, 判斷返回碼, 可指定機器
[Arguments] ${machine} ${src} ${dest}
SwithConnectionAndLog ${machine}
SSHLibrary.Put File ${src} ${dest}