Import/Export Policies not preserved in user-defined order
I’ve encountered an issue with how Import and Export Policies are handled in the Netbox BGP Plugin.
When I add multiple policies to a BGP session or a peer group, the plugin displays and stores them sorted by their Policy ID, rather than preserving the order in which I added them. This is problematic because in real-world router configurations, the order of policies matters — routers evaluate policies sequentially.
From the Juniper documentaion:
If you specify more than one policy, they are evaluated in the order specified, from first to last.
So the expected behavior would be that the plugin respects the user-defined order of policies, rather than sorting them automatically by ID.
Let me know if more information is needed or if I can help debug further!
Thanks!
Hi @VEEC023 whilst I understand the use case (I've used Juniper in a previous life), this would require a large refactor as the import_policies is a M2M field, so you'd need to transition to a similar approach to that of PrefixList rules with an index alongside create a migration to migrate all existing plugin data to that - its a not insignificant level of work.
@VEEC023 - coming back to this - is this still an issue ? changing the fields to this level I don't think is possible - however what we could do is add an optional 'index' field to the routing policy itself. This could give a way to define some sort of ordering, however it could mean that index is global relevant to any sessions the policy is applied to
+1 for this issue and also it still being an issue.
I think an index is certainly a viable solution however like you mention it would become relevant to any session globally. Could a weighting like the configuration contexts be used to avoid this perhaps? I'm not too familiar with the inner workings of netbox plugin development so unsure if this is viable for this use case and/or plugin.