Changeset 10468 in genesis for tools


Ignore:
Timestamp:
Apr 13, 2012, 3:30:36 AM (13 years ago)
Author:
rick
Message:

Make resolv.conf template more pretty. While here fix the hybrid setup for resolvers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r10467 r10468  
    672672def generate_resolv_conf(datadump):
    673673  """ Generate configuration file '/etc/resolv.conf' """
    674   output = generate_header("#");
    675   output += """\
     674  # XXX: This should properly going to be an datastructure soon
     675  datadump['autogen_header'] = generate_header("#")
     676  datadump['autogen_edge_nameservers'] = ''
     677  for host in get_proxylist():
     678    hostdump = get_yaml(host)
     679    datadump['autogen_edge_nameservers'] += "nameserver %(masterip)-15s # %(autogen_realname)s\n" % hostdump
     680  for host in get_hybridlist():
     681    hostdump = get_yaml(host)
     682    if hostdump['service_proxy'] or hostdump['service_ileiden']:
     683      datadump['autogen_edge_nameservers'] += "nameserver %(masterip)-15s # %(autogen_realname)s\n" % hostdump
     684
     685  return Template("""\
     686{{ autogen_header }}
    676687search wleiden.net
    677 """
    678   if datadump['nodetype'] == 'Proxy':
    679     output += """\
    680 # try local (cache) first
     688
     689# Try local (cache) first
    681690nameserver 127.0.0.1
     691
     692{% if service_proxy or service_ileiden or nodetype == 'Proxy' -%}
    682693nameserver 8.8.8.8   # Google Public NameServer
    683694nameserver 8.8.4.4   # Google Public NameServer
    684 """
    685   elif datadump['nodetype'] == 'Hybrid':
    686     output += """\
    687 # try local (cache) first
    688 nameserver 127.0.0.1
    689 """
    690     for proxy in get_proxylist():
    691       proxy_ip = get_yaml(proxy)['masterip']
    692       output += "nameserver %-15s # %s\n" % (proxy_ip, proxy)
    693     output += """\
    694 nameserver 8.8.8.8   # Google Public NameServer
    695 nameserver 8.8.4.4   # Google Public NameServer
    696 """
    697   else:
    698     output += """\
    699 # Try local (cache) first
    700 nameserver 127.0.0.1
    701 
    702 # Proxies are recursive nameservers
    703 # needs to be in resolv.conf for dnsmasq as well
    704 """ % datadump
    705     for proxy in get_proxylist():
    706       proxy_ip = get_yaml(proxy)['masterip']
    707       output += "nameserver %-15s # %s\n" % (proxy_ip, proxy)
    708 
    709   return output
     695{% else -%}
     696{{ autogen_edge_nameservers }}
     697{% endif -%}
     698""").render(datadump)
     699
     700
    710701
    711702def generate_motd(datadump):
Note: See TracChangeset for help on using the changeset viewer.