Changeset 10655 in genesis


Ignore:
Timestamp:
May 2, 2012, 10:49:02 PM (13 years ago)
Author:
rick
Message:

Allow some reverse entries, not always all of them, this highly is sometimes
highly confusing, as the reverse PTR is shown in output from traceroute and
such. Multiple names makes it look a different host all the time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r10654 r10655  
    995995      wleiden_cname[datadump['nodename']] = fqdn
    996996
    997     wleiden_zone[fqdn].append(datadump['masterip'])
     997    wleiden_zone[fqdn].append((datadump['masterip'], True))
    998998
    999999    # Hacking to get proper DHCP IPs and hostnames
     
    10061006        dhcp_part = ".".join(ip.split('.')[0:3])
    10071007        if ip != datadump['masterip']:
    1008           wleiden_zone["dhcp-gateway-%s.%s" % (iface_name, fqdn)].append(ip)
     1008          wleiden_zone["dhcp-gateway-%s.%s" % (iface_name, fqdn)].append((ip, False))
    10091009        for i in range(int(dhcp_start), int(dhcp_stop) + 1):
    1010           wleiden_zone["dhcp-%s-%s.%s" % (i, iface_name, fqdn)].append("%s.%s" % (dhcp_part, i))
     1010          wleiden_zone["dhcp-%s-%s.%s" % (i, iface_name, fqdn)].append(("%s.%s" % (dhcp_part, i), True))
    10111011      except (AttributeError, ValueError):
    10121012        # First push it into a pool, to indentify the counter-part later on
     
    10481048    if len(value) == 1:
    10491049      (iface_name, fqdn, ip) = value[0]
    1050       wleiden_zone["2unused-%s.%s" % (iface_name, fqdn)].append(ip)
     1050      wleiden_zone["2unused-%s.%s" % (iface_name, fqdn)].append((ip, True))
    10511051
    10521052      # Device DNS names
    10531053      if 'cnode' in fqdn.lower():
    1054         wleiden_zone["d-at-%s.%s" % (iface_name, fqdn)].append(showaddr(parseaddr(ip) + 1))
    1055         wleiden_cname["d-at-%s.%s" % (iface_name,sn(fqdn))] = "d-at-%s.%s" % (iface_name, fqdn)
     1054        wleiden_zone["d-at-%s.%s" % (iface_name, fqdn)].append((showaddr(parseaddr(ip) + 1), False))
     1055        wleiden_cname["d-at-%s.%s" % (iface_name,sn(fqdn))] = "d-at-%s.%s" % ((iface_name, fqdn))
    10561056
    10571057    elif len(value) == 2:
    10581058      (a_iface_name, a_fqdn, a_ip) = value[0]
    10591059      (b_iface_name, b_fqdn, b_ip) = value[1]
    1060       wleiden_zone["2%s.%s" % (b_fqdn,a_fqdn)].append(a_ip)
    1061       wleiden_zone["2%s.%s" % (a_fqdn,b_fqdn)].append(b_ip)
     1060      wleiden_zone["2%s.%s" % (b_fqdn,a_fqdn)].append((a_ip, True))
     1061      wleiden_zone["2%s.%s" % (a_fqdn,b_fqdn)].append((b_ip, True))
    10621062
    10631063      # Device DNS names
    10641064      if 'cnode' in a_fqdn.lower() and 'cnode' in b_fqdn.lower():
    1065         wleiden_zone["d-at-%s.%s" % (a_iface_name, a_fqdn)].append(showaddr(parseaddr(a_ip) + 1))
    1066         wleiden_zone["d-at-%s.%s" % (b_iface_name, b_fqdn)].append(showaddr(parseaddr(b_ip) - 1))
     1065        wleiden_zone["d-at-%s.%s" % (a_iface_name, a_fqdn)].append((showaddr(parseaddr(a_ip) + 1), False))
     1066        wleiden_zone["d-at-%s.%s" % (b_iface_name, b_fqdn)].append((showaddr(parseaddr(b_ip) - 1), False))
    10671067        wleiden_cname["d-at-%s.%s" % (a_iface_name,sn(a_fqdn))] = "d-at-%s.%s" % (a_iface_name, a_fqdn)
    10681068        wleiden_cname["d-at-%s.%s" % (b_iface_name,sn(b_fqdn))] = "d-at-%s.%s" % (b_iface_name, b_fqdn)
     
    10751075        (iface_name, fqdn, ip) = item
    10761076        pool_name = "2pool-" + showaddr(key).replace('.','-') + "-" + pool_to_name(fqdn,pool_members)
    1077         wleiden_zone["%s.%s" % (pool_name, fqdn)].append(ip)
     1077        wleiden_zone["%s.%s" % (pool_name, fqdn)].append((ip, True))
    10781078
    10791079  # Include static DNS entries
     
    10961096        wleiden_raw[k] = item
    10971097      elif valid_addr(item):
    1098         wleiden_zone[k].append(item)
     1098        wleiden_zone[k].append((item, False))
    10991099      else:
    11001100        wleiden_cname[k] = item
     
    11271127  f.write(dns_header % details)
    11281128
    1129   for host,ips in wleiden_zone.iteritems():
    1130     for ip in ips:
     1129  for host,items in wleiden_zone.iteritems():
     1130    for ip,reverse in items:
    11311131      if valid_addr(ip):
    11321132        f.write("%s.wleiden.net. IN A %s \n" % (host.lower(), ip))
     
    11451145    #XXX: Not effient, fix to proper data structure and do checks at other
    11461146    # stages
    1147     for host,ips in wleiden_zone.iteritems():
    1148       for ip in ips:
     1147    for host,items in wleiden_zone.iteritems():
     1148      for ip,reverse in items:
     1149        if not reverse:
     1150          continue
    11491151        if valid_addr(ip):
    1150           if int(ip.split('.')[1]) == s:
    1151             rev_ip = '.'.join(reversed(ip.split('.')))
    1152             f.write("%s.in-addr.arpa. IN PTR %s.wleiden.net.\n" % (rev_ip.lower(), host.lower()))
     1152          if valid_addr(ip):
     1153            if int(ip.split('.')[1]) == s:
     1154              rev_ip = '.'.join(reversed(ip.split('.')))
     1155              f.write("%s.in-addr.arpa. IN PTR %s.wleiden.net.\n" % (rev_ip.lower(), host.lower()))
    11531156    f.close()
    11541157
Note: See TracChangeset for help on using the changeset viewer.