Skip to content

Conversation

@nazarko-es
Copy link

Added "site" field in ASPathList, CommunityList, RoutePolicy, PrefixList - it's usefull if you reuse names of this objects in diffrent sites but with diffrent rules. If the site is None, uniquiness of name is checking as before.
Also i added new object "redistributing". It provides to add redistributing of routes from other routing protocols with policy

@nazarko-es
Copy link
Author

Hey, any updates?

@cruse1977
Copy link
Member

hey @nazarko-es there seems to be 2 changes here covered by 1 PR - in future please split these into 1 change per PR (ie: site + redistribution = 2 PRs).

In terms of site, would you not instead scope this ? ie: to allow region, site, location etc as per other models ?

@nazarko-es
Copy link
Author

hey, in future i will split. About site i didn't think about use scope because it isn't relevant in my target. I can change it to scope

@k01ek k01ek marked this pull request as draft November 15, 2025 05:31
…add-fields-site-and-redistribute-policy

# Conflicts:
#	netbox_bgp/api/serializers.py
#	netbox_bgp/forms.py
#	netbox_bgp/graphql/types.py
#	netbox_bgp/models.py
#	netbox_bgp/tables.py
#	netbox_bgp/template_content.py
#	netbox_bgp/templates/netbox_bgp/device_extend.html
#	netbox_bgp/templates/netbox_bgp/routingpolicy.html
@k01ek
Copy link
Collaborator

k01ek commented Nov 21, 2025

i need some time to review

@nazarko-es
Copy link
Author

hi, i merged updates from source branch and changed site to scope

@nazarko-es nazarko-es marked this pull request as ready for review November 28, 2025 09:36
@aoforb
Copy link

aoforb commented Dec 3, 2025

I'm interested to know more about this change.

Snipping of Cisco BGP config below which shows redistribute commands under the global and vrf address-family.

Would this change address this?

 address-family ipv4
  redistribute connected
  redistribute static route-map STATIC_ROUTES_TO_BGP
 address-family ipv4 vrf FOO
  redistribute connected
  redistribute static

Thanks

@nazarko-es
Copy link
Author

@aoforb yes, this change provides to add redistributing with diverse source and vrf. But now route policy is necessary field for redistributing, i can change it

@aoforb
Copy link

aoforb commented Dec 4, 2025

Cool, at the moment I extract all the VRFs from each peer group, then make them unique. This provides a list of address families to iterate over for config rendering. Since these redistribute commands are not at the peer group level, i'm guessing something else needs to be done so they can accessed at address family level. Not sure if i'm doing that correctly.

{% set bgp_sessions = netbox_bgp.BGPSession.objects.filter(device=device, status='active') %}
{% set peer_group_names = bgp_sessions | map(attribute='peer_group.name') | select('defined') | unique | list %}
{% set _peer_groups = [] %}
{% for name in peer_group_names %}
{%  set peer_group = netbox_bgp.BGPPeerGroup.objects.filter(name=name) %}
{%  if peer_group %}
{%    set _ = _peer_groups.append(peer_group[0]) %}
{%  endif %}
{%  endfor %}
{%  if _peer_groups %}
{%  set peer_groups = _peer_groups
      | selectattr('name')
      | sort(attribute='name')
      | list
%}
{%  set address_families = peer_groups
      | selectattr('cf.bgp_vrf.name', 'defined')
      | sort(attribute='cf.bgp_vrf.name')
      | map(attribute='cf.bgp_vrf.name')
      | unique
      | list
%}

Hopefully that makes sense.

@nazarko-es
Copy link
Author

Did i correct understand that you need relationship beetwen peer group object and redistributing object?

@aoforb
Copy link

aoforb commented Dec 4, 2025

In Cisco BGP, redistribute <source> [route-map …] is configured under the BGP address‑family (AF) and applies to the entire AF/VRF, not to individual neighbours or peer‑groups. Per‑neighbour scoping is achieved with policy (neighbour … route-map out, communities, prefix‑lists), not per‑neighbour redistribute. In other words, “redistribute” populates the AF RIB; neighbour/peer‑group policy controls what is actually advertised.

As far as I can see, the plugin doesn’t currently expose an explicit “Address Family” concept (e.g., ipv4/ipv6 unicast per device/VRF within the BGP process). Without that anchor, it’s hard to put redistribute in the correct place.

Maybe introduce an AF‑scoped model and hang redistribution off it.

@nazarko-es
Copy link
Author

nazarko-es commented Dec 4, 2025

I know. This change has relationship between device/virtualmachine objects and redistributing, so we can define several sources and route policies for our target. About address families - now it isn't supported in plugin. In my case i can use address families in jinja template and other data from plugin to generate configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants