Browse Source

Colored nodes in topology maps

Jeremy Stretch 8 years ago
parent
commit
9f67da00d1
1 changed files with 3 additions and 2 deletions
  1. 3 2
      netbox/extras/models.py

+ 3 - 2
netbox/extras/models.py

@@ -337,9 +337,10 @@ class TopologyMap(models.Model):
             # Add each device to the graph
             devices = []
             for query in device_set.split(';'):  # Split regexes on semicolons
-                devices += Device.objects.filter(name__regex=query)
+                devices += Device.objects.filter(name__regex=query).select_related('device_role')
             for d in devices:
-                subgraph.node(d.name)
+                fillcolor = '#{}'.format(d.device_role.color)
+                subgraph.node(d.name, style='filled', fillcolor=fillcolor)
 
             # Add an invisible connection to each successive device in a set to enforce horizontal order
             for j in range(0, len(devices) - 1):