mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
TopologyMap: Allow multiple device regexes per line
This commit is contained in:
@ -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,))
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user