question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Virtual chassis search displays duplicate entries

See original GitHub issue

NetBox version

v2.10.6

Python version

3.8

Steps to Reproduce

  1. Create a device named test-vc-1-1
  2. Create a device named test-vc-1-2
  3. Create a virtual chassis named test-vc-1 and bundle the two device created in 1. and 2.
  4. 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

Netbox 2.9

Observed behaviour in netbox 2.10

image

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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
maximumGcommented, Mar 19, 2021

@jeremystretch I can take the lead on this one if you agree. Quick and easy fix.

0reactions
jeremystretchcommented, Mar 19, 2021

Open for volunteers

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found