Changeset 10053 in genesis for tools


Ignore:
Timestamp:
Mar 7, 2012, 10:08:06 PM (13 years ago)
Author:
rick
Message:

Serious hacking and cleanups to get all keys in the right format and stored to the proper files.

Please do mind that I remove the Bullet2,etc... information now, I will dynamically add this at an later stage.

Related-To: ticket:117

Location:
tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tools/genesis-to-yaml.pl

    r10050 r10053  
    8080} else {
    8181  print "ileiden   : no\n";
     82}
     83
     84foreach $key  ('internalif', 'nat', 'internalroute', 'remote_access', 'gateway', 'firewall_block') {
     85  if ($$key) {
     86    print "$key: $$key\n";
     87  }
    8288}
    8389
  • tools/gformat.py

    r10052 r10053  
    277277    output += "tproxy_enable='NO'\n"
    278278
     279  # Extra Proxy configuration
     280  if datadump['nodetype'] == 'Proxy':
     281    output += '\n# Disable routing\ngateway_enable="no"\n'
     282
     283  output += '\ninternalif="%s"\n' % datadump['internalif']
     284
    279285  output += '\n'
    280286  # lo0 configuration:
     
    366372  datadump = yaml.load(f,Loader=Loader)
    367373  datadump['autogen_iface_keys'] = get_interface_keys(datadump)
     374  datadump['autogen_item'] = item
    368375  f.close()
    369376
     
    372379def store_yaml(datadump):
    373380  """ Store configuration yaml for 'item'"""
     381  item = datadump['autogen_item']
    374382  gfile = os.path.join(NODE_DIR,item,'wleiden.yaml')
    375383
    376384  f = open(gfile, 'w')
    377   del datadump['autogen_iface_keys']
    378385  f.write(generate_wleiden_yaml(datadump))
    379386  f.close()
     
    412419
    413420
    414 def write_yaml(item, datadump):
    415   """ Write configuration yaml for 'item'"""
    416   gfile = os.path.join(NODE_DIR,item,'wleiden.yaml')
    417 
    418   f = open(gfile, 'w')
    419   f.write(format_wleiden_yaml(datadump))
    420   f.close()
    421 
    422 
    423 
    424421def generate_resolv_conf(datadump):
    425422  """ Generate configuration file '/etc/resolv.conf' """
     
    429426# Try local (cache) first
    430427nameserver 127.0.0.1
    431 
     428"""
     429  if datadump['nodetype'] == 'Proxy':
     430    output += """\
     431nameserver 8.8.8.8   # Google Public NameServer
     432nameserver 8.8.4.4   # Google Public NameServer
     433"""
     434  else:
     435    output += """\
    432436# Proxies are recursive nameservers
    433437# needs to be in resolv.conf for dnsmasq as well
    434438""" % datadump
    435 
    436   for proxy in get_proxylist():
    437     proxy_ip = get_yaml(proxy)['masterip']
    438     output += "nameserver %-15s # %s\n" % (proxy_ip, proxy)
     439    for proxy in get_proxylist():
     440      proxy_ip = get_yaml(proxy)['masterip']
     441      output += "nameserver %-15s # %s\n" % (proxy_ip, proxy)
     442
    439443  return output
    440444
     
    478482def generate_wleiden_yaml(datadump):
    479483  """ Generate (petty) version of wleiden.yaml"""
     484  for key in datadump.keys():
     485    if key.startswith('autogen_'):
     486      del datadump[key]
     487
    480488  output = generate_header("#")
    481489  output += format_wleiden_yaml(datadump)
     
    843851        datadumps[get_fqdn(datadump)] = datadump
    844852
     853      for key,datadump in datadumps.iteritems():
    845854        datadump['latitude'], datadump['longitude'] = rdnap.rd2etrs(datadump['rdnap_x'], datadump['rdnap_y'])
    846         write_yaml(host, datadump)
     855        store_yaml(datadump)
    847856    elif sys.argv[1] == "list":
    848857      if sys.argv[2] == "nodes":
Note: See TracChangeset for help on using the changeset viewer.