netbox-peering-manager 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. netbox_peering_manager-0.2.0/LICENSE +177 -0
  2. netbox_peering_manager-0.2.0/MANIFEST.in +1 -0
  3. netbox_peering_manager-0.2.0/PKG-INFO +383 -0
  4. netbox_peering_manager-0.2.0/README.md +357 -0
  5. netbox_peering_manager-0.2.0/netbox_peering_manager/__init__.py +59 -0
  6. netbox_peering_manager-0.2.0/netbox_peering_manager/admin.py +0 -0
  7. netbox_peering_manager-0.2.0/netbox_peering_manager/api/__init__.py +0 -0
  8. netbox_peering_manager-0.2.0/netbox_peering_manager/api/serializers.py +282 -0
  9. netbox_peering_manager-0.2.0/netbox_peering_manager/api/urls.py +35 -0
  10. netbox_peering_manager-0.2.0/netbox_peering_manager/api/views.py +160 -0
  11. netbox_peering_manager-0.2.0/netbox_peering_manager/choices.py +54 -0
  12. netbox_peering_manager-0.2.0/netbox_peering_manager/constants.py +6 -0
  13. netbox_peering_manager-0.2.0/netbox_peering_manager/filtersets.py +246 -0
  14. netbox_peering_manager-0.2.0/netbox_peering_manager/forms.py +667 -0
  15. netbox_peering_manager-0.2.0/netbox_peering_manager/graphql/__init__.py +3 -0
  16. netbox_peering_manager-0.2.0/netbox_peering_manager/graphql/enums.py +7 -0
  17. netbox_peering_manager-0.2.0/netbox_peering_manager/graphql/filters.py +132 -0
  18. netbox_peering_manager-0.2.0/netbox_peering_manager/graphql/schema.py +45 -0
  19. netbox_peering_manager-0.2.0/netbox_peering_manager/graphql/types.py +129 -0
  20. netbox_peering_manager-0.2.0/netbox_peering_manager/initializers/__init__.py +6 -0
  21. netbox_peering_manager-0.2.0/netbox_peering_manager/initializers/relationships.py +30 -0
  22. netbox_peering_manager-0.2.0/netbox_peering_manager/irr_client.py +162 -0
  23. netbox_peering_manager-0.2.0/netbox_peering_manager/jinja2_filters.py +152 -0
  24. netbox_peering_manager-0.2.0/netbox_peering_manager/jobs.py +173 -0
  25. netbox_peering_manager-0.2.0/netbox_peering_manager/management/__init__.py +0 -0
  26. netbox_peering_manager-0.2.0/netbox_peering_manager/management/commands/__init__.py +0 -0
  27. netbox_peering_manager-0.2.0/netbox_peering_manager/management/commands/load_all_initializer_data.py +54 -0
  28. netbox_peering_manager-0.2.0/netbox_peering_manager/management/commands/sync_peeringdb.py +91 -0
  29. netbox_peering_manager-0.2.0/netbox_peering_manager/migrations/0001_initial.py +296 -0
  30. netbox_peering_manager-0.2.0/netbox_peering_manager/migrations/__init__.py +0 -0
  31. netbox_peering_manager-0.2.0/netbox_peering_manager/models.py +561 -0
  32. netbox_peering_manager-0.2.0/netbox_peering_manager/navigation.py +203 -0
  33. netbox_peering_manager-0.2.0/netbox_peering_manager/services/__init__.py +13 -0
  34. netbox_peering_manager-0.2.0/netbox_peering_manager/services/config_renderer.py +268 -0
  35. netbox_peering_manager-0.2.0/netbox_peering_manager/services/exceptions.py +25 -0
  36. netbox_peering_manager-0.2.0/netbox_peering_manager/services/peeringdb.py +184 -0
  37. netbox_peering_manager-0.2.0/netbox_peering_manager/services/peeringdb_sync.py +474 -0
  38. netbox_peering_manager-0.2.0/netbox_peering_manager/tables.py +263 -0
  39. netbox_peering_manager-0.2.0/netbox_peering_manager/template_content.py +1 -0
  40. netbox_peering_manager-0.2.0/netbox_peering_manager/templates/netbox_peering_manager/irrprefixlistconfig.html +79 -0
  41. netbox_peering_manager-0.2.0/netbox_peering_manager/templates/netbox_peering_manager/irrsource.html +88 -0
  42. netbox_peering_manager-0.2.0/netbox_peering_manager/templates/netbox_peering_manager/peerasn.html +111 -0
  43. netbox_peering_manager-0.2.0/netbox_peering_manager/templates/netbox_peering_manager/peeringconnection.html +81 -0
  44. netbox_peering_manager-0.2.0/netbox_peering_manager/templates/netbox_peering_manager/peeringfabric.html +135 -0
  45. netbox_peering_manager-0.2.0/netbox_peering_manager/templates/netbox_peering_manager/peeringfabric_create_from_peeringdb.html +77 -0
  46. netbox_peering_manager-0.2.0/netbox_peering_manager/templates/netbox_peering_manager/peeringfabrictype.html +64 -0
  47. netbox_peering_manager-0.2.0/netbox_peering_manager/templates/netbox_peering_manager/peeringnetwork.html +89 -0
  48. netbox_peering_manager-0.2.0/netbox_peering_manager/templates/netbox_peering_manager/peeringsession.html +71 -0
  49. netbox_peering_manager-0.2.0/netbox_peering_manager/templates/netbox_peering_manager/relationship.html +65 -0
  50. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/__init__.py +0 -0
  51. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/test_api.py +128 -0
  52. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/test_config_renderer.py +212 -0
  53. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/test_forms.py +128 -0
  54. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/test_irr_client.py +200 -0
  55. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/test_jinja2_filters.py +302 -0
  56. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/test_jobs.py +307 -0
  57. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/test_models.py +357 -0
  58. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/test_peeringdb.py +526 -0
  59. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/test_validators.py +71 -0
  60. netbox_peering_manager-0.2.0/netbox_peering_manager/tests/test_views.py +471 -0
  61. netbox_peering_manager-0.2.0/netbox_peering_manager/urls.py +101 -0
  62. netbox_peering_manager-0.2.0/netbox_peering_manager/validators.py +49 -0
  63. netbox_peering_manager-0.2.0/netbox_peering_manager/version.py +1 -0
  64. netbox_peering_manager-0.2.0/netbox_peering_manager/views.py +637 -0
  65. netbox_peering_manager-0.2.0/netbox_peering_manager.egg-info/PKG-INFO +383 -0
  66. netbox_peering_manager-0.2.0/netbox_peering_manager.egg-info/SOURCES.txt +70 -0
  67. netbox_peering_manager-0.2.0/netbox_peering_manager.egg-info/dependency_links.txt +1 -0
  68. netbox_peering_manager-0.2.0/netbox_peering_manager.egg-info/requires.txt +3 -0
  69. netbox_peering_manager-0.2.0/netbox_peering_manager.egg-info/top_level.txt +1 -0
  70. netbox_peering_manager-0.2.0/pyproject.toml +86 -0
  71. netbox_peering_manager-0.2.0/setup.cfg +4 -0
  72. netbox_peering_manager-0.2.0/setup.py +48 -0
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1 @@
1
+ recursive-include netbox_peering_manager/templates *.html
@@ -0,0 +1,383 @@
1
+ Metadata-Version: 2.4
2
+ Name: netbox-peering-manager
3
+ Version: 0.2.0
4
+ Summary: BGP related stuff
5
+ Home-page: https://github.com/jsenecal/netbox-peering-manager
6
+ Author: Jonathan Senecal
7
+ Author-email: jonathan.senecal@metrooptic.com
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Framework :: Django
11
+ Classifier: Programming Language :: Python :: 3
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: httpx
15
+ Requires-Dist: tenacity
16
+ Requires-Dist: netbox-routing
17
+ Dynamic: author
18
+ Dynamic: author-email
19
+ Dynamic: classifier
20
+ Dynamic: description
21
+ Dynamic: description-content-type
22
+ Dynamic: home-page
23
+ Dynamic: license-file
24
+ Dynamic: requires-dist
25
+ Dynamic: summary
26
+
27
+ # netbox-peering-manager
28
+
29
+ [NetBox Peering Manager](https://github.com/jsenecal/netbox-peering-manager) is a peering management plugin for [NetBox](https://github.com/netbox-community/netbox). It provides a way to document Internet Exchange points, peering sessions, and IRR prefix list synchronization, serving as both a source of truth and a configuration management layer for external BGP sessions (transit, customers, peering, etc).
30
+
31
+ Starting with v0.2.0, this plugin builds on top of [netbox-routing](https://github.com/DanSheps/netbox-routing), which provides the core BGP data models (peers, peer groups, routing policies, prefix lists, communities, BFD profiles, etc). netbox-peering-manager extends those models with peering-specific functionality rather than duplicating them.
32
+
33
+ ## Features
34
+
35
+ This plugin provides the following on top of netbox-routing:
36
+
37
+ **Peering Session Management:**
38
+ * Peering Sessions — thin wrapper around netbox-routing's BGPPeer, adding relationship type, peering network association, and service reference tracking
39
+ * Relationship Types — classify sessions as transit, peer, customer, IXP, etc.
40
+ * Peer ASNs — extends NetBox ASN with peering-specific attributes (IRR AS-SET, max prefixes, PeeringDB ID)
41
+
42
+ **Internet Exchange Support:**
43
+ * Peering Fabric Types — classify fabric types (IX, cloud exchange, private LAN)
44
+ * Peering Fabrics — represent IX or peering environments with PeeringDB integration
45
+ * Peering Networks — IX LANs with prefix/VLAN associations
46
+ * Peering Connections — device interface attachments to peering networks
47
+
48
+ **IRR Prefix List Synchronization:**
49
+ * IRR Sources — configure IRR query endpoints (via [fastbgpq4](https://github.com/jsenecal/fastbgpq4))
50
+ * IRR Prefix List Configs — link netbox-routing PrefixLists to IRR sources for automatic sync
51
+ * Background jobs for single and bulk prefix list synchronization
52
+
53
+ **External Integrations:**
54
+ * PeeringDB selective sync (IX discovery, peer discovery)
55
+ * Configuration templating (Jinja2 with multi-vendor support via NetBox ConfigTemplates)
56
+
57
+ **Provided by netbox-routing (required dependency):**
58
+ * BGP Peers and Peer Templates (peer groups)
59
+ * BGP Routers and Scopes
60
+ * Routing Policies (route maps) with address family support
61
+ * Prefix Lists and Prefix List Entries
62
+ * Communities and Community Lists
63
+ * AS Path Lists
64
+ * BFD Profiles
65
+
66
+ ## Compatibility
67
+
68
+ | NetBox Version | Plugin Version | netbox-routing Version |
69
+ |----------------|----------------|------------------------|
70
+ | NetBox 4.5.x | >= 0.2.0 | 0.4.x+ |
71
+ | NetBox 4.4.x | 0.1.x | N/A (standalone) |
72
+
73
+ ## Prerequisites
74
+
75
+ **netbox-routing** must be installed and enabled before installing netbox-peering-manager. The plugin declares `netbox_routing` as a required plugin and will not load without it.
76
+
77
+ ```bash
78
+ pip install git+https://github.com/DanSheps/netbox-routing.git@14318f1c
79
+ ```
80
+
81
+ Enable it in your NetBox configuration:
82
+
83
+ ```python
84
+ PLUGINS = [
85
+ 'netbox_routing',
86
+ 'netbox_peering_manager',
87
+ ]
88
+ ```
89
+
90
+ > **Important:** `netbox_routing` must appear before `netbox_peering_manager` in the `PLUGINS` list.
91
+
92
+ ## Installation
93
+
94
+ Install the plugin (this will also pull in netbox-routing as a dependency):
95
+
96
+ ```bash
97
+ pip install git+https://github.com/jsenecal/netbox-peering-manager.git
98
+ ```
99
+
100
+ Enable both plugins in `/opt/netbox/netbox/netbox/configuration.py`:
101
+
102
+ ```python
103
+ PLUGINS = [
104
+ 'netbox_routing',
105
+ 'netbox_peering_manager',
106
+ ]
107
+ ```
108
+
109
+ Run database migrations:
110
+
111
+ ```bash
112
+ cd /opt/netbox/netbox
113
+ python manage.py migrate
114
+ ```
115
+
116
+ Restart NetBox and add `netbox-peering-manager` to your `local_requirements.txt`.
117
+
118
+ See [NetBox Documentation](https://docs.netbox.dev/en/stable/plugins/#installing-plugins) for details.
119
+
120
+ ## Configuration
121
+
122
+ ```python
123
+ PLUGINS_CONFIG = {
124
+ 'netbox_peering_manager': {
125
+ # Enable top-level navigation menu (default: True)
126
+ 'top_level_menu': True,
127
+
128
+ # PeeringDB integration (all optional)
129
+ 'peeringdb_url': None, # Falls back to default PeeringDB API
130
+ 'peeringdb_api_key': None, # Optional, needed for contact info
131
+ 'peeringdb_timeout': None, # Falls back to 30s
132
+ 'peeringdb_local_asns': [], # Your ASN(s) for filtering
133
+ }
134
+ }
135
+ ```
136
+
137
+ ## Model Architecture
138
+
139
+ netbox-peering-manager v0.2.0 follows a layered architecture where netbox-routing provides the core BGP models and this plugin adds peering-specific extensions:
140
+
141
+ ```
142
+ netbox-routing (dependency) netbox-peering-manager (this plugin)
143
+ ───────────────────────────── ────────────────────────────────────
144
+ BGPPeer ◄──────────────────────────── PeeringSession (1:1)
145
+ ├── peer (remote IP) ├── relationship (FK → Relationship)
146
+ ├── source (local IP) ├── peering_network (FK → PeeringNetwork)
147
+ ├── remote_as / local_as └── service_reference
148
+ ├── peer_group (BGPPeerTemplate)
149
+ ├── bfd (BFDProfile) Relationship
150
+ ├── address_families[] ├── name, slug, color
151
+ └── enabled, status, ttl
152
+ PeerASN (1:1 → ipam.ASN)
153
+ PrefixList ◄───────────────────────── ├── affiliated, irr_as_set
154
+ ├── name, family ├── max prefixes (v4/v6)
155
+ └── entries[] └── peeringdb_id
156
+
157
+ IRRPrefixListConfig (1:1 → PrefixList)
158
+ ├── irr_source (FK → IRRSource)
159
+ ├── source_as_set
160
+ └── sync_interval
161
+
162
+ IRRSource
163
+ ├── name, url, sources
164
+ └── enabled, sync_interval
165
+
166
+ PeeringFabric / PeeringNetwork / PeeringConnection
167
+ └── IX infrastructure models
168
+ ```
169
+
170
+ ## External Dependencies
171
+
172
+ ### IRR Prefix List Synchronization (fastbgpq4)
173
+
174
+ The plugin supports automatic prefix list synchronization from Internet Routing Registry (IRR) databases. This feature requires [fastbgpq4](https://github.com/jsenecal/fastbgpq4), a separate REST API service that wraps [bgpq4](https://github.com/bgp/bgpq4) for querying IRR databases like RADB, RIPE, ARIN, etc.
175
+
176
+ **Why a separate service?**
177
+
178
+ bgpq4 is a command-line tool, not a library. fastbgpq4 provides a REST API interface that allows netbox-peering-manager to query IRR data without requiring bgpq4 to be installed on the NetBox server itself. This also enables caching, async queries for large AS-SETs, and centralized IRR query infrastructure.
179
+
180
+ **Setup:**
181
+
182
+ 1. Deploy fastbgpq4 (see [fastbgpq4 documentation](https://github.com/jsenecal/fastbgpq4) for installation options including Docker)
183
+
184
+ 2. In NetBox, create an IRR Source under *Peering Manager > IRR Sources* with:
185
+ - **Name**: A descriptive name (e.g., "RADB via fastbgpq4")
186
+ - **URL**: The fastbgpq4 API base URL (e.g., `http://fastbgpq4:8000`)
187
+ - **Sources** (optional): Comma-separated IRR sources to query (e.g., `RADB,RIPE,ARIN`)
188
+ - **Cache TTL** (optional): Cache duration for query results
189
+
190
+ 3. Create an IRR Prefix List Config linking a netbox-routing Prefix List to the IRR Source:
191
+ - **Prefix List**: Select a netbox-routing prefix list
192
+ - **IRR Source**: Select your configured IRR source
193
+ - **Source AS-SET**: The AS-SET to query (e.g., `AS-HURRICANE`)
194
+
195
+ 4. Use the sync action to populate the prefix list entries from IRR data
196
+
197
+ **Background Jobs:**
198
+
199
+ IRR synchronization runs as NetBox background jobs via the RQ worker:
200
+ - **Sync Prefix List from IRR** — Syncs a single prefix list
201
+ - **Sync All Prefix Lists from IRR** — Syncs all prefix lists associated with an IRR source
202
+
203
+ Ensure the NetBox RQ worker is running (`make rqworker` in development, or your production worker service).
204
+
205
+ ## Configuration Templating
206
+
207
+ netbox-peering-manager provides a configuration rendering service that builds Jinja2 template context from your BGP data. It uses NetBox's built-in `ConfigTemplate` model for template storage.
208
+
209
+ ### Template Context Variables
210
+
211
+ The `ConfigRenderer` service provides the following context:
212
+
213
+ | Variable | Type | Description |
214
+ |----------|------|-------------|
215
+ | `device` | dict | Device info: `name`, `platform.name`, `platform.slug`, `site.name`, `site.slug` |
216
+ | `sessions` | list[dict] | Peering sessions (see below) |
217
+ | `peer_groups` | list[dict] | Deduplicated peer groups: `id`, `name` |
218
+ | `route_maps` | list[dict] | Deduplicated route maps: `id`, `name` |
219
+ | `prefix_lists` | list[dict] | Reserved for future use |
220
+ | `communities` | list[dict] | Reserved for future use |
221
+
222
+ ### Session Context
223
+
224
+ Each session in `sessions` contains:
225
+
226
+ | Field | Type | Description |
227
+ |-------|------|-------------|
228
+ | `name` | str | BGP peer name |
229
+ | `description` | str | Peer description |
230
+ | `enabled` | bool | Whether the peer is enabled |
231
+ | `status` | str | Peer status |
232
+ | `local_asn` | int | Local AS number |
233
+ | `peer_asn` | int | Remote AS number |
234
+ | `local_ip` | str | Local IP address |
235
+ | `remote_ip` | str | Remote IP address |
236
+ | `password` | str | MD5 authentication password |
237
+ | `ttl` | int | TTL / multihop value |
238
+ | `relationship` | str | Relationship type name |
239
+ | `service_reference` | str | Service ticket reference |
240
+ | `peer_name` | str | PeerASN name (if exists) |
241
+ | `irr_as_set` | str | IRR AS-SET from PeerASN |
242
+ | `ipv4_max_prefixes` | int | Max IPv4 prefixes from PeerASN |
243
+ | `ipv6_max_prefixes` | int | Max IPv6 prefixes from PeerASN |
244
+ | `bfd_profile` | dict | BFD config: `name`, `minimum_interval`, `minimum_rx_interval`, `multiplier`, `hold` |
245
+ | `peer_group` | dict | Peer group: `id`, `name` |
246
+ | `peering_network` | dict | IX network: `id`, `name`, `fabric` |
247
+ | `afi_safis` | list[str] | Address families (e.g., `["ipv4-unicast"]`) |
248
+ | `address_families` | list[dict] | Per-AFI config with `route_map_in`, `route_map_out`, `prefix_list_in`, `prefix_list_out` |
249
+
250
+ ### Custom Jinja2 Filters
251
+
252
+ The plugin registers custom Jinja2 filters for use in templates:
253
+
254
+ | Filter | Description |
255
+ |--------|-------------|
256
+ | `as_path_regex` | Convert AS path to regex pattern |
257
+ | `ip_network` | Parse IP network string |
258
+ | `group_by` | Group objects by attribute |
259
+ | `to_community_list` | Format community list entries |
260
+ | `to_prefix_set` | Format prefix set entries |
261
+
262
+ ### Example Templates
263
+
264
+ Example templates are provided in [`docs/examples/templates/`](docs/examples/templates/) for:
265
+ - **Juniper Junos** (`junos-bgp.j2`)
266
+ - **Cisco IOS-XR** (`ios-xr-bgp.j2`)
267
+ - **Arista EOS** (`eos-bgp.j2`)
268
+ - **Nokia SR OS** (`nokia-sros-bgp.j2`)
269
+
270
+ ### API Endpoint
271
+
272
+ Render configuration via the REST API:
273
+
274
+ ```
275
+ POST /api/plugins/bgp/render-config/
276
+ ```
277
+
278
+ ## Development
279
+
280
+ This plugin uses a VS Code devcontainer for development. The devcontainer provides a complete NetBox environment with both netbox-routing and netbox-peering-manager installed in editable mode.
281
+
282
+ ### Prerequisites
283
+
284
+ - [Docker](https://www.docker.com/get-started)
285
+ - [Visual Studio Code](https://code.visualstudio.com/)
286
+ - [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
287
+
288
+ ### Getting Started
289
+
290
+ 1. Clone the repository:
291
+ ```bash
292
+ git clone https://github.com/jsenecal/netbox-peering-manager.git
293
+ cd netbox-peering-manager
294
+ ```
295
+
296
+ 2. Open the project in VS Code:
297
+ ```bash
298
+ code .
299
+ ```
300
+
301
+ 3. When prompted, click "Reopen in Container" or run the command "Dev Containers: Reopen in Container" from the Command Palette (F1)
302
+
303
+ 4. Wait for the container to build and start. This may take a few minutes on the first run.
304
+
305
+ 5. Once the container is ready, NetBox will be accessible at `http://localhost:8001`
306
+ - Username: `admin`
307
+ - Password: `admin`
308
+
309
+ ### Development Workflow
310
+
311
+ Both netbox-routing and netbox-peering-manager are installed in editable mode (`pip install -e`), so changes to the code will be reflected immediately. You may need to restart the NetBox service for some changes.
312
+
313
+ #### Using Make Commands
314
+
315
+ The project includes a Makefile with convenient targets for common development tasks:
316
+
317
+ ```bash
318
+ # Show all available make targets with descriptions
319
+ make help
320
+
321
+ # Quick Start / Composite Commands
322
+ make all # Full setup: install, migrate, collect static, load demo data
323
+ make rebuild # Rebuild: reinstall plugin, run migrations, collect static
324
+ make setup # Install/reinstall the plugin in editable mode
325
+
326
+ # Development Server & Shells
327
+ make runserver # Start NetBox development server on port 8001
328
+ make shell # Open Django shell
329
+ make nbshell # Open NetBox shell (with NetBox utilities)
330
+ make dbshell # Open database shell
331
+
332
+ # Database Migrations
333
+ make makemigrations # Create new migrations for the plugin
334
+ make migrate # Apply database migrations
335
+ make showmigrations # Show migration status
336
+
337
+ # Testing & Code Quality
338
+ make test # Run plugin tests (includes migration check)
339
+ make test-verbose # Run tests with verbose output
340
+ make lint # Run ruff linting checks
341
+ make format # Auto-format code with ruff
342
+ make fix # Run ruff with --fix for auto-fixes
343
+
344
+ # NetBox Utilities
345
+ make trace_paths # Run NetBox trace_paths utility
346
+ make collectstatic # Collect static files
347
+ make createsuperuser # Create a superuser account
348
+ make rqworker # Start RQ worker for background tasks
349
+
350
+ # Demo Data (NetBox Initializers)
351
+ make initializers # Setup and load demo data
352
+ make example_initializers # Copy example initializers to .devcontainer
353
+ make load_initializers # Load initializer data from .devcontainer/initializers
354
+
355
+ # Maintenance
356
+ make clean # Clean build artifacts
357
+ make reinstall # Alias for setup
358
+ ```
359
+
360
+ #### Manual Commands
361
+
362
+ You can also run Django management commands directly:
363
+
364
+ ```bash
365
+ # From within the devcontainer terminal
366
+ cd /opt/netbox/netbox
367
+ python manage.py runserver 0.0.0.0:8001
368
+ python manage.py test netbox_peering_manager
369
+ python manage.py makemigrations netbox_peering_manager
370
+ python manage.py migrate
371
+ ```
372
+
373
+ ## Upgrading from v0.1.x
374
+
375
+ v0.2.0 is a **breaking change**. All BGP routing models (BGPSession, BGPPeerGroup, BFD, RoutingPolicy, PrefixList, Community, ASPathList, and their rule models) have been removed in favor of netbox-routing.
376
+
377
+ **Migration steps:**
378
+
379
+ 1. Install netbox-routing and run its migrations
380
+ 2. Migrate your data from the old plugin tables to netbox-routing models
381
+ 3. Update `PLUGINS` configuration to include both `netbox_routing` and `netbox_peering_manager`
382
+ 4. Upgrade netbox-peering-manager to v0.2.0 and run migrations
383
+ 5. Update any configuration templates to use the new context variables (see [Configuration Templating](#configuration-templating))