Changeset 8262 in genesis


Ignore:
Timestamp:
Aug 8, 2010, 12:43:27 PM (14 years ago)
Author:
rick
Message:

More pretty and informative

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nodes/gformat.py

    r8259 r8262  
    123123
    124124  for iface_key in datadump['iface_keys']:
    125     output += "## %(interface)s %(desc)s\n" % datadump[iface_key]
     125    if not datadump[iface_key].has_key('comment'):
     126      datadump[iface_key]['comment'] = None
     127    output += "## %(interface)s - %(desc)s - %(comment)s\n" % datadump[iface_key]
    126128
    127129    try:
     
    129131      (ip, netmask) = datadump[iface_key]['ip'].split('/')
    130132      datadump[iface_key]['subnet'] = netmask2subnet(netmask)
    131     except AttributeError:
     133    except (AttributeError, ValueError):
    132134      output += "# not autoritive\n\n"
    133135      continue
     
    238240  """ Get configuration yaml for 'item'"""
    239241  gfile = NODE_DIR + '/%s/wleiden.yaml' % item
    240   gfile = 'test.yaml'
    241242
    242243  f = open(gfile, 'r')
     
    277278  output = generate_header("#")
    278279  output += "# Genesis config yaml style\n"
     280  output += "# vim:ts=2:et:sw=2:ai\n"
    279281  output += "#\n"
    280282  iface_keys = [elem for elem in datadump.keys() if elem.startswith('iface_')]
     
    286288  for iface_key in sorted(iface_keys):
    287289    output += "%s:\n" % iface_key
    288     output += yaml.dump(datadump[iface_key], default_flow_style=False)
     290    for key in sorted(datadump[iface_key]):
     291      #output += yaml.dump(datadump[iface_key], default_flow_style=False)
     292      output += "  %s: %s\n" % (key, datadump[iface_key][key])
    289293    output += "\n\n"
    290294
Note: See TracChangeset for help on using the changeset viewer.