from alignak_backend.models import register_models

from graphviz import Digraph

dot = Digraph(format='png')
#dot.node_attr.update(color='lightblue2', style='filled')
#dot.graph_attr.update(nodesep='0.1')
dot.graph_attr.update(size="140,140")
#dot.edge_attr.update(weight='2.1')

models = register_models()

done = []
for name, schema in models.iteritems():
    for key, value in schema['schema'].iteritems():
        if not key.startswith("_"):
            if value['type'] == 'objectid':
                if name + " \/ " + value['data_relation']['resource'] not in done:
                    dot.edge(name, value['data_relation']['resource'])
                    done.append(name + " \/ " + value['data_relation']['resource'])
            elif value['type'] == 'list' and 'schema' in value:
                if value['schema']['type'] == 'objectid':
                    if name + " \/ " + value['schema']['data_relation']['resource'] not in done:
                        dot.edge(name, value['schema']['data_relation']['resource'])
                        done.append(name + " \/ " + value['schema']['data_relation']['resource'])

dot.render('model_schema', view=False)
@@ -101,16 +101,17 @@
 at='png'
+,
 )%0A#dot.n
@@ -307,18 +307,8 @@
 ()%0A%0A
-done = %5B%5D%0A
 for 
@@ -351,135 +351,304 @@
     
-for key, value in schema%5B'schema'%5D.iteritems():%0A        if not key.startswith(%22_%22):%0A            if value%5B'type'%5D == 'object
+color = ''%0A    if name == 'host':%0A       color = 'red'%0A    elif name == 'service':%0A       color = 'green'%0A    dot.node(name, color=color)%0A    for key, value in schema%5B'schema'%5D.iteritems():%0A        style = 'dashed'%0A        if 'required' in value and value%5B'required'%5D:%0A            style = 'sol
 id'
-:
 %0A   
@@ -656,638 +656,456 @@
     
-        if name + %22 %5C/ %22 + value%5B'data_relation'%5D%5B'resource'%5D not in done:%0A                    dot.edge(name, value%5B'data_relation'%5D%5B'resource'%5D)%0A                    done.append(name + %22 %5C/ %22 + value%5B'data_relation'%5D%5B'resource'%5D)%0A            elif value%5B'type'%5D == 'list' and 'schema' in value:%0A                if value%5B'schema'%5D%5B'type'%5D == 'objectid':%0A                    if name + %22 %5C/ %22 + value%5B'schema'%5D%5B'data_relation'%5D%5B'resource'%5D not in done:%0A                        dot.edge(name, value%5B'schema'%5D%5B'data_relation'%5D%5B'resource'%5D)%0A                        done.append(name + %22 %5C/ %22 + value%5B'schema'%5D%5B'data_relation'%5D%5B'resource'%5D
+if not key.startswith(%22_%22):%0A            if value%5B'type'%5D == 'objectid':%0A                dot.edge(name, value%5B'data_relation'%5D%5B'resource'%5D, color=color, label=key, fontcolor=color, style=style)%0A            elif value%5B'type'%5D == 'list' and 'schema' in value:%0A                if value%5B'schema'%5D%5B'type'%5D == 'objectid':%0A                    dot.edge(name, value%5B'schema'%5D%5B'data_relation'%5D%5B'resource'%5D, color=color, label=key, fontcolor=color, style=style
 )%0A%0Ad

Update script for graph