Skip to content

Conversation

Kani999
Copy link
Contributor

@Kani999 Kani999 commented Sep 30, 2025

Description

This feature adds "BGP Sessions" tabs to the detail pages of various NetBox objects that are related to BGP sessions. This allows users to easily view all BGP sessions associated with a specific IP address, site, tenant, device, virtual machine, or ASN directly from their respective pages.

Changes Made

New Views Added

  • IPAddressBGPSessionsView: Displays BGP sessions where the IP address is either the local or remote address.
  • SiteBGPSessionsView: Displays BGP sessions associated with a site.
  • TenantBGPSessionsView: Displays BGP sessions associated with a tenant.
  • DeviceBGPSessionsView: Displays BGP sessions associated with a device (conditionally enabled via config).
  • VirtualMachineBGPSessionsView: Displays BGP sessions associated with a virtual machine.
  • ASNBGPSessionsView: Displays BGP sessions where the ASN is either the local or remote AS.
  • InterfaceBGPSessionsView: Displays BGP sessions where the Interface IP Addresses is either the local or remote address
    • Interface -> IP Addresses -> Local address + Remote address

Configuration Updates

  • Added support for device_ext_page config option in PLUGINS_CONFIG['netbox_bgp']:
    • "left", "right", "full_width": Inline display (existing behavior).
    • "tab": Display BGP sessions as a tab on device pages.

Files Modified

  • template_content.py: Added new view classes and conditional registration.
  • README.md: Updated documentation for the new config option.

Benefits

  • Improved navigation: Users can access BGP sessions directly from related object pages without searching.
  • Consistent UI: All related objects now have a unified way to view associated BGP sessions.
  • Configurable: Device display can be toggled between inline and tab modes.

Testing

  • Verified tabs appear on IP address, site, tenant, virtual machine, and ASN pages.
  • Confirmed badge counts match the number of related sessions.
  • Tested conditional device tab registration based on config.

Additional Notes

This implementation uses NetBox's ObjectChildrenView and @register_model_view decorator for consistency with existing NetBox patterns. The device view is conditionally registered to allow users to choose between inline and tab display modes.

@cruse1977
Copy link
Member

hey @Kani999, thanks for this - can you look to resolve the conflicts since the initial PR ?

@cruse1977 cruse1977 added the revisions-needed Revisions are need to ascertain the issue label Oct 8, 2025
- Implement IPAddressBGPSessionsView to display BGP sessions associated with an IP address
- Add tab with badge showing session count and permission check
- Update README.md to document the new "tab" value for device_ext_page config, enabling BGP sessions as a tab on device view pages
- Implement DeviceBGPSessionsView in template_content.py as an ObjectChildrenView for tab-based display
- Conditionally register the view only when device_ext_page is set to "tab", otherwise use PluginTemplateExtension for inline display (left/right/full_width)
- Add necessary imports for Device model and settings to support the new functionality
- Implement SiteBGPSessionsView in netbox_bgp/template_content.py as an ObjectChildrenView for displaying BGP sessions associated with a site
- Implement TenantBGPSessionsView in [netbox_bgp/template_content.py]template_content.py ) as an ObjectChildrenView for displaying BGP sessions associated with a tenant
- Implement VirtualMachineBGPSessionsView in [netbox_bgp/template_content.py]template_content.py ) as an ObjectChildrenView for displaying BGP sessions associated with a virtual machine
- Implement ASNBGPSessionsView in [netbox_bgp/template_content.py]template_content.py ) as an ObjectChildrenView for displaying BGP sessions associated with an ASN
- Include tab with badge showing count of related BGP sessions (where ASN is local or remote AS) and permission check for viewing
@Kani999 Kani999 force-pushed the displaying_bgp_sessions_on_related_objects branch 2 times, most recently from c89c978 to df97591 Compare October 8, 2025 12:12
- Add InterfaceBGPSessionsView class with tab registration for displaying BGP sessions associated with interfaces via their IP addresses
- Fix GenericForeignKey filtering by using ContentType and assigned_object_type/id fields instead of direct assigned_object lookup
- Add necessary imports for Interface and ContentType models
@Kani999 Kani999 force-pushed the displaying_bgp_sessions_on_related_objects branch from df97591 to 77b88aa Compare October 8, 2025 12:14
@Kani999
Copy link
Contributor Author

Kani999 commented Oct 8, 2025

hey @Kani999, thanks for this - can you look to resolve the conflicts since the initial PR ?

Hello @cruse1977,
The conflicts have been resolved. I've tested the changes on my machine, and everything seems to be working fine.

@cruse1977 cruse1977 removed the revisions-needed Revisions are need to ascertain the issue label Oct 9, 2025
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.

2 participants