Skip to content

Add VLAN netident to ipdevinfo ports table#3473

Merged
lunkwill42 merged 3 commits intomasterfrom
show-vlan-descr-in-ipdevinfo
Oct 30, 2025
Merged

Add VLAN netident to ipdevinfo ports table#3473
lunkwill42 merged 3 commits intomasterfrom
show-vlan-descr-in-ipdevinfo

Conversation

@stveit
Copy link
Copy Markdown
Contributor

@stveit stveit commented Aug 27, 2025

Scope and purpose

Fixes #2160.

Adds new column showing VLAN netident to the Ports table in ipdevinfo.

Adds VLAN netident to the results of the interface API. This was necessary as the Port table gets its data from that endpoint.

Uses prefetch_related to reduce database lookups. We access the correct SwPortVlan via self.swport_vlans, which returns a set, so select_related cannot be used.

This was originally called "Vlan Description", but was changed to netident as the NAV Vlan class has both a description and netident value, but the netident value is the most relevant to use here

This pull request

  • changes the API

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • This pull request is based on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this adds a new Python source code file: Added the boilerplate header to that file

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 27, 2025

Test results

    27 files      27 suites   45m 17s ⏱️
 2 631 tests  2 631 ✅ 0 💤 0 ❌
19 438 runs  19 438 ✅ 0 💤 0 ❌

Results for commit b23fc35.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 27, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 62.67%. Comparing base (1019a55) to head (b23fc35).
⚠️ Report is 220 commits behind head on master.

Files with missing lines Patch % Lines
python/nav/models/manage.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3473   +/-   ##
=======================================
  Coverage   62.67%   62.67%           
=======================================
  Files         611      611           
  Lines       45100    45107    +7     
  Branches       43       43           
=======================================
+ Hits        28266    28272    +6     
- Misses      16824    16825    +1     
  Partials       10       10           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stveit stveit force-pushed the show-vlan-descr-in-ipdevinfo branch from fe9a66b to 9f6644a Compare August 27, 2025 14:25
@stveit stveit self-assigned this Aug 27, 2025
@stveit stveit force-pushed the show-vlan-descr-in-ipdevinfo branch from 9f6644a to ab9ce74 Compare August 28, 2025 11:13
@sonarqubecloud
Copy link
Copy Markdown

@stveit stveit marked this pull request as ready for review August 28, 2025 11:22
@stveit stveit marked this pull request as draft August 28, 2025 11:22
@stveit stveit changed the title Add vlan description to ipdevinfo ports table Add VLAN description to ipdevinfo ports table Aug 29, 2025
@lunkwill42
Copy link
Copy Markdown
Member

I would post before/after, but not sure if NTNU would be happy about me posting images of their port stuff?

Good call. Never post customer data online unless you have explicit consent.

@lunkwill42 lunkwill42 self-requested a review August 29, 2025 13:59
Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue mentions #1935, which was solved by #1955 - it basically uses str(vlan_object) as "description" - which, in fact, is the netident, not the "description". Netidents are more prevalent.

But it sounds like you need input on what SwportVlan is and how to interpret the data, so let's have a f2f chat about this feature next week...

@stveit stveit marked this pull request as ready for review October 30, 2025 08:41
Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works very well for me, only nitpicks left :)

"""

queryset = manage.Interface.objects.all()
queryset = manage.Interface.objects.prefetch_related('swport_vlans__vlan').all()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't strictly necessary for the new feature to work, however it is here for performance reasons - which means it should be in a separate commit that explains why it was added :)

Comment on lines +2008 to +2013
@property
def vlan_description(self):
if self.trunk:
return None
swportvlan = self.swport_vlans.first()
return swportvlan.vlan.net_ident if swportvlan else None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, this should be called vlan_netident. Other than that, it seems you forgot the discussed docstring to explain that this doesn't return results for trunk ports, since they carry multiple VLANs.

@stveit stveit force-pushed the show-vlan-descr-in-ipdevinfo branch 2 times, most recently from e62a707 to dc406b7 Compare October 30, 2025 10:23
@stveit stveit force-pushed the show-vlan-descr-in-ipdevinfo branch from dc406b7 to b23fc35 Compare October 30, 2025 10:24
@sonarqubecloud
Copy link
Copy Markdown

@stveit stveit changed the title Add VLAN description to ipdevinfo ports table Add VLAN netident to ipdevinfo ports table Oct 30, 2025
@lunkwill42 lunkwill42 self-requested a review October 30, 2025 10:53
@lunkwill42 lunkwill42 merged commit 2b80c14 into master Oct 30, 2025
17 checks passed
@lunkwill42 lunkwill42 deleted the show-vlan-descr-in-ipdevinfo branch October 30, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show VLAN description in the portlist in ipdevinfo

2 participants