Index: /tools/yaml2nag.py
===================================================================
--- /tools/yaml2nag.py	(revision 10391)
+++ /tools/yaml2nag.py	(revision 10393)
@@ -8,38 +8,20 @@
 import gformat
 
-NODE_PREFIX = 'nodes-7-2'
-
 def is_ap(ifacedump):
   return ifacedump.has_key('dhcp') and not ifacedump['dhcp'] == 'no'
 
 def is_iris(node):
- return node.has_key('release') and node['release'] in ['8.0-RELEASE', '7.2-RELEASE', '8.1-RELEASE', '8.2-RELEASE']
+  return node.has_key('release') and node['release'] in ['8.0-RELEASE', '7.2-RELEASE', '8.1-RELEASE', '8.2-RELEASE']
 
-if __name__ == '__main__':
-  for host in gformat.get_hostlist():
-    datadump = gformat.get_yaml(host)
+def is_up(datadump):
+  return datadump['status'] == 'up'
 
-    # Make sure to process only active IRIS nodes
-    if not is_iris(datadump) or not datadump['status'] == 'up':
-      continue
 
-    # Default hostgroup
-    hostgroups = [NODE_PREFIX,]
 
-    # Interface groups
-    for iface in datadump['autogen_iface_keys']:
-      ifacedump = datadump[iface]
-      if (ifacedump['status'] == 'up' and not is_ap(ifacedump)):
-        key = 'iface-%s' % ifacedump['autogen_ifname']
-        if not key in hostgroups:
-          hostgroups.append(key)
-
-    if datadump['ileiden']:
-      hostgroups.append('nodes-ileiden')
-
-    datadump['hostgroups'] = ','.join(hostgroups)
-    print """
+def print_host(datadump, hostgroups):
+  datadump['hostgroups'] = ','.join(hostgroups)
+  print """
 define host{
-  use        host-pnp
+  use        %(use)s
   host_name  %(autogen_realname)s
   alias      %(autogen_realname)s
@@ -47,4 +29,42 @@
   hostgroups %(hostgroups)s
 }
-  
-    """ % datadump
+""" % datadump
+
+
+if __name__ == '__main__':
+  # Process all hosts
+  for host in gformat.get_hostlist():
+    datadump = gformat.get_yaml(host)
+
+    # Make sure to process only active IRIS nodes
+    if not is_iris(datadump) or not is_up(datadump):
+      continue
+
+    hostgroups = []
+    if datadump['nodetype'] == 'CNode':
+      datadump['use'] = 'host-pnp'
+      hostgroups.append('nodes-7-2')
+
+      # Interface groups
+      for iface in datadump['autogen_iface_keys']:
+        ifacedump = datadump[iface]
+        if is_up(ifacedump) and not is_ap(ifacedump):
+          key = 'iface-%s' % ifacedump['autogen_ifname']
+          if not key in hostgroups:
+            hostgroups.append(key)
+
+      # ileiden groups
+      if datadump['ileiden']:
+        hostgroups.append('nodes-ileiden')
+
+      print_host(datadump, hostgroups)
+    elif datadump['nodetype'] == 'Proxy':
+      datadump['use'] = 'host-proxy'
+      hostgroups.append('proxies')
+
+      print_host(datadump, hostgroups)
+    else:
+      print "# ERROR: nodetype %(nodetype)s for %(autogen_realname)s not defined" % datadump
+
+
+
