Changeset 13336 in genesis for tools/gformat.py
- Timestamp:
- Jul 28, 2015, 10:04:00 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r13328 r13336 715 715 datadump['autogen_normal_proxies_ips'] = ','.join([x['masterip'] for x in normal_proxies]) 716 716 datadump['autogen_normal_proxies_names'] = ','.join([x['autogen_item'] for x in normal_proxies]) 717 datadump['autogen_attached_devices'] = [x[2] for x in get_attached_devices(datadump)] 718 datadump['autogen_neighbours'] = [x[1] for x in get_neighbours(datadump)] 717 719 718 720 output = generate_header(datadump, "#"); … … 850 852 851 853 # 854 # Script variables 855 # 856 attached_devices="{{ autogen_attached_devices|join(' ') }}" 857 neighbours="{{ autogen_neighbours|join(' ') }}" 858 859 860 # 852 861 # Interface definitions 853 862 #\n … … 932 941 933 942 return nameservers_cache[0:max_servers] 943 944 945 def get_neighbours(datadump): 946 (addrs_list, dhclient_if, extra_ouput) = make_interface_list(datadump) 947 948 (poel, errors) = make_relations() 949 table = [] 950 for iface,addrs in sorted(addrs_list.iteritems()): 951 if iface in ['lo0']: 952 continue 953 954 for addr, comment in sorted(addrs,key=lambda x: parseaddr(x[0].split('/')[0])): 955 if not addr.startswith('172.'): 956 # Avoid listing internet connections as pool 957 continue 958 for neighbour in poel[network(addr)]: 959 if neighbour[0] != datadump['autogen_item']: 960 table.append((iface, neighbour[1]['ip'].split('/')[0], neighbour[0] + " (" + neighbour[1]['autogen_ifname'] + ")", neighbour[1]['comment'])) 961 return table 962 963 964 def get_attached_devices(datadump, url=False): 965 table = [] 966 for iface_key in get_interface_keys(datadump, True): 967 # Quick to avoid listing ath(4) interface as attached device 968 if 'ath0' in iface_key: 969 continue 970 ifacedump = datadump[iface_key] 971 if ifacedump.has_key('ns_ip'): 972 x_ip = ifacedump['ns_ip'].split('/')[0] 973 else: 974 x_ip = ifacedump['ip'].split('/')[0] 975 976 if 'mode' in ifacedump: 977 x_mode = ifacedump['mode'] 978 else: 979 x_mode = 'unknown' 980 981 if 'bridge_type' in ifacedump: 982 device_type = ifacedump['bridge_type'] 983 else: 984 device_type = 'Unknown' 985 986 table.append((ifacedump['autogen_ifname'], x_mode, 'http://%s' % x_ip if url else x_ip, device_type)) 987 return table 934 988 935 989 … … 1071 1125 Attached devices: 1072 1126 """ 1073 table = [] 1074 for iface_key in get_interface_keys(datadump, True): 1075 # Quick to avoid listing ath(4) interface as attached device 1076 if 'ath0' in iface_key: 1077 continue 1078 ifacedump = datadump[iface_key] 1079 if ifacedump.has_key('ns_ip'): 1080 x_ip = ifacedump['ns_ip'].split('/')[0] 1081 else: 1082 x_ip = ifacedump['ip'].split('/')[0] 1083 1084 if 'mode' in ifacedump: 1085 x_mode = ifacedump['mode'] 1086 else: 1087 x_mode = 'unknown' 1088 1089 if 'bridge_type' in ifacedump: 1090 device_type = ifacedump['bridge_type'] 1091 else: 1092 device_type = 'Unknown' 1093 1094 table.append((ifacedump['autogen_ifname'], x_mode, "http://%s" % x_ip, device_type)) 1095 1096 output += make_table(table) 1127 output += make_table(get_attached_devices(datadump, url=True)) 1097 1128 output += '\n' 1098 1129 output += """\ 1099 1130 Available neighbours: 1100 1131 """ 1101 (poel, errors) = make_relations() 1102 table = [] 1103 for iface,addrs in sorted(addrs_list.iteritems()): 1104 if iface in ['lo0']: 1105 continue 1106 1107 for addr, comment in sorted(addrs,key=lambda x: parseaddr(x[0].split('/')[0])): 1108 if not addr.startswith('172.'): 1109 # Avoid listing internet connections as pool 1110 continue 1111 for neighbour in poel[network(addr)]: 1112 if neighbour[0] != datadump['autogen_item']: 1113 table.append((iface, neighbour[1]['ip'].split('/')[0], neighbour[0] + " (" + neighbour[1]['autogen_ifname'] + ")", neighbour[1]['comment'])) 1114 1115 output += make_table(table) 1132 output += make_table(get_neighbours(datadump)) 1116 1133 1117 1134 return output
Note:
See TracChangeset
for help on using the changeset viewer.