Changeset 10889 in genesis
- Timestamp:
- May 16, 2012, 10:06:19 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r10887 r10889 108 108 return DHCP_CLIENT 109 109 else: 110 # Validation Checks 111 begin,end = map(int,item['dhcp'].split('-')) 112 if begin >= end: 113 raise ValueError("DHCP Start >= DHCP End") 110 114 return DHCP_SERVER 111 115 … … 447 451 datadump[iface_key]['autogen_netmask'] = cidr2netmask(mask) 448 452 datadump[iface_key]['autogen_subnet'] = get_network(addr, mask) 449 try: 450 if dhcp_type(datadump[iface_key]) != DHCP_SERVER: 451 raise ValueError 452 (dhcp_start, dhcp_stop) = datadump[iface_key]['dhcp'].split('-') 453 except (AttributeError, ValueError, KeyError): 454 dhcp_out[ifname].append(" subnet %(autogen_subnet)s netmask %(autogen_netmask)s {\n ### not autoritive\n }\n" % datadump[iface_key]) 453 if dhcp_type(datadump[iface_key]) != DHCP_SERVER: 454 dhcp_out[ifname].append(" subnet %(autogen_subnet)s netmask %(autogen_netmask)s {\n ### not autoritive\n }\n" % \ 455 datadump[iface_key]) 455 456 continue 456 457 458 (dhcp_start, dhcp_stop) = datadump[iface_key]['dhcp'].split('-') 457 459 dhcp_part = ".".join(addr.split('.')[0:3]) 458 460 datadump[iface_key]['autogen_dhcp_start'] = dhcp_part + "." + dhcp_start … … 494 496 output += "## %(interface)s - %(comment)s\n" % datadump[iface_key] 495 497 496 try: 497 (dhcp_start, dhcp_stop) = datadump[iface_key]['dhcp'].split('-') 498 (ip, cidr) = datadump[iface_key]['ip'].split('/') 499 datadump[iface_key]['autogen_netmask'] = cidr2netmask(cidr) 500 except (AttributeError, ValueError, KeyError): 498 if dhcp_type(datadump[iface_key]) != DHCP_SERVER: 501 499 output += "# not autoritive\n\n" 502 500 continue 501 502 (dhcp_start, dhcp_stop) = datadump[iface_key]['dhcp'].split('-') 503 (ip, cidr) = datadump[iface_key]['ip'].split('/') 504 datadump[iface_key]['autogen_netmask'] = cidr2netmask(cidr) 503 505 504 506 dhcp_part = ".".join(ip.split('.')[0:3]) … … 1534 1536 1535 1537 for iface_key in datadump['autogen_iface_keys']: 1536 # All our normal wireless cards are normal APs now 1537 if datadump[iface_key]['type'] in ['11a', '11b', '11g', 'wireless']: 1538 datadump[iface_key]['mode'] = 'ap' 1539 # Wireless Leiden SSID have an consistent lowercase/uppercase 1540 if datadump[iface_key].has_key('ssid'): 1541 ssid = datadump[iface_key]['ssid'] 1542 prefix = 'ap-WirelessLeiden-' 1543 if ssid.lower().startswith(prefix.lower()): 1544 datadump[iface_key]['ssid'] = prefix + ssid[len(prefix)].upper() + ssid[len(prefix) + 1:] 1545 if datadump[iface_key].has_key('ns_ip') and not datadump[iface_key].has_key('mode'): 1546 datadump[iface_key]['mode'] = 'autogen-FIXME' 1547 if not datadump[iface_key].has_key('comment'): 1548 datadump[iface_key]['comment'] = 'autogen-FIXME' 1549 1550 if datadump[iface_key]['comment'].startswith('autogen-') and datadump[iface_key].has_key('comment'): 1551 datadump[iface_key] = datadump[iface_key]['desc'] 1552 1553 x = datadump[iface_key]['comment'] 1554 datadump[iface_key]['comment'] = x[0].upper() + x[1:] 1555 1556 1557 if datadump[iface_key].has_key('desc'): 1558 if datadump[iface_key]['comment'].lower() == datadump[iface_key]['desc'].lower(): 1559 del datadump[iface_key]['desc'] 1560 else: 1561 print "# ERROR: At %s - %s" % (datadump['nodename'], iface_key) 1562 response = fix_conflict(datadump[iface_key]['comment'], datadump[iface_key]['desc']) 1563 if response: 1564 datadump[iface_key]['comment'] = response 1538 try: 1539 if datadump[iface_key]['interface'] not in iface_key: 1540 raise ValueError("interface must be in the key name") 1541 # All our normal wireless cards are normal APs now 1542 if datadump[iface_key]['type'] in ['11a', '11b', '11g', 'wireless']: 1543 datadump[iface_key]['mode'] = 'ap' 1544 # Wireless Leiden SSID have an consistent lowercase/uppercase 1545 if datadump[iface_key].has_key('ssid'): 1546 ssid = datadump[iface_key]['ssid'] 1547 prefix = 'ap-WirelessLeiden-' 1548 if ssid.lower().startswith(prefix.lower()): 1549 datadump[iface_key]['ssid'] = prefix + ssid[len(prefix)].upper() + ssid[len(prefix) + 1:] 1550 if datadump[iface_key].has_key('ns_ip') and not datadump[iface_key].has_key('mode'): 1551 datadump[iface_key]['mode'] = 'autogen-FIXME' 1552 if not datadump[iface_key].has_key('comment'): 1553 datadump[iface_key]['comment'] = 'autogen-FIXME' 1554 1555 if datadump[iface_key]['comment'].startswith('autogen-') and datadump[iface_key].has_key('comment'): 1556 datadump[iface_key] = datadump[iface_key]['desc'] 1557 1558 x = datadump[iface_key]['comment'] 1559 datadump[iface_key]['comment'] = x[0].upper() + x[1:] 1560 1561 1562 if datadump[iface_key].has_key('desc'): 1563 if datadump[iface_key]['comment'].lower() == datadump[iface_key]['desc'].lower(): 1565 1564 del datadump[iface_key]['desc'] 1566 1567 # Set the compass value based on the angle between the poels 1568 if datadump[iface_key].has_key('ns_ip'): 1569 my_pool = poel[network(datadump[iface_key]['ip'])] 1570 remote_hosts = list(set([x[0] for x in my_pool]) - set([host])) 1571 if remote_hosts: 1572 compass_target = remote_hosts[0] 1573 datadump[iface_key]['compass'] = cd_between_hosts(host, compass_target, datadumps) 1574 1565 else: 1566 print "# ERROR: At %s - %s" % (datadump['nodename'], iface_key) 1567 response = fix_conflict(datadump[iface_key]['comment'], datadump[iface_key]['desc']) 1568 if response: 1569 datadump[iface_key]['comment'] = response 1570 del datadump[iface_key]['desc'] 1571 1572 # Check DHCP configuration 1573 dhcp_type(datadump[iface_key]) 1574 1575 # Set the compass value based on the angle between the poels 1576 if datadump[iface_key].has_key('ns_ip'): 1577 my_pool = poel[network(datadump[iface_key]['ip'])] 1578 remote_hosts = list(set([x[0] for x in my_pool]) - set([host])) 1579 if remote_hosts: 1580 compass_target = remote_hosts[0] 1581 datadump[iface_key]['compass'] = cd_between_hosts(host, compass_target, datadumps) 1582 except Exception as e: 1583 print "# Error while processing interface %s" % iface_key 1584 raise 1575 1585 store_yaml(datadump) 1576 1586 except Exception as e:
Note:
See TracChangeset
for help on using the changeset viewer.