netbox-oxidized 0.1.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.
- netbox_oxidized-0.1.0/LICENSE +190 -0
- netbox_oxidized-0.1.0/PKG-INFO +157 -0
- netbox_oxidized-0.1.0/README.md +128 -0
- netbox_oxidized-0.1.0/netbox_oxidized/__init__.py +38 -0
- netbox_oxidized-0.1.0/netbox_oxidized/api/__init__.py +1 -0
- netbox_oxidized-0.1.0/netbox_oxidized/api/urls.py +5 -0
- netbox_oxidized-0.1.0/netbox_oxidized/client.py +127 -0
- netbox_oxidized-0.1.0/netbox_oxidized/navigation.py +11 -0
- netbox_oxidized-0.1.0/netbox_oxidized/templates/netbox_oxidized/device_tab.html +18 -0
- netbox_oxidized-0.1.0/netbox_oxidized/templates/netbox_oxidized/device_tab_content.html +108 -0
- netbox_oxidized-0.1.0/netbox_oxidized/templates/netbox_oxidized/settings.html +124 -0
- netbox_oxidized-0.1.0/netbox_oxidized/urls.py +11 -0
- netbox_oxidized-0.1.0/netbox_oxidized/views.py +143 -0
- netbox_oxidized-0.1.0/netbox_oxidized.egg-info/PKG-INFO +157 -0
- netbox_oxidized-0.1.0/netbox_oxidized.egg-info/SOURCES.txt +18 -0
- netbox_oxidized-0.1.0/netbox_oxidized.egg-info/dependency_links.txt +1 -0
- netbox_oxidized-0.1.0/netbox_oxidized.egg-info/requires.txt +6 -0
- netbox_oxidized-0.1.0/netbox_oxidized.egg-info/top_level.txt +1 -0
- netbox_oxidized-0.1.0/pyproject.toml +56 -0
- netbox_oxidized-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 sieteunoseis
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: netbox-oxidized
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: NetBox plugin for oxidized integration
|
|
5
|
+
Author-email: sieteunoseis <jeremy.worden@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/sieteunoseis/netbox-oxidized
|
|
8
|
+
Project-URL: Repository, https://github.com/sieteunoseis/netbox-oxidized
|
|
9
|
+
Project-URL: Documentation, https://github.com/sieteunoseis/netbox-oxidized/wiki
|
|
10
|
+
Project-URL: Changelog, https://github.com/sieteunoseis/netbox-oxidized/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: netbox,netbox-plugin,oxidized
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Framework :: Django
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: requests>=2.25.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: black; extra == "dev"
|
|
26
|
+
Requires-Dist: flake8; extra == "dev"
|
|
27
|
+
Requires-Dist: isort; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# NetBox Oxidized Plugin
|
|
31
|
+
|
|
32
|
+
A NetBox plugin that displays [Oxidized](https://github.com/ytti/oxidized) device configuration backups directly in Device detail pages.
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
37
|
+
[](https://pypi.org/project/netbox-oxidized/)
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Oxidized Tab** - Adds an "Oxidized" tab to Device detail pages
|
|
42
|
+
- **Config Display** - Shows the latest device configuration as code with copy button
|
|
43
|
+
- **Node Status** - Displays backup status, model, and last backup time
|
|
44
|
+
- **Link to Oxidized** - Direct link to the device's version history in Oxidized
|
|
45
|
+
- **Device Filtering** - Configurable by device role and manufacturer slugs
|
|
46
|
+
- **HTMX Loading** - Async content loading without blocking the page
|
|
47
|
+
- **Caching** - API responses cached to reduce load on Oxidized
|
|
48
|
+
|
|
49
|
+
## Requirements
|
|
50
|
+
|
|
51
|
+
- NetBox 4.0 or higher
|
|
52
|
+
- Python 3.10+
|
|
53
|
+
- Oxidized with REST API enabled
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
### From PyPI (recommended)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install netbox-oxidized
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Docker Installation
|
|
64
|
+
|
|
65
|
+
Add to your NetBox Docker requirements file:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# requirements-extra.txt
|
|
69
|
+
netbox-oxidized
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Configuration
|
|
73
|
+
|
|
74
|
+
Add the plugin to your NetBox configuration:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
# configuration.py or plugins.py
|
|
78
|
+
|
|
79
|
+
PLUGINS = [
|
|
80
|
+
'netbox_oxidized',
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
PLUGINS_CONFIG = {
|
|
84
|
+
'netbox_oxidized': {
|
|
85
|
+
# Required: Oxidized REST API URL
|
|
86
|
+
'oxidized_url': 'http://oxidized:8888',
|
|
87
|
+
# Optional: External URL for browser links (if behind reverse proxy)
|
|
88
|
+
'oxidized_external_url': 'https://oxidized.example.com',
|
|
89
|
+
# API timeout in seconds
|
|
90
|
+
'timeout': 30,
|
|
91
|
+
# Cache duration in seconds
|
|
92
|
+
'cache_timeout': 300,
|
|
93
|
+
# SSL certificate verification
|
|
94
|
+
'verify_ssl': False,
|
|
95
|
+
# Device role slugs to show tab for (empty = all)
|
|
96
|
+
'device_roles': ['voice-gateway'],
|
|
97
|
+
# Manufacturer slugs to show tab for (empty = all)
|
|
98
|
+
'manufacturers': ['cisco'],
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
See the [Configuration wiki](https://github.com/sieteunoseis/netbox-oxidized/wiki/Configuration) for full details.
|
|
104
|
+
|
|
105
|
+
## Usage
|
|
106
|
+
|
|
107
|
+
Once installed and configured:
|
|
108
|
+
|
|
109
|
+
1. Navigate to any Device in NetBox that matches your filter criteria
|
|
110
|
+
2. Click the **Oxidized** tab
|
|
111
|
+
3. View the node status and latest configuration
|
|
112
|
+
4. Use the **Copy** button to copy the config
|
|
113
|
+
5. Click **Open in Oxidized** to view version history
|
|
114
|
+
|
|
115
|
+
## Documentation
|
|
116
|
+
|
|
117
|
+
Full documentation is available on the [Wiki](https://github.com/sieteunoseis/netbox-oxidized/wiki):
|
|
118
|
+
|
|
119
|
+
- [Installation](https://github.com/sieteunoseis/netbox-oxidized/wiki/Installation)
|
|
120
|
+
- [Configuration](https://github.com/sieteunoseis/netbox-oxidized/wiki/Configuration)
|
|
121
|
+
- [Troubleshooting](https://github.com/sieteunoseis/netbox-oxidized/wiki/Troubleshooting)
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
### Setup
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
git clone https://github.com/sieteunoseis/netbox-oxidized.git
|
|
129
|
+
cd netbox-oxidized
|
|
130
|
+
pip install -e ".[dev]"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Code Style
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
black netbox_oxidized/
|
|
137
|
+
isort netbox_oxidized/
|
|
138
|
+
flake8 netbox_oxidized/
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Changelog
|
|
142
|
+
|
|
143
|
+
See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
144
|
+
|
|
145
|
+
## Support
|
|
146
|
+
|
|
147
|
+
If you find this plugin helpful, consider supporting development:
|
|
148
|
+
|
|
149
|
+
[](https://buymeacoffee.com/automatebldrs)
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
Apache License 2.0 - See [LICENSE](LICENSE) for details.
|
|
154
|
+
|
|
155
|
+
## Author
|
|
156
|
+
|
|
157
|
+
sieteunoseis
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# NetBox Oxidized Plugin
|
|
2
|
+
|
|
3
|
+
A NetBox plugin that displays [Oxidized](https://github.com/ytti/oxidized) device configuration backups directly in Device detail pages.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
8
|
+
[](https://pypi.org/project/netbox-oxidized/)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Oxidized Tab** - Adds an "Oxidized" tab to Device detail pages
|
|
13
|
+
- **Config Display** - Shows the latest device configuration as code with copy button
|
|
14
|
+
- **Node Status** - Displays backup status, model, and last backup time
|
|
15
|
+
- **Link to Oxidized** - Direct link to the device's version history in Oxidized
|
|
16
|
+
- **Device Filtering** - Configurable by device role and manufacturer slugs
|
|
17
|
+
- **HTMX Loading** - Async content loading without blocking the page
|
|
18
|
+
- **Caching** - API responses cached to reduce load on Oxidized
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- NetBox 4.0 or higher
|
|
23
|
+
- Python 3.10+
|
|
24
|
+
- Oxidized with REST API enabled
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
### From PyPI (recommended)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install netbox-oxidized
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Docker Installation
|
|
35
|
+
|
|
36
|
+
Add to your NetBox Docker requirements file:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# requirements-extra.txt
|
|
40
|
+
netbox-oxidized
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
Add the plugin to your NetBox configuration:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
# configuration.py or plugins.py
|
|
49
|
+
|
|
50
|
+
PLUGINS = [
|
|
51
|
+
'netbox_oxidized',
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
PLUGINS_CONFIG = {
|
|
55
|
+
'netbox_oxidized': {
|
|
56
|
+
# Required: Oxidized REST API URL
|
|
57
|
+
'oxidized_url': 'http://oxidized:8888',
|
|
58
|
+
# Optional: External URL for browser links (if behind reverse proxy)
|
|
59
|
+
'oxidized_external_url': 'https://oxidized.example.com',
|
|
60
|
+
# API timeout in seconds
|
|
61
|
+
'timeout': 30,
|
|
62
|
+
# Cache duration in seconds
|
|
63
|
+
'cache_timeout': 300,
|
|
64
|
+
# SSL certificate verification
|
|
65
|
+
'verify_ssl': False,
|
|
66
|
+
# Device role slugs to show tab for (empty = all)
|
|
67
|
+
'device_roles': ['voice-gateway'],
|
|
68
|
+
# Manufacturer slugs to show tab for (empty = all)
|
|
69
|
+
'manufacturers': ['cisco'],
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
See the [Configuration wiki](https://github.com/sieteunoseis/netbox-oxidized/wiki/Configuration) for full details.
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
78
|
+
Once installed and configured:
|
|
79
|
+
|
|
80
|
+
1. Navigate to any Device in NetBox that matches your filter criteria
|
|
81
|
+
2. Click the **Oxidized** tab
|
|
82
|
+
3. View the node status and latest configuration
|
|
83
|
+
4. Use the **Copy** button to copy the config
|
|
84
|
+
5. Click **Open in Oxidized** to view version history
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
Full documentation is available on the [Wiki](https://github.com/sieteunoseis/netbox-oxidized/wiki):
|
|
89
|
+
|
|
90
|
+
- [Installation](https://github.com/sieteunoseis/netbox-oxidized/wiki/Installation)
|
|
91
|
+
- [Configuration](https://github.com/sieteunoseis/netbox-oxidized/wiki/Configuration)
|
|
92
|
+
- [Troubleshooting](https://github.com/sieteunoseis/netbox-oxidized/wiki/Troubleshooting)
|
|
93
|
+
|
|
94
|
+
## Development
|
|
95
|
+
|
|
96
|
+
### Setup
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git clone https://github.com/sieteunoseis/netbox-oxidized.git
|
|
100
|
+
cd netbox-oxidized
|
|
101
|
+
pip install -e ".[dev]"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Code Style
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
black netbox_oxidized/
|
|
108
|
+
isort netbox_oxidized/
|
|
109
|
+
flake8 netbox_oxidized/
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Changelog
|
|
113
|
+
|
|
114
|
+
See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
115
|
+
|
|
116
|
+
## Support
|
|
117
|
+
|
|
118
|
+
If you find this plugin helpful, consider supporting development:
|
|
119
|
+
|
|
120
|
+
[](https://buymeacoffee.com/automatebldrs)
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
Apache License 2.0 - See [LICENSE](LICENSE) for details.
|
|
125
|
+
|
|
126
|
+
## Author
|
|
127
|
+
|
|
128
|
+
sieteunoseis
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
NetBox Oxidized Plugin
|
|
3
|
+
|
|
4
|
+
Displays device configuration backups from Oxidized on NetBox device detail pages.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from netbox.plugins import PluginConfig
|
|
8
|
+
|
|
9
|
+
__version__ = "0.1.0"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class OxidizedConfig(PluginConfig):
|
|
13
|
+
"""Plugin configuration for NetBox Oxidized integration."""
|
|
14
|
+
|
|
15
|
+
name = "netbox_oxidized"
|
|
16
|
+
verbose_name = "NetBox Oxidized"
|
|
17
|
+
description = "Display Oxidized configuration backups in NetBox device views"
|
|
18
|
+
version = __version__
|
|
19
|
+
author = "Jeremy Worden"
|
|
20
|
+
author_email = "jeremy.worden@gmail.com"
|
|
21
|
+
base_url = "oxidized"
|
|
22
|
+
min_version = "4.0.0"
|
|
23
|
+
|
|
24
|
+
required_settings = []
|
|
25
|
+
|
|
26
|
+
default_settings = {
|
|
27
|
+
"oxidized_url": "",
|
|
28
|
+
"oxidized_external_url": "",
|
|
29
|
+
"timeout": 30,
|
|
30
|
+
"cache_timeout": 300,
|
|
31
|
+
"verify_ssl": False,
|
|
32
|
+
# Device filter - empty lists mean show for all
|
|
33
|
+
"device_roles": [],
|
|
34
|
+
"manufacturers": [],
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
config = OxidizedConfig
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""API module for NetBox Oxidized plugin."""
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""API client for Oxidized REST API integration."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
import requests
|
|
7
|
+
from django.conf import settings
|
|
8
|
+
from django.core.cache import cache
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class OxidizedClient:
|
|
14
|
+
"""Client for Oxidized REST API with caching and error handling."""
|
|
15
|
+
|
|
16
|
+
def __init__(self):
|
|
17
|
+
"""Initialize the client from plugin settings."""
|
|
18
|
+
self.config = settings.PLUGINS_CONFIG.get("netbox_oxidized", {})
|
|
19
|
+
self.base_url = self.config.get("oxidized_url", "").rstrip("/")
|
|
20
|
+
self.timeout = self.config.get("timeout", 30)
|
|
21
|
+
self.cache_timeout = self.config.get("cache_timeout", 300)
|
|
22
|
+
self.verify_ssl = self.config.get("verify_ssl", False)
|
|
23
|
+
|
|
24
|
+
def _make_request(self, endpoint: str, expect_json: bool = True):
|
|
25
|
+
"""Make request to Oxidized REST API.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
endpoint: API endpoint path (e.g., 'nodes.json', 'node/fetch/hostname')
|
|
29
|
+
expect_json: If True, parse response as JSON. If False, return text.
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
Parsed JSON (dict or list), text string, or None on error.
|
|
33
|
+
"""
|
|
34
|
+
url = f"{self.base_url}/{endpoint}"
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
response = requests.get(
|
|
38
|
+
url,
|
|
39
|
+
timeout=self.timeout,
|
|
40
|
+
verify=self.verify_ssl,
|
|
41
|
+
)
|
|
42
|
+
response.raise_for_status()
|
|
43
|
+
if expect_json:
|
|
44
|
+
return response.json()
|
|
45
|
+
return response.text
|
|
46
|
+
except requests.Timeout:
|
|
47
|
+
logger.error(f"Oxidized API request timed out: {endpoint}")
|
|
48
|
+
return None
|
|
49
|
+
except requests.RequestException as e:
|
|
50
|
+
logger.error(f"Oxidized API request failed: {e}")
|
|
51
|
+
return None
|
|
52
|
+
|
|
53
|
+
def _get_all_nodes(self) -> list:
|
|
54
|
+
"""Get all nodes from /nodes.json with caching."""
|
|
55
|
+
cache_key = "netbox_oxidized_all_nodes"
|
|
56
|
+
cached = cache.get(cache_key)
|
|
57
|
+
if cached is not None:
|
|
58
|
+
return cached
|
|
59
|
+
|
|
60
|
+
result = self._make_request("nodes.json")
|
|
61
|
+
if result and isinstance(result, list):
|
|
62
|
+
cache.set(cache_key, result, self.cache_timeout)
|
|
63
|
+
return result
|
|
64
|
+
|
|
65
|
+
return []
|
|
66
|
+
|
|
67
|
+
def get_node(self, name: str) -> dict:
|
|
68
|
+
"""Get node status information by looking up in /nodes.json.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
name: Device hostname.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
Dict with node info (name, model, status, last backup time) or error.
|
|
75
|
+
"""
|
|
76
|
+
nodes = self._get_all_nodes()
|
|
77
|
+
for node in nodes:
|
|
78
|
+
if node.get("name") == name or node.get("full_name") == name:
|
|
79
|
+
node["cached"] = False
|
|
80
|
+
return node
|
|
81
|
+
|
|
82
|
+
return {"error": f"Node '{name}' not found in Oxidized", "cached": False}
|
|
83
|
+
|
|
84
|
+
def get_node_config(self, name: str) -> dict:
|
|
85
|
+
"""Get latest configuration for a node via /node/fetch/<name>.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
name: Device hostname.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
Dict with 'config' key containing the config text, or 'error' key.
|
|
92
|
+
"""
|
|
93
|
+
cache_key = f"netbox_oxidized_config_{name}"
|
|
94
|
+
cached = cache.get(cache_key)
|
|
95
|
+
if cached:
|
|
96
|
+
cached["cached"] = True
|
|
97
|
+
return cached
|
|
98
|
+
|
|
99
|
+
config_text = self._make_request(f"node/fetch/{name}", expect_json=False)
|
|
100
|
+
if config_text is not None:
|
|
101
|
+
result = {"config": config_text, "cached": False}
|
|
102
|
+
cache.set(cache_key, result, self.cache_timeout)
|
|
103
|
+
return result
|
|
104
|
+
|
|
105
|
+
return {"error": f"Config not found for '{name}'", "cached": False}
|
|
106
|
+
|
|
107
|
+
def test_connection(self) -> tuple[bool, str]:
|
|
108
|
+
"""Test connection to Oxidized API.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
Tuple of (success, message).
|
|
112
|
+
"""
|
|
113
|
+
result = self._make_request("nodes.json")
|
|
114
|
+
if result is not None:
|
|
115
|
+
if isinstance(result, list):
|
|
116
|
+
return True, f"Connected. Managing {len(result)} nodes."
|
|
117
|
+
return True, "Connected successfully."
|
|
118
|
+
return False, f"Failed to connect to {self.base_url}"
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def get_client() -> Optional[OxidizedClient]:
|
|
122
|
+
"""Get a configured client instance, or None if not configured."""
|
|
123
|
+
config = settings.PLUGINS_CONFIG.get("netbox_oxidized", {})
|
|
124
|
+
if not config.get("oxidized_url"):
|
|
125
|
+
logger.warning("Oxidized URL not configured")
|
|
126
|
+
return None
|
|
127
|
+
return OxidizedClient()
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Navigation menu items for NetBox Oxidized plugin."""
|
|
2
|
+
|
|
3
|
+
from netbox.plugins import PluginMenuItem
|
|
4
|
+
|
|
5
|
+
menu_items = (
|
|
6
|
+
PluginMenuItem(
|
|
7
|
+
link="plugins:netbox_oxidized:settings",
|
|
8
|
+
link_text="Oxidized Settings",
|
|
9
|
+
permissions=["dcim.view_device"],
|
|
10
|
+
),
|
|
11
|
+
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{% extends 'dcim/device/base.html' %}
|
|
2
|
+
{% load helpers %}
|
|
3
|
+
|
|
4
|
+
{% block content %}
|
|
5
|
+
<div id="oxidized-content"
|
|
6
|
+
hx-get="{% url 'plugins:netbox_oxidized:device_content' pk=object.pk %}"
|
|
7
|
+
hx-trigger="load"
|
|
8
|
+
hx-swap="innerHTML">
|
|
9
|
+
<div class="d-flex justify-content-center align-items-center py-5">
|
|
10
|
+
<div class="text-center">
|
|
11
|
+
<div class="spinner-border text-primary mb-3" role="status" style="width: 3rem; height: 3rem;">
|
|
12
|
+
<span class="visually-hidden">Loading...</span>
|
|
13
|
+
</div>
|
|
14
|
+
<p class="text-muted mb-0">Loading Oxidized configuration...</p>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
{% endblock %}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{% load helpers %}
|
|
2
|
+
|
|
3
|
+
<div class="row mb-3">
|
|
4
|
+
<div class="col-md-12">
|
|
5
|
+
{% if error %}
|
|
6
|
+
<div class="alert alert-warning" role="alert">
|
|
7
|
+
<i class="mdi mdi-alert"></i> {{ error }}
|
|
8
|
+
</div>
|
|
9
|
+
{% else %}
|
|
10
|
+
{# Node Status Card #}
|
|
11
|
+
<div class="card mb-3">
|
|
12
|
+
<div class="card-header d-flex justify-content-between align-items-center">
|
|
13
|
+
<h5 class="card-title mb-0">
|
|
14
|
+
<i class="mdi mdi-server"></i> Oxidized Node Status
|
|
15
|
+
{% if cached %}
|
|
16
|
+
<span class="badge text-bg-secondary ms-2">
|
|
17
|
+
<i class="mdi mdi-cached"></i> Cached
|
|
18
|
+
</span>
|
|
19
|
+
{% endif %}
|
|
20
|
+
</h5>
|
|
21
|
+
{% if external_url %}
|
|
22
|
+
<a href="{{ external_url }}/node/version?node_full={{ node_info.full_name|default:object.name }}" target="_blank" class="btn btn-sm btn-outline-primary">
|
|
23
|
+
<i class="mdi mdi-open-in-new"></i> Open in Oxidized
|
|
24
|
+
</a>
|
|
25
|
+
{% endif %}
|
|
26
|
+
</div>
|
|
27
|
+
<div class="card-body">
|
|
28
|
+
<div class="table-responsive">
|
|
29
|
+
<table class="table table-hover">
|
|
30
|
+
<thead class="table-light">
|
|
31
|
+
<tr>
|
|
32
|
+
<th>Name</th>
|
|
33
|
+
<th>Model</th>
|
|
34
|
+
<th>Last Backup</th>
|
|
35
|
+
<th>Status</th>
|
|
36
|
+
</tr>
|
|
37
|
+
</thead>
|
|
38
|
+
<tbody>
|
|
39
|
+
<tr>
|
|
40
|
+
<td>{{ node_info.name|default:object.name }}</td>
|
|
41
|
+
<td>{{ node_info.model|default:"-" }}</td>
|
|
42
|
+
<td>
|
|
43
|
+
{% if node_info.last %}
|
|
44
|
+
{% if node_info.last.end %}
|
|
45
|
+
{{ node_info.last.end }}
|
|
46
|
+
{% else %}
|
|
47
|
+
{{ node_info.last|default:"-" }}
|
|
48
|
+
{% endif %}
|
|
49
|
+
{% elif node_info.time %}
|
|
50
|
+
{{ node_info.time }}
|
|
51
|
+
{% else %}
|
|
52
|
+
-
|
|
53
|
+
{% endif %}
|
|
54
|
+
</td>
|
|
55
|
+
<td>
|
|
56
|
+
{% with status=node_info.status %}
|
|
57
|
+
{% if status == "success" %}
|
|
58
|
+
<span class="badge text-bg-success">{{ status }}</span>
|
|
59
|
+
{% elif status == "no_connection" or status == "timeout" %}
|
|
60
|
+
<span class="badge text-bg-danger">{{ status }}</span>
|
|
61
|
+
{% elif status == "never" %}
|
|
62
|
+
<span class="badge text-bg-warning">{{ status }}</span>
|
|
63
|
+
{% else %}
|
|
64
|
+
<span class="badge text-bg-secondary">{{ status|default:"unknown" }}</span>
|
|
65
|
+
{% endif %}
|
|
66
|
+
{% endwith %}
|
|
67
|
+
</td>
|
|
68
|
+
</tr>
|
|
69
|
+
</tbody>
|
|
70
|
+
</table>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
{# Configuration Card #}
|
|
76
|
+
{% if config_text %}
|
|
77
|
+
<div class="card">
|
|
78
|
+
<div class="card-header d-flex justify-content-between align-items-center">
|
|
79
|
+
<h5 class="card-title mb-0">
|
|
80
|
+
<i class="mdi mdi-file-document-outline"></i> Latest Configuration
|
|
81
|
+
</h5>
|
|
82
|
+
<button id="copy-config-btn" class="btn btn-sm btn-outline-secondary" onclick="copyConfig()">
|
|
83
|
+
<i class="mdi mdi-content-copy"></i> Copy
|
|
84
|
+
</button>
|
|
85
|
+
</div>
|
|
86
|
+
<div class="card-body p-0">
|
|
87
|
+
<pre id="config-pre" class="mb-0 p-3" style="max-height: 600px; overflow: auto; font-size: 0.8rem;"><code>{{ config_text }}</code></pre>
|
|
88
|
+
<script>
|
|
89
|
+
function copyConfig() {
|
|
90
|
+
const text = document.getElementById('config-pre').innerText;
|
|
91
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
92
|
+
const btn = document.getElementById('copy-config-btn');
|
|
93
|
+
btn.innerHTML = '<i class="mdi mdi-check"></i> Copied';
|
|
94
|
+
setTimeout(() => { btn.innerHTML = '<i class="mdi mdi-content-copy"></i> Copy'; }, 2000);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
{% elif config_error %}
|
|
101
|
+
<div class="alert alert-info" role="alert">
|
|
102
|
+
<i class="mdi mdi-information-outline"></i> {{ config_error }}
|
|
103
|
+
</div>
|
|
104
|
+
{% endif %}
|
|
105
|
+
|
|
106
|
+
{% endif %}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{% extends 'generic/object.html' %}
|
|
2
|
+
{% load helpers %}
|
|
3
|
+
|
|
4
|
+
{% block title %}Oxidized Settings{% endblock %}
|
|
5
|
+
|
|
6
|
+
{% block content %}
|
|
7
|
+
<div class="row">
|
|
8
|
+
<div class="col-md-6">
|
|
9
|
+
<div class="card mb-3">
|
|
10
|
+
<div class="card-header">
|
|
11
|
+
<h5 class="card-title mb-0">
|
|
12
|
+
<i class="mdi mdi-cog"></i> Configuration Status
|
|
13
|
+
</h5>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="card-body">
|
|
16
|
+
{% if configured %}
|
|
17
|
+
<div class="alert alert-success mb-3">
|
|
18
|
+
<i class="mdi mdi-check-circle"></i> Plugin is configured
|
|
19
|
+
</div>
|
|
20
|
+
<table class="table table-sm">
|
|
21
|
+
<tr>
|
|
22
|
+
<th>Oxidized URL</th>
|
|
23
|
+
<td><code>{{ config.oxidized_url }}</code></td>
|
|
24
|
+
</tr>
|
|
25
|
+
<tr>
|
|
26
|
+
<th>External URL</th>
|
|
27
|
+
<td>
|
|
28
|
+
{% if config.oxidized_external_url %}
|
|
29
|
+
<a href="{{ config.oxidized_external_url }}" target="_blank">{{ config.oxidized_external_url }}</a>
|
|
30
|
+
{% else %}
|
|
31
|
+
<span class="text-muted">Not set</span>
|
|
32
|
+
{% endif %}
|
|
33
|
+
</td>
|
|
34
|
+
</tr>
|
|
35
|
+
<tr>
|
|
36
|
+
<th>Timeout</th>
|
|
37
|
+
<td>{{ config.timeout }}s</td>
|
|
38
|
+
</tr>
|
|
39
|
+
<tr>
|
|
40
|
+
<th>Cache Timeout</th>
|
|
41
|
+
<td>{{ config.cache_timeout }}s</td>
|
|
42
|
+
</tr>
|
|
43
|
+
<tr>
|
|
44
|
+
<th>SSL Verification</th>
|
|
45
|
+
<td>{{ config.verify_ssl|yesno:"Enabled,Disabled" }}</td>
|
|
46
|
+
</tr>
|
|
47
|
+
<tr>
|
|
48
|
+
<th>Device Roles</th>
|
|
49
|
+
<td>
|
|
50
|
+
{% if config.device_roles %}
|
|
51
|
+
{% for role in config.device_roles %}<span class="badge text-bg-primary me-1">{{ role }}</span>{% endfor %}
|
|
52
|
+
{% else %}
|
|
53
|
+
<span class="text-muted">All roles</span>
|
|
54
|
+
{% endif %}
|
|
55
|
+
</td>
|
|
56
|
+
</tr>
|
|
57
|
+
<tr>
|
|
58
|
+
<th>Manufacturers</th>
|
|
59
|
+
<td>
|
|
60
|
+
{% if config.manufacturers %}
|
|
61
|
+
{% for mfg in config.manufacturers %}<span class="badge text-bg-primary me-1">{{ mfg }}</span>{% endfor %}
|
|
62
|
+
{% else %}
|
|
63
|
+
<span class="text-muted">All manufacturers</span>
|
|
64
|
+
{% endif %}
|
|
65
|
+
</td>
|
|
66
|
+
</tr>
|
|
67
|
+
</table>
|
|
68
|
+
|
|
69
|
+
<button id="test-btn" class="btn btn-primary" onclick="testConnection()">
|
|
70
|
+
<i class="mdi mdi-connection"></i> Test Connection
|
|
71
|
+
</button>
|
|
72
|
+
<div id="test-result" class="mt-2"></div>
|
|
73
|
+
{% else %}
|
|
74
|
+
<div class="alert alert-warning">
|
|
75
|
+
<i class="mdi mdi-alert"></i> Plugin is not configured
|
|
76
|
+
</div>
|
|
77
|
+
<p>Add configuration to your <code>configuration/plugins.py</code>:</p>
|
|
78
|
+
<pre><code>PLUGINS_CONFIG = {
|
|
79
|
+
"netbox_oxidized": {
|
|
80
|
+
"oxidized_url": "http://oxidized:8888",
|
|
81
|
+
"oxidized_external_url": "https://oxidized.example.com",
|
|
82
|
+
"device_roles": ["voice-gateway"],
|
|
83
|
+
"manufacturers": ["cisco"],
|
|
84
|
+
}
|
|
85
|
+
}</code></pre>
|
|
86
|
+
{% endif %}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<script>
|
|
93
|
+
function testConnection() {
|
|
94
|
+
const btn = document.getElementById('test-btn');
|
|
95
|
+
const result = document.getElementById('test-result');
|
|
96
|
+
btn.disabled = true;
|
|
97
|
+
btn.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Testing...';
|
|
98
|
+
result.innerHTML = '';
|
|
99
|
+
|
|
100
|
+
fetch("{% url 'plugins:netbox_oxidized:test_connection' %}", {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: {
|
|
103
|
+
'X-CSRFToken': '{{ csrf_token }}',
|
|
104
|
+
'Content-Type': 'application/json',
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
.then(response => response.json())
|
|
108
|
+
.then(data => {
|
|
109
|
+
if (data.success) {
|
|
110
|
+
result.innerHTML = '<div class="alert alert-success"><i class="mdi mdi-check-circle"></i> ' + data.message + '</div>';
|
|
111
|
+
} else {
|
|
112
|
+
result.innerHTML = '<div class="alert alert-danger"><i class="mdi mdi-alert-circle"></i> ' + data.error + '</div>';
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
.catch(error => {
|
|
116
|
+
result.innerHTML = '<div class="alert alert-danger"><i class="mdi mdi-alert-circle"></i> Request failed: ' + error + '</div>';
|
|
117
|
+
})
|
|
118
|
+
.finally(() => {
|
|
119
|
+
btn.disabled = false;
|
|
120
|
+
btn.innerHTML = '<i class="mdi mdi-connection"></i> Test Connection';
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
</script>
|
|
124
|
+
{% endblock %}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""URL configuration for NetBox Oxidized plugin."""
|
|
2
|
+
|
|
3
|
+
from django.urls import path
|
|
4
|
+
|
|
5
|
+
from . import views
|
|
6
|
+
|
|
7
|
+
urlpatterns = [
|
|
8
|
+
path("settings/", views.SettingsView.as_view(), name="settings"),
|
|
9
|
+
path("test-connection/", views.TestConnectionView.as_view(), name="test_connection"),
|
|
10
|
+
path("device/<int:pk>/content/", views.DeviceOxidizedContentView.as_view(), name="device_content"),
|
|
11
|
+
]
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""Views for NetBox Oxidized plugin."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
from dcim.models import Device
|
|
6
|
+
from django.conf import settings
|
|
7
|
+
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
|
|
8
|
+
from django.http import HttpResponse, JsonResponse
|
|
9
|
+
from django.shortcuts import render
|
|
10
|
+
from django.template.loader import render_to_string
|
|
11
|
+
from django.views import View
|
|
12
|
+
from netbox.views import generic
|
|
13
|
+
from utilities.views import ViewTab, register_model_view
|
|
14
|
+
|
|
15
|
+
from .client import get_client
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def should_show_tab(obj):
|
|
21
|
+
"""Determine if Oxidized tab should be shown for this device.
|
|
22
|
+
|
|
23
|
+
Checks device role and manufacturer against configured filters.
|
|
24
|
+
Empty filter lists mean show for all devices.
|
|
25
|
+
"""
|
|
26
|
+
config = settings.PLUGINS_CONFIG.get("netbox_oxidized", {})
|
|
27
|
+
device_roles = config.get("device_roles", [])
|
|
28
|
+
manufacturers = config.get("manufacturers", [])
|
|
29
|
+
|
|
30
|
+
if device_roles and hasattr(obj, "role") and obj.role:
|
|
31
|
+
if obj.role.slug not in device_roles:
|
|
32
|
+
return False
|
|
33
|
+
|
|
34
|
+
if manufacturers and hasattr(obj, "device_type") and obj.device_type:
|
|
35
|
+
manufacturer_slug = obj.device_type.manufacturer.slug
|
|
36
|
+
if manufacturer_slug not in manufacturers:
|
|
37
|
+
return False
|
|
38
|
+
|
|
39
|
+
return True
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@register_model_view(Device, "oxidized", path="oxidized")
|
|
43
|
+
class DeviceOxidizedView(generic.ObjectView):
|
|
44
|
+
"""Oxidized tab view for Device detail pages. Renders HTMX loading spinner."""
|
|
45
|
+
|
|
46
|
+
queryset = Device.objects.all()
|
|
47
|
+
template_name = "netbox_oxidized/device_tab.html"
|
|
48
|
+
tab = ViewTab(
|
|
49
|
+
label="Oxidized",
|
|
50
|
+
weight=9005,
|
|
51
|
+
permission="dcim.view_device",
|
|
52
|
+
hide_if_empty=False,
|
|
53
|
+
visible=should_show_tab,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def get(self, request, pk):
|
|
57
|
+
device = Device.objects.get(pk=pk)
|
|
58
|
+
return render(
|
|
59
|
+
request,
|
|
60
|
+
self.template_name,
|
|
61
|
+
{
|
|
62
|
+
"object": device,
|
|
63
|
+
"tab": self.tab,
|
|
64
|
+
},
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class DeviceOxidizedContentView(LoginRequiredMixin, PermissionRequiredMixin, View):
|
|
69
|
+
"""HTMX endpoint that returns Oxidized config content for async loading."""
|
|
70
|
+
|
|
71
|
+
permission_required = "dcim.view_device"
|
|
72
|
+
|
|
73
|
+
def get(self, request, pk):
|
|
74
|
+
device = Device.objects.get(pk=pk)
|
|
75
|
+
config = settings.PLUGINS_CONFIG.get("netbox_oxidized", {})
|
|
76
|
+
external_url = config.get("oxidized_external_url", config.get("oxidized_url", "")).rstrip("/")
|
|
77
|
+
|
|
78
|
+
client = get_client()
|
|
79
|
+
node_info = {}
|
|
80
|
+
config_data = {}
|
|
81
|
+
error = None
|
|
82
|
+
|
|
83
|
+
if client:
|
|
84
|
+
try:
|
|
85
|
+
node_info = client.get_node(device.name)
|
|
86
|
+
if not node_info.get("error"):
|
|
87
|
+
config_data = client.get_node_config(device.name)
|
|
88
|
+
else:
|
|
89
|
+
error = node_info.get("error")
|
|
90
|
+
except Exception as e:
|
|
91
|
+
logger.error(f"Error fetching Oxidized data for {device.name}: {e}")
|
|
92
|
+
error = str(e)
|
|
93
|
+
else:
|
|
94
|
+
error = "Oxidized plugin not configured. Add oxidized_url to PLUGINS_CONFIG."
|
|
95
|
+
|
|
96
|
+
return HttpResponse(
|
|
97
|
+
render_to_string(
|
|
98
|
+
"netbox_oxidized/device_tab_content.html",
|
|
99
|
+
{
|
|
100
|
+
"object": device,
|
|
101
|
+
"node_info": node_info,
|
|
102
|
+
"config_text": config_data.get("config", ""),
|
|
103
|
+
"config_error": config_data.get("error"),
|
|
104
|
+
"error": error,
|
|
105
|
+
"external_url": external_url,
|
|
106
|
+
"cached": node_info.get("cached", False) or config_data.get("cached", False),
|
|
107
|
+
},
|
|
108
|
+
request=request,
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class SettingsView(View):
|
|
114
|
+
"""Plugin settings page."""
|
|
115
|
+
|
|
116
|
+
template_name = "netbox_oxidized/settings.html"
|
|
117
|
+
|
|
118
|
+
def get(self, request):
|
|
119
|
+
config = settings.PLUGINS_CONFIG.get("netbox_oxidized", {})
|
|
120
|
+
client = get_client()
|
|
121
|
+
|
|
122
|
+
return render(
|
|
123
|
+
request,
|
|
124
|
+
self.template_name,
|
|
125
|
+
{
|
|
126
|
+
"config": config,
|
|
127
|
+
"configured": client is not None,
|
|
128
|
+
},
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class TestConnectionView(View):
|
|
133
|
+
"""Test connection to Oxidized API."""
|
|
134
|
+
|
|
135
|
+
def post(self, request):
|
|
136
|
+
client = get_client()
|
|
137
|
+
if not client:
|
|
138
|
+
return JsonResponse({"success": False, "error": "Plugin not configured"}, status=400)
|
|
139
|
+
|
|
140
|
+
success, message = client.test_connection()
|
|
141
|
+
if success:
|
|
142
|
+
return JsonResponse({"success": True, "message": message})
|
|
143
|
+
return JsonResponse({"success": False, "error": message}, status=400)
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: netbox-oxidized
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: NetBox plugin for oxidized integration
|
|
5
|
+
Author-email: sieteunoseis <jeremy.worden@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/sieteunoseis/netbox-oxidized
|
|
8
|
+
Project-URL: Repository, https://github.com/sieteunoseis/netbox-oxidized
|
|
9
|
+
Project-URL: Documentation, https://github.com/sieteunoseis/netbox-oxidized/wiki
|
|
10
|
+
Project-URL: Changelog, https://github.com/sieteunoseis/netbox-oxidized/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: netbox,netbox-plugin,oxidized
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Framework :: Django
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: requests>=2.25.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: black; extra == "dev"
|
|
26
|
+
Requires-Dist: flake8; extra == "dev"
|
|
27
|
+
Requires-Dist: isort; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# NetBox Oxidized Plugin
|
|
31
|
+
|
|
32
|
+
A NetBox plugin that displays [Oxidized](https://github.com/ytti/oxidized) device configuration backups directly in Device detail pages.
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
37
|
+
[](https://pypi.org/project/netbox-oxidized/)
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Oxidized Tab** - Adds an "Oxidized" tab to Device detail pages
|
|
42
|
+
- **Config Display** - Shows the latest device configuration as code with copy button
|
|
43
|
+
- **Node Status** - Displays backup status, model, and last backup time
|
|
44
|
+
- **Link to Oxidized** - Direct link to the device's version history in Oxidized
|
|
45
|
+
- **Device Filtering** - Configurable by device role and manufacturer slugs
|
|
46
|
+
- **HTMX Loading** - Async content loading without blocking the page
|
|
47
|
+
- **Caching** - API responses cached to reduce load on Oxidized
|
|
48
|
+
|
|
49
|
+
## Requirements
|
|
50
|
+
|
|
51
|
+
- NetBox 4.0 or higher
|
|
52
|
+
- Python 3.10+
|
|
53
|
+
- Oxidized with REST API enabled
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
### From PyPI (recommended)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install netbox-oxidized
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Docker Installation
|
|
64
|
+
|
|
65
|
+
Add to your NetBox Docker requirements file:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# requirements-extra.txt
|
|
69
|
+
netbox-oxidized
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Configuration
|
|
73
|
+
|
|
74
|
+
Add the plugin to your NetBox configuration:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
# configuration.py or plugins.py
|
|
78
|
+
|
|
79
|
+
PLUGINS = [
|
|
80
|
+
'netbox_oxidized',
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
PLUGINS_CONFIG = {
|
|
84
|
+
'netbox_oxidized': {
|
|
85
|
+
# Required: Oxidized REST API URL
|
|
86
|
+
'oxidized_url': 'http://oxidized:8888',
|
|
87
|
+
# Optional: External URL for browser links (if behind reverse proxy)
|
|
88
|
+
'oxidized_external_url': 'https://oxidized.example.com',
|
|
89
|
+
# API timeout in seconds
|
|
90
|
+
'timeout': 30,
|
|
91
|
+
# Cache duration in seconds
|
|
92
|
+
'cache_timeout': 300,
|
|
93
|
+
# SSL certificate verification
|
|
94
|
+
'verify_ssl': False,
|
|
95
|
+
# Device role slugs to show tab for (empty = all)
|
|
96
|
+
'device_roles': ['voice-gateway'],
|
|
97
|
+
# Manufacturer slugs to show tab for (empty = all)
|
|
98
|
+
'manufacturers': ['cisco'],
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
See the [Configuration wiki](https://github.com/sieteunoseis/netbox-oxidized/wiki/Configuration) for full details.
|
|
104
|
+
|
|
105
|
+
## Usage
|
|
106
|
+
|
|
107
|
+
Once installed and configured:
|
|
108
|
+
|
|
109
|
+
1. Navigate to any Device in NetBox that matches your filter criteria
|
|
110
|
+
2. Click the **Oxidized** tab
|
|
111
|
+
3. View the node status and latest configuration
|
|
112
|
+
4. Use the **Copy** button to copy the config
|
|
113
|
+
5. Click **Open in Oxidized** to view version history
|
|
114
|
+
|
|
115
|
+
## Documentation
|
|
116
|
+
|
|
117
|
+
Full documentation is available on the [Wiki](https://github.com/sieteunoseis/netbox-oxidized/wiki):
|
|
118
|
+
|
|
119
|
+
- [Installation](https://github.com/sieteunoseis/netbox-oxidized/wiki/Installation)
|
|
120
|
+
- [Configuration](https://github.com/sieteunoseis/netbox-oxidized/wiki/Configuration)
|
|
121
|
+
- [Troubleshooting](https://github.com/sieteunoseis/netbox-oxidized/wiki/Troubleshooting)
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
### Setup
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
git clone https://github.com/sieteunoseis/netbox-oxidized.git
|
|
129
|
+
cd netbox-oxidized
|
|
130
|
+
pip install -e ".[dev]"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Code Style
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
black netbox_oxidized/
|
|
137
|
+
isort netbox_oxidized/
|
|
138
|
+
flake8 netbox_oxidized/
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Changelog
|
|
142
|
+
|
|
143
|
+
See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
144
|
+
|
|
145
|
+
## Support
|
|
146
|
+
|
|
147
|
+
If you find this plugin helpful, consider supporting development:
|
|
148
|
+
|
|
149
|
+
[](https://buymeacoffee.com/automatebldrs)
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
Apache License 2.0 - See [LICENSE](LICENSE) for details.
|
|
154
|
+
|
|
155
|
+
## Author
|
|
156
|
+
|
|
157
|
+
sieteunoseis
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
netbox_oxidized/__init__.py
|
|
5
|
+
netbox_oxidized/client.py
|
|
6
|
+
netbox_oxidized/navigation.py
|
|
7
|
+
netbox_oxidized/urls.py
|
|
8
|
+
netbox_oxidized/views.py
|
|
9
|
+
netbox_oxidized.egg-info/PKG-INFO
|
|
10
|
+
netbox_oxidized.egg-info/SOURCES.txt
|
|
11
|
+
netbox_oxidized.egg-info/dependency_links.txt
|
|
12
|
+
netbox_oxidized.egg-info/requires.txt
|
|
13
|
+
netbox_oxidized.egg-info/top_level.txt
|
|
14
|
+
netbox_oxidized/api/__init__.py
|
|
15
|
+
netbox_oxidized/api/urls.py
|
|
16
|
+
netbox_oxidized/templates/netbox_oxidized/device_tab.html
|
|
17
|
+
netbox_oxidized/templates/netbox_oxidized/device_tab_content.html
|
|
18
|
+
netbox_oxidized/templates/netbox_oxidized/settings.html
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
netbox_oxidized
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "netbox-oxidized"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "NetBox plugin for oxidized integration"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "Apache-2.0"}
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "sieteunoseis", email = "jeremy.worden@gmail.com"}
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Framework :: Django",
|
|
18
|
+
"Intended Audience :: System Administrators",
|
|
19
|
+
"License :: OSI Approved :: Apache Software License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
]
|
|
25
|
+
keywords = ["netbox", "netbox-plugin", "oxidized"]
|
|
26
|
+
|
|
27
|
+
dependencies = [
|
|
28
|
+
"requests>=2.25.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"black",
|
|
34
|
+
"flake8",
|
|
35
|
+
"isort",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/sieteunoseis/netbox-oxidized"
|
|
40
|
+
Repository = "https://github.com/sieteunoseis/netbox-oxidized"
|
|
41
|
+
Documentation = "https://github.com/sieteunoseis/netbox-oxidized/wiki"
|
|
42
|
+
Changelog = "https://github.com/sieteunoseis/netbox-oxidized/blob/main/CHANGELOG.md"
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.packages.find]
|
|
45
|
+
include = ["netbox_oxidized*"]
|
|
46
|
+
|
|
47
|
+
[tool.setuptools.package-data]
|
|
48
|
+
netbox_oxidized = ["templates/**/*.html"]
|
|
49
|
+
|
|
50
|
+
[tool.black]
|
|
51
|
+
line-length = 120
|
|
52
|
+
target-version = ['py310', 'py311', 'py312']
|
|
53
|
+
|
|
54
|
+
[tool.isort]
|
|
55
|
+
profile = "black"
|
|
56
|
+
line_length = 120
|