19 lines
661 B
Python
19 lines
661 B
Python
import json
|
|
from view_common import get_system_interfaces, iface_info
|
|
|
|
|
|
def collect_tokens(cfg):
|
|
net = cfg.get('network_interfaces', {})
|
|
wan = net.get('wan_interface', '')
|
|
lan = net.get('lan_interface', '')
|
|
sys_ifaces = get_system_interfaces()
|
|
for configured in [wan, lan]:
|
|
if configured and configured not in sys_ifaces:
|
|
sys_ifaces.append(configured)
|
|
sys_ifaces.sort()
|
|
iface_data = [iface_info(i) for i in sys_ifaces]
|
|
return {
|
|
'GENERAL_WAN_INTERFACE': str(wan or '-'),
|
|
'GENERAL_LAN_INTERFACE': str(lan or '-'),
|
|
'NETWORK_INTERFACE_DATA_JSON': json.dumps(iface_data),
|
|
}
|