mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Add alias and device type columns to host pools (#953)
* Add alias and device type columns to host pools * Add host pool members links when available * Add host pool links * Implement host pool members pagination * Host Pools GUI fixes and improvements * Remove hardcoded columns number * Host Pools GUI fixes * Remove debug print
This commit is contained in:
parent
f711ab555b
commit
2a843966da
10 changed files with 332 additions and 147 deletions
|
|
@ -9,7 +9,6 @@ local host_pools_utils = {}
|
|||
host_pools_utils.DEFAULT_POOL_ID = "0"
|
||||
host_pools_utils.DEFAULT_POOL_NAME = "Not Assigned"
|
||||
host_pools_utils.MAX_NUM_POOLS = 16
|
||||
host_pools_utils.MAX_MEMBERS_NUM = 32
|
||||
|
||||
local function get_pool_members_key(ifid, pool_id)
|
||||
return "ntopng.prefs." .. ifid .. ".host_pools.members." .. pool_id
|
||||
|
|
@ -37,15 +36,6 @@ local function get_pool_detail(ifid, pool_id, detail)
|
|||
return ntop.getHashCache(details_key, detail)
|
||||
end
|
||||
|
||||
local function addressSplitVlan(mixed)
|
||||
local parts = split(mixed, "@")
|
||||
if #parts == 2 then
|
||||
return parts[1], parts[2]
|
||||
else
|
||||
return mixed, "0"
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
function host_pools_utils.createPool(ifid, pool_id, pool_name)
|
||||
|
|
@ -104,13 +94,40 @@ function host_pools_utils.getPoolMembers(ifid, pool_id)
|
|||
local members = {}
|
||||
|
||||
for _,v in pairsByValues(ntop.getMembersCache(members_key) or {}, asc) do
|
||||
local address, vlan = addressSplitVlan(v)
|
||||
members[#members + 1] = {address=address, vlan=vlan}
|
||||
local hostinfo = hostkey2hostinfo(v)
|
||||
members[#members + 1] = {address=hostinfo["host"], vlan=hostinfo["vlan"], key=v}
|
||||
end
|
||||
|
||||
return members
|
||||
end
|
||||
|
||||
function host_pools_utils.getMemberKey(member)
|
||||
-- handle vlan
|
||||
local is_network
|
||||
local host_key
|
||||
local address = hostkey2hostinfo(member)["host"]
|
||||
|
||||
if isMacAddress(address) then
|
||||
host_key = address
|
||||
is_network = false
|
||||
else
|
||||
local network, prefix = splitNetworkPrefix(address)
|
||||
|
||||
if(((isIPv4(network)) and (prefix ~= 32)) or
|
||||
((isIPv6(network)) and (prefix ~= 128))) then
|
||||
-- this is a network
|
||||
host_key = address
|
||||
is_network = true
|
||||
else
|
||||
-- this is an host
|
||||
host_key = network
|
||||
is_network = false
|
||||
end
|
||||
end
|
||||
|
||||
return host_key, is_network
|
||||
end
|
||||
|
||||
function host_pools_utils.getPoolName(ifid, pool_id)
|
||||
return get_pool_detail(ifid, pool_id, "name")
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue