Changeset 8598 in genesis
- Timestamp:
- Oct 30, 2010, 11:07:39 PM (14 years ago)
- Location:
- nodes
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nodes/gformat.py
r8588 r8598 545 545 def make_dns(): 546 546 items = dict() 547 547 548 # hostname is key, IP is value 548 549 wleiden_zone = dict() 549 550 wleiden_cname = dict() 551 550 552 pool = dict() 551 553 for node in get_hostlist(): … … 559 561 wleiden_zone[fqdn] = datadump['masterip'] 560 562 561 #items['node'] = node 562 #items['wdir'] = "./static/%(node)s" % items 563 #if not os.path.isdir(items['wdir']): 564 # os.makedirs(items['wdir']) 563 # Hacking to get proper DHCP IPs and hostnames 565 564 for iface_key in get_interface_keys(datadump): 566 iface_name = datadump[iface_key]['interface'].replace(':'," _alias_")565 iface_name = datadump[iface_key]['interface'].replace(':',"-alias-") 567 566 (ip, netmask) = datadump[iface_key]['ip'].split('/') 568 567 try: … … 585 584 continue 586 585 587 # wleiden_zone["2%s-%s.%s" % ("unused", iface_name, fqdn)] = ip 588 # #XXX: automatic naming convention namely 2 + remote.lower() 586 # Automatic naming convention of interlinks namely 2 + remote.lower() 589 587 for (key,value) in pool.iteritems(): 590 588 if len(value) == 1: … … 600 598 for item in value: 601 599 (iface_name, fqdn, ip) = item 602 pool_name = "2pool-" + showaddr(key).replace('.','-') + "-" + " _".join(sorted(list(set(pool_members) - set([fqdn]))))600 pool_name = "2pool-" + showaddr(key).replace('.','-') + "-" + "-".join(sorted(list(set(pool_members) - set([fqdn])))) 603 601 wleiden_zone["%s.%s" % (pool_name, fqdn)] = ip 602 603 # Include static DNS entries 604 # XXX: Should they override the autogenerated results? 605 # XXX: Convert input to yaml more useable. 606 # Format: 607 ##; this is a comment 608 ## roomburgh=CNodeRoomburgh1 609 ## apkerk1.CNodeVosko=172.17.176.8 ;this as well 610 f = open('../dns/staticDNS.conf','r') 611 for l in f.readlines(): 612 # Get rid of comments 613 l = l.strip().split(';')[0].strip() 614 if l: 615 k,v = l.split('=') 616 if valid_addr(v): 617 wleiden_zone[k] = v 618 else: 619 wleiden_cname[k] = v 620 f.close() 604 621 622 details = dict() 623 # 24 updates a day allowed 624 details['serial'] = time.strftime('%Y%m%d%H') 625 626 dns_header = ''' 627 $TTL 3h 628 %(zone)s. SOA sunny.wleiden.net. beheer.lijst.wirelessleiden.nl. ( %(serial)s 1d 12h 1w 3h ) 629 ; Serial, Refresh, Retry, Expire, Neg. cache TTL 630 631 NS sunny.wleiden.net. 632 \n''' 633 605 634 606 f = open("db.wleiden.net", "w") 635 if not os.path.isdir('dns'): 636 os.makedirs('dns') 637 details['zone'] = 'wleiden.net' 638 f = open("dns/db." + details['zone'], "w") 639 f.write(dns_header % details) 640 607 641 for host,ip in wleiden_zone.iteritems(): 608 f.write("%s.wleiden.net. A %s ~\n" % (host, ip)) 642 if valid_addr(ip): 643 f.write("%s.wleiden.net. IN A %s \n" % (host, ip)) 609 644 for source,dest in wleiden_cname.iteritems(): 610 f.write("%s.wleiden.net. CNAME %s.wleiden.net. ~\n" % (source, dest))645 f.write("%s.wleiden.net. IN CNAME %s.wleiden.net.\n" % (source, dest)) 611 646 f.close() 612 f = open("db.172.in-addr.arpa", "w") 613 for host,ip in wleiden_zone.iteritems(): 614 rev_ip = '.'.join(reversed(ip.split('.'))) 615 f.write("%s.in-addr.arpa. PTR %s.wleiden.net. ~\n" % (rev_ip, host)) 616 f.close() 647 648 # Create whole bunch of specific sub arpa zones. To keep it compliant 649 for s in range(16,32): 650 details['zone'] = '%i.172.in-addr.arpa' % s 651 f = open("dns/db." + details['zone'], "w") 652 f.write(dns_header % details) 653 654 #XXX: Not effient, fix to proper data structure and do checks at other 655 # stages 656 for host,ip in wleiden_zone.iteritems(): 657 if valid_addr(ip): 658 if int(ip.split('.')[1]) == s: 659 rev_ip = '.'.join(reversed(ip.split('.'))) 660 f.write("%s.in-addr.arpa. IN PTR %s.wleiden.net.\n" % (rev_ip, host)) 661 f.close() 617 662 618 663 619 664 def usage(): 620 print """Usage: %s <standalone [port] |test [test arguments]|static >665 print """Usage: %s <standalone [port] |test [test arguments]|static|dns> 621 666 Examples: 667 \tdns = Generate BIND compliant zone files in dns. 622 668 \tstandalone = Run configurator webserver [default port=8000] 623 669 \tstatic = Generate all config files and store on disk
Note:
See TracChangeset
for help on using the changeset viewer.