Fixed invalid name access on view interfaces

This commit is contained in:
Luca Deri 2022-01-05 09:38:12 +01:00
parent d67dd50b87
commit 2992d6acd0

View file

@ -2345,15 +2345,27 @@ function flow2hostinfo(host_info, host_type)
if host_type == "cli" then
if not host_info["cli.host"] then
host_name = interface.getHostMinInfo(host_info["cli.ip"])["name"]
local res = interface.getHostMinInfo(host_info["cli.ip"])
if((res == nil) or (res["name"] == nil)) then
host_name = host_info["cli.ip"]
else
host_name = res["name"]
end
end
return({host = host_info["cli.ip"], vlan = host_info["cli.vlan"], name = host_name})
elseif host_type == "srv" then
if not host_info["srv.host"] then
host_name = interface.getHostMinInfo(host_info["srv.ip"])["name"]
local res = interface.getHostMinInfo(host_info["srv.ip"])
if((res == nil) or (res["name"] == nil)) then
host_name = host_info["srv.ip"]
else
host_name = res["name"]
end
end
return({host = host_info["srv.ip"], vlan = host_info["srv.vlan"], name = host_name})
end
end