Virtual chassis search displays duplicate entries
See original GitHub issueNetBox version
v2.10.6
Python version
3.8
Steps to Reproduce
- Create a device named test-vc-1-1
- Create a device named test-vc-1-2
- Create a virtual chassis named test-vc-1 and bundle the two device created in 1. and 2.
- In the virtual chassis view perform a search by name using test-vc-1
Expected Behavior
The list view should display only one entry for the virtual chassis (check the screenshot of the search using Nebox 2.9 release)
Observed Behavior
The list view displays twice the same entry for the virtual chassis, one per member (check the screenshot of the search using Nebox 2.10.6 release)
Expected behaviour in netbox 2.9
Observed behaviour in netbox 2.10
Solution hint
After some code investigation it seems that the VirtualChassisFilterSet.search
method in dcim/filter.py
has something wrong with the forged queryset.
def search(self, queryset, name, value):
if not value.strip():
return queryset
qs_filter = (
Q(name__icontains=value) |
Q(members__name__icontains=value) |
Q(domain__icontains=value)
)
return queryset.filter(qs_filter)
When you modify the queryset with the following code, the entry is not duplicated anymore in the WebUI.
def search(self, queryset, name, value):
if not value.strip():
return queryset
qs_filter = (
Q(name__icontains=value) |
Q(members__name__icontains=value) |
Q(domain__icontains=value)
)
return queryset.filter(qs_filter).distinct() # adding distinct de-duplicate the VC
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Monitoring the Virtual Chassis Status and Statistics on EX ...
To view Virtual Chassis monitoring details in the J-Web interface for a Virtual Chassis, select Monitor > Virtual Chassis. To view member details...
Read more >Solved: How to check there are duplicate records on a tabl...
Run this in your background Script. It will give you all the Tag names which have duplicate entries. It doesn't check for Duplicate...
Read more >4. EX Virtual Chassis - JUNOS Enterprise Switching [Book]
EX Virtual Chassis EX4200 switches support clustering of up to ten 4200 chassis ... The highlighted entry in Switch 0's mapping table shows...
Read more >Virtual Chassis Technology Best Practices
Table 1 shows the switch models that support Virtual Chassis and the roles they play in a mixed Virtual Chassis configuration—RE or line...
Read more >Count Duplicates in a List Online Tool - Somacon
Use this to quickly aggregate the values to find duplicate lines, or to count the number of ... Every line that is repeated...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jeremystretch I can take the lead on this one if you agree. Quick and easy fix.
Open for volunteers