Changeset 13328 in genesis
- Timestamp:
- Jul 28, 2015, 9:37:33 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r13327 r13328 212 212 wlan_count=0 213 213 try: 214 for key in datadump['autogen_iface_keys']:214 for key in get_interface_keys(datadump, True): 215 215 datadump[key]['autogen_ifbase'] = key.split('_')[1] 216 216 datadump[key]['autogen_gateway'] = datadump[key]['ip'].split('/')[0] … … 278 278 datadump = get_yaml(host) 279 279 try: 280 for iface_key in datadump['autogen_iface_keys']:280 for iface_key in get_interface_keys(datadump): 281 281 net_addr = network(datadump[iface_key]['ip']) 282 282 poel[net_addr] += [(host,datadump[iface_key].copy())] … … 515 515 516 516 dhcp_out = defaultdict(list) 517 for iface_key in datadump['autogen_iface_keys']:517 for iface_key in get_interface_keys(datadump): 518 518 ifname = datadump[iface_key]['autogen_ifname'] 519 519 if not datadump[iface_key].has_key('comment'): … … 578 578 \n""").render(datadump) 579 579 580 for iface_key in datadump['autogen_iface_keys']:580 for iface_key in get_interface_keys(datadump): 581 581 if not datadump[iface_key].has_key('comment'): 582 582 datadump[iface_key]['comment'] = None … … 613 613 614 614 masterip_used = False 615 for iface_key in datadump['autogen_iface_keys']:615 for iface_key in get_interface_keys(datadump): 616 616 if datadump[iface_key]['ip'].startswith(datadump['masterip']): 617 617 masterip_used = True … … 620 620 addrs_list['lo0'].append((datadump['masterip'] + "/32", 'Master IP Not used in interface')) 621 621 622 for iface_key in datadump['autogen_iface_keys']:622 for iface_key in get_interface_keys(datadump): 623 623 ifacedump = datadump[iface_key] 624 624 ifname = ifacedump['autogen_ifname'] … … 892 892 893 893 894 def get_interface_keys(config ):894 def get_interface_keys(config, extra=False): 895 895 """ Quick hack to get all interface keys, later stage convert this to a iterator """ 896 return sorted([elem for elem in config.keys() if (elem.startswith('iface_') and not "lo0" in elem)]) 896 elems = sorted([elem for elem in config.keys() if (elem.startswith('iface_') and not "lo0" in elem)]) 897 if extra == False: 898 return filter(lambda x: not "extra" in x, elems) 899 else: 900 return elems 897 901 898 902 … … 902 906 for config in configs: 903 907 ip_list.append(config['masterip']) 904 for iface_key in get_interface_keys(config ):908 for iface_key in get_interface_keys(config, True): 905 909 l = config[iface_key]['ip'] 906 910 addr, mask = l.split('/') … … 1068 1072 """ 1069 1073 table = [] 1070 for iface_key in datadump['autogen_iface_keys']: 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 1071 1078 ifacedump = datadump[iface_key] 1072 1079 if ifacedump.has_key('ns_ip'): 1073 1080 x_ip = ifacedump['ns_ip'].split('/')[0] 1074 x_proto = 'https' if 'M' in ifacedump['bridge_type'] else 'http' 1075 table.append((ifacedump['autogen_ifname'], ifacedump['mode'], "%s://%s" % (x_proto, x_ip))) 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)) 1076 1095 1077 1096 output += make_table(table) … … 1504 1523 print """Usage: %(prog)s <argument> 1505 1524 Argument: 1525 \tcleanup = Cleanup all YAML files to specified format 1506 1526 \tstandalone [port] = Run configurator webserver [8000] 1507 1527 \tdns [outputdir] = Generate BIND compliant zone files in dns [./dns] … … 1715 1735 datadump = get_yaml(host) 1716 1736 ip2host[datadump['masterip']] = datadump['autogen_fqdn'] 1717 for iface in datadump['autogen_iface_keys']:1737 for iface in get_interface_keys(datadump): 1718 1738 ip2host[datadump[iface]['autogen_gateway']] = datadump['autogen_fqdn'] 1719 1739 … … 1972 1992 datadump['nodename'] = datadump['nodename'].lower() 1973 1993 1974 for iface_key in datadump['autogen_iface_keys']:1994 for iface_key in get_interface_keys(datadump): 1975 1995 try: 1976 1996 # All our normal wireless cards are normal APs now … … 2091 2111 datadump = get_yaml(system) 2092 2112 ips = [datadump['masterip']] 2093 for ifkey in datadump['autogen_iface_keys']:2113 for ifkey in get_interface_keys(datadump): 2094 2114 ips.append(datadump[ifkey]['ip'].split('/')[0]) 2095 2115 print system, ' '.join(ips)
Note:
See TracChangeset
for help on using the changeset viewer.