提交 9a5fac15 编写于 作者: Y Yihuang Yu

ping.ext_host: Only execute ext_host_get_cmd when it is not empty

`process.run` cannot pass empty command line and will raise IndexError,
only execute the ext_host_get_cmd if it is not empty.
Signed-off-by: NYihuang Yu <yihyu@redhat.com>
上级 195b754d
......@@ -68,13 +68,14 @@ def run(test, params, env):
if ping_ext_host:
ext_host = params.get("ext_host", "")
ext_host_get_cmd = params.get("ext_host_get_cmd", "")
try:
ext_host = process.system_output(ext_host_get_cmd, shell=True)
ext_host = ext_host.decode()
except process.CmdError:
logging.warn("Can't get specified host with cmd '%s',"
" Fallback to default host '%s'",
ext_host_get_cmd, ext_host)
if ext_host_get_cmd:
try:
ext_host = process.system_output(ext_host_get_cmd, shell=True)
ext_host = ext_host.decode()
except process.CmdError:
logging.warn("Can't get specified host with cmd '%s',"
" Fallback to default host '%s'",
ext_host_get_cmd, ext_host)
dest_ips = [ext_host]
sessions = [session]
interfaces = [None]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册