- Timestamp:
- Apr 13, 2012, 3:30:36 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r10467 r10468 672 672 def generate_resolv_conf(datadump): 673 673 """ 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 }} 676 687 search wleiden.net 677 """ 678 if datadump['nodetype'] == 'Proxy': 679 output += """\ 680 # try local (cache) first 688 689 # Try local (cache) first 681 690 nameserver 127.0.0.1 691 692 {% if service_proxy or service_ileiden or nodetype == 'Proxy' -%} 682 693 nameserver 8.8.8.8 # Google Public NameServer 683 694 nameserver 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 710 701 711 702 def generate_motd(datadump):
Note:
See TracChangeset
for help on using the changeset viewer.