Index: tools/gformat.py
===================================================================
--- tools/gformat.py	(revision 13327)
+++ tools/gformat.py	(revision 13328)
@@ -212,5 +212,5 @@
     wlan_count=0
     try:
-      for key in datadump['autogen_iface_keys']:
+      for key in get_interface_keys(datadump, True):
         datadump[key]['autogen_ifbase'] = key.split('_')[1]
         datadump[key]['autogen_gateway'] = datadump[key]['ip'].split('/')[0]
@@ -278,5 +278,5 @@
     datadump = get_yaml(host)
     try:
-      for iface_key in datadump['autogen_iface_keys']:
+      for iface_key in get_interface_keys(datadump):
         net_addr = network(datadump[iface_key]['ip'])
         poel[net_addr] += [(host,datadump[iface_key].copy())]
@@ -515,5 +515,5 @@
 
   dhcp_out = defaultdict(list)
-  for iface_key in datadump['autogen_iface_keys']:
+  for iface_key in get_interface_keys(datadump):
     ifname = datadump[iface_key]['autogen_ifname']
     if not datadump[iface_key].has_key('comment'):
@@ -578,5 +578,5 @@
 \n""").render(datadump)
 
-  for iface_key in datadump['autogen_iface_keys']:
+  for iface_key in get_interface_keys(datadump):
     if not datadump[iface_key].has_key('comment'):
       datadump[iface_key]['comment'] = None
@@ -613,5 +613,5 @@
 
   masterip_used = False
-  for iface_key in datadump['autogen_iface_keys']:
+  for iface_key in get_interface_keys(datadump):
     if datadump[iface_key]['ip'].startswith(datadump['masterip']):
       masterip_used = True
@@ -620,5 +620,5 @@
     addrs_list['lo0'].append((datadump['masterip'] + "/32", 'Master IP Not used in interface'))
 
-  for iface_key in datadump['autogen_iface_keys']:
+  for iface_key in get_interface_keys(datadump):
     ifacedump = datadump[iface_key]
     ifname = ifacedump['autogen_ifname']
@@ -892,7 +892,11 @@
 
 
-def get_interface_keys(config):
+def get_interface_keys(config, extra=False):
   """ Quick hack to get all interface keys, later stage convert this to a iterator """
-  return sorted([elem for elem in config.keys() if (elem.startswith('iface_') and not "lo0" in elem)])
+  elems = sorted([elem for elem in config.keys() if (elem.startswith('iface_') and not "lo0" in elem)])
+  if extra == False:
+    return filter(lambda x: not "extra" in x, elems)
+  else:
+    return elems
 
 
@@ -902,5 +906,5 @@
     for config in configs:
       ip_list.append(config['masterip'])
-      for iface_key in get_interface_keys(config):
+      for iface_key in get_interface_keys(config, True):
         l = config[iface_key]['ip']
         addr, mask = l.split('/')
@@ -1068,10 +1072,25 @@
 """
   table = []
-  for iface_key in datadump['autogen_iface_keys']:
+  for iface_key in get_interface_keys(datadump, True):
+    # Quick to avoid listing ath(4) interface as attached device
+    if 'ath0' in iface_key:
+      continue
     ifacedump = datadump[iface_key]
     if ifacedump.has_key('ns_ip'):
       x_ip = ifacedump['ns_ip'].split('/')[0]
-      x_proto = 'https' if 'M' in ifacedump['bridge_type'] else 'http'
-      table.append((ifacedump['autogen_ifname'], ifacedump['mode'], "%s://%s" % (x_proto, x_ip)))
+    else:
+      x_ip = ifacedump['ip'].split('/')[0]
+
+    if 'mode' in ifacedump:
+      x_mode = ifacedump['mode']
+    else:
+      x_mode = 'unknown'
+
+    if 'bridge_type' in ifacedump:
+      device_type = ifacedump['bridge_type']
+    else:
+      device_type = 'Unknown'
+
+    table.append((ifacedump['autogen_ifname'], x_mode, "http://%s" % x_ip, device_type))
 
   output += make_table(table)
@@ -1504,4 +1523,5 @@
   print """Usage: %(prog)s <argument>
 Argument:
+\tcleanup                      =  Cleanup all YAML files to specified format
 \tstandalone [port]            =  Run configurator webserver [8000]
 \tdns [outputdir]              =  Generate BIND compliant zone files in dns [./dns]
@@ -1715,5 +1735,5 @@
         datadump = get_yaml(host)
         ip2host[datadump['masterip']] = datadump['autogen_fqdn']
-        for iface in datadump['autogen_iface_keys']:
+        for iface in get_interface_keys(datadump):
           ip2host[datadump[iface]['autogen_gateway']] = datadump['autogen_fqdn']
 
@@ -1972,5 +1992,5 @@
             datadump['nodename'] = datadump['nodename'].lower()
 
-          for iface_key in datadump['autogen_iface_keys']:
+          for iface_key in get_interface_keys(datadump):
             try:
               # All our normal wireless cards are normal APs now
@@ -2091,5 +2111,5 @@
           datadump = get_yaml(system)
           ips = [datadump['masterip']]
-          for ifkey in datadump['autogen_iface_keys']:
+          for ifkey in get_interface_keys(datadump):
             ips.append(datadump[ifkey]['ip'].split('/')[0])
           print system, ' '.join(ips)
