Add 'L2VPN' column to device/VM interfaces table view #6821

Closed
opened 2025-12-29 19:45:46 +01:00 by adam · 7 comments
Owner

Originally created by @candlerb on GitHub (Aug 16, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.3-beta2

Feature type

Change to existing functionality

Proposed functionality

When viewing a table of interfaces on a device or VM, and configuring the columns to view, be able to select a column for "L2VPN" (analogous to FHRP Group, Parent etc).

Use case

When browsing a router with many interfaces/subinterfaces and L2VPN terminations, you want to see which L2VPN each interface connects to.

Since you can already do this for many other objects which link to interface, I suspect this was just an oversight.

Database changes

None

External dependencies

None

Originally created by @candlerb on GitHub (Aug 16, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.3-beta2 ### Feature type Change to existing functionality ### Proposed functionality When viewing a table of interfaces on a device or VM, and configuring the columns to view, be able to select a column for "L2VPN" (analogous to FHRP Group, Parent etc). ### Use case When browsing a router with many interfaces/subinterfaces and L2VPN terminations, you want to see which L2VPN each interface connects to. Since you can already do this for many other objects which link to interface, I suspect this was just an oversight. ### Database changes None ### External dependencies None
adam added the status: acceptedtype: feature labels 2025-12-29 19:45:46 +01:00
adam closed this issue 2025-12-29 19:45:46 +01:00
Author
Owner

@candlerb commented on GitHub (Aug 16, 2022):

Ref discussion: https://github.com/netbox-community/netbox/discussions/9727#discussioncomment-3409332

@candlerb commented on GitHub (Aug 16, 2022): Ref discussion: https://github.com/netbox-community/netbox/discussions/9727#discussioncomment-3409332
Author
Owner

@jeremystretch commented on GitHub (Aug 17, 2022):

Since you can already do this for many other objects which link to interface, I suspect this was just an oversight.

Something unique about this relationship is that we're following a reverse generic relation that should only ever return a single object. Unfortunately there's no built-in relation type for this in Django, so we might want to experiment a bit with the ideal solution.

@jeremystretch commented on GitHub (Aug 17, 2022): > Since you can already do this for many other objects which link to interface, I suspect this was just an oversight. Something unique about this relationship is that we're following a reverse generic relation that should only ever return a _single_ object. Unfortunately there's no built-in relation type for this in Django, so we might want to experiment a bit with the ideal solution.
Author
Owner

@candlerb commented on GitHub (Aug 17, 2022):

Is the problem specifically to do with table views?

The field is already present in the interfaces detail view page (e.g. /dcim/interfaces/666/)

image

            <tr>
              <th scope="row">L2VPN</th>
              <td>{{ object.l2vpn_termination.l2vpn|linkify|placeholder }}</td>
            </tr>

and it just comes from:

    @property
    def l2vpn_termination(self):
        return self.l2vpn_terminations.first()
@candlerb commented on GitHub (Aug 17, 2022): Is the problem specifically to do with table views? The field is already present in the interfaces detail view page (e.g. `/dcim/interfaces/666/`) ![image](https://user-images.githubusercontent.com/44789/185207006-f05c795d-a6bb-4490-a402-8a4902b644bf.png) ``` <tr> <th scope="row">L2VPN</th> <td>{{ object.l2vpn_termination.l2vpn|linkify|placeholder }}</td> </tr> ``` and it just comes from: ``` @property def l2vpn_termination(self): return self.l2vpn_terminations.first() ```
Author
Owner

@jeremystretch commented on GitHub (Aug 17, 2022):

That's certainly a valid approach. I was just thinking we should try to identify something slightly more elegant, like a custom GenericRelation that returns a single object. Granted, that's likely going to involve a lot of work, and probably shouldn't block this FR.

@jeremystretch commented on GitHub (Aug 17, 2022): That's certainly a valid approach. I was just thinking we should try to identify something slightly more elegant, like a custom GenericRelation that returns a single object. Granted, that's likely going to involve a lot of work, and probably shouldn't block this FR.
Author
Owner

@candlerb commented on GitHub (Aug 17, 2022):

Looks like what you have already is pretty standard:
https://stackoverflow.com/questions/7837330/generic-one-to-one-relation-in-django

I presume you could also enforce it by putting a unique constraint on (object_type, object_id)

@candlerb commented on GitHub (Aug 17, 2022): Looks like what you have already is pretty standard: https://stackoverflow.com/questions/7837330/generic-one-to-one-relation-in-django I presume you could also enforce it by putting a unique constraint on (object_type, object_id)
Author
Owner

@DanSheps commented on GitHub (Aug 17, 2022):

I think what Jeremy means is instead to have a custom relation class to make things a little cleaner to try and DRY up our code, otherwise we are repeating the same pattern all over the place but with different names.

Ideally, a GenericOneToOne() would be better but I don't know if that is possible or not.

@DanSheps commented on GitHub (Aug 17, 2022): I think what Jeremy means is instead to have a custom relation class to make things a little cleaner to try and DRY up our code, otherwise we are repeating the same pattern all over the place but with different names. Ideally, a GenericOneToOne() would be better but I don't know if that is possible or not.
Author
Owner

@ITJamie commented on GitHub (Aug 29, 2022):

just adding an additional note from https://github.com/netbox-community/netbox/issues/10194.
The same is also needed when viewing a vlan list to show that a vlan is part of an l2vpn

@ITJamie commented on GitHub (Aug 29, 2022): just adding an additional note from https://github.com/netbox-community/netbox/issues/10194. The same is also needed when viewing a vlan list to show that a vlan is part of an l2vpn
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6821