diff --git a/netbox/extras/api/views.py b/netbox/extras/api/views.py index 381956145..167a28881 100644 --- a/netbox/extras/api/views.py +++ b/netbox/extras/api/views.py @@ -59,7 +59,9 @@ class TopologyMapView(APIView): graph.add_edge(pydot.Edge('set{}'.format(i - 1), 'set{}'.format(i), style='invis')) # Add each device to the graph - devices = Device.objects.filter(name__regex=device_set) + devices = [] + for query in device_set.split(','): + devices += Device.objects.filter(name__regex=query) for d in devices: node = pydot.Node(d.name) subgraph.add_node(node) @@ -75,8 +77,9 @@ class TopologyMapView(APIView): # Compile list of all devices device_superset = Q() - for regex in tmap.device_sets: - device_superset = device_superset | Q(name__regex=regex) + for device_set in tmap.device_sets: + for query in device_set.split(','): + device_superset = device_superset | Q(name__regex=query) # Add all connections to the graph devices = Device.objects.filter(*(device_superset,)) diff --git a/netbox/extras/models.py b/netbox/extras/models.py index df5433519..0fff7fa2b 100644 --- a/netbox/extras/models.py +++ b/netbox/extras/models.py @@ -77,7 +77,10 @@ class TopologyMap(models.Model): name = models.CharField(max_length=50, unique=True) slug = models.SlugField(unique=True) site = models.ForeignKey(Site, related_name='topology_maps', blank=True, null=True) - device_patterns = models.TextField() + device_patterns = models.TextField(help_text="Identify devices to include in the diagram using regular expressions," + "one per line. Each line will result in a new tier of the drawing. " + "Separate multiple regexes on a line using commas. Devices will be " + "rendered in the order they are defined.") description = models.CharField(max_length=100, blank=True) class Meta: