netbox-bgp icon indicating copy to clipboard operation
netbox-bgp copied to clipboard

Expose BGP Sessions in Device data model

Open elipsion opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. When creating device configuration templates, I would like to also include BGP sessions.

Describe the solution you'd like A data model relation for Device -> Session, not just the other way around.

Describe alternatives you've considered Adding BGP sessions as a Custom Field to the Device data model object, and linking them manually.

elipsion avatar Feb 01 '24 12:02 elipsion

Found it using nbshell. The name bgpsession_set was not expected, to say the least.

elipsion avatar Feb 01 '24 12:02 elipsion

As the documentation mentions https://github.com/netbox-community/netbox/blob/develop/docs/features/configuration-rendering.md , you can ask every class, including plugins.

From what I undertand on your needs, you could parse all sessions and filter by your device (as the relation session --> device exists), exemple:

{% for session in netbox_bgp.BGPSession.objects.all() %} {% if session.device.name == device.name %} session {{ session.name }} {% endif%} {% endfor %}

image image

I don't think you could get a relation device --> session as it's a plugin

pl0xym0r avatar Feb 03 '24 08:02 pl0xym0r

Even this is quite easier and quickier :

{% for session in netbox_bgp.BGPSession.objects.filter(device=device) %} session {{ session.name }} {% endfor %}

pl0xym0r avatar Feb 23 '24 15:02 pl0xym0r