netbox-bmc 0.4.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 (45) hide show
  1. netbox_bmc-0.4.0/LICENSE +182 -0
  2. netbox_bmc-0.4.0/NOTICE +4 -0
  3. netbox_bmc-0.4.0/PKG-INFO +230 -0
  4. netbox_bmc-0.4.0/README.md +195 -0
  5. netbox_bmc-0.4.0/netbox_bmc/__init__.py +78 -0
  6. netbox_bmc-0.4.0/netbox_bmc/api/__init__.py +0 -0
  7. netbox_bmc-0.4.0/netbox_bmc/api/serializers.py +23 -0
  8. netbox_bmc-0.4.0/netbox_bmc/api/urls.py +7 -0
  9. netbox_bmc-0.4.0/netbox_bmc/api/views.py +9 -0
  10. netbox_bmc-0.4.0/netbox_bmc/credentials.py +209 -0
  11. netbox_bmc-0.4.0/netbox_bmc/drivers/__init__.py +3 -0
  12. netbox_bmc-0.4.0/netbox_bmc/drivers/base.py +71 -0
  13. netbox_bmc-0.4.0/netbox_bmc/drivers/ipmi.py +103 -0
  14. netbox_bmc-0.4.0/netbox_bmc/drivers/redfish.py +543 -0
  15. netbox_bmc-0.4.0/netbox_bmc/forms.py +18 -0
  16. netbox_bmc-0.4.0/netbox_bmc/inventory.py +43 -0
  17. netbox_bmc-0.4.0/netbox_bmc/jobs.py +28 -0
  18. netbox_bmc-0.4.0/netbox_bmc/migrations/0001_initial.py +75 -0
  19. netbox_bmc-0.4.0/netbox_bmc/migrations/0002_add_jobs_feature.py +23 -0
  20. netbox_bmc-0.4.0/netbox_bmc/migrations/0003_inventoryitem_redfish_path_cf.py +47 -0
  21. netbox_bmc-0.4.0/netbox_bmc/migrations/0004_module_custom_fields.py +80 -0
  22. netbox_bmc-0.4.0/netbox_bmc/migrations/0005_device_firmware_cf.py +54 -0
  23. netbox_bmc-0.4.0/netbox_bmc/migrations/__init__.py +0 -0
  24. netbox_bmc-0.4.0/netbox_bmc/models.py +71 -0
  25. netbox_bmc-0.4.0/netbox_bmc/module_sync.py +305 -0
  26. netbox_bmc-0.4.0/netbox_bmc/navigation.py +15 -0
  27. netbox_bmc-0.4.0/netbox_bmc/normalizer.py +86 -0
  28. netbox_bmc-0.4.0/netbox_bmc/tables.py +25 -0
  29. netbox_bmc-0.4.0/netbox_bmc/template_content.py +19 -0
  30. netbox_bmc-0.4.0/netbox_bmc/templates/netbox_bmc/bmcendpoint.html +96 -0
  31. netbox_bmc-0.4.0/netbox_bmc/templates/netbox_bmc/inc/device_bmc_panel.html +29 -0
  32. netbox_bmc-0.4.0/netbox_bmc/templates/netbox_bmc/module_preview.html +145 -0
  33. netbox_bmc-0.4.0/netbox_bmc/urls.py +24 -0
  34. netbox_bmc-0.4.0/netbox_bmc/views.py +191 -0
  35. netbox_bmc-0.4.0/netbox_bmc.egg-info/PKG-INFO +230 -0
  36. netbox_bmc-0.4.0/netbox_bmc.egg-info/SOURCES.txt +43 -0
  37. netbox_bmc-0.4.0/netbox_bmc.egg-info/dependency_links.txt +1 -0
  38. netbox_bmc-0.4.0/netbox_bmc.egg-info/requires.txt +7 -0
  39. netbox_bmc-0.4.0/netbox_bmc.egg-info/top_level.txt +1 -0
  40. netbox_bmc-0.4.0/pyproject.toml +59 -0
  41. netbox_bmc-0.4.0/setup.cfg +4 -0
  42. netbox_bmc-0.4.0/tests/test_module_sync_apply.py +288 -0
  43. netbox_bmc-0.4.0/tests/test_module_sync_diff.py +97 -0
  44. netbox_bmc-0.4.0/tests/test_normalizer.py +71 -0
  45. netbox_bmc-0.4.0/tests/test_redfish_extensions.py +138 -0
@@ -0,0 +1,182 @@
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 made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or otherwise designated in writing by the copyright owner as
57
+ "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or a Contribution
81
+ incorporated within the Work constitutes direct or contributory patent
82
+ infringement, then any patent licenses granted to You under this License
83
+ for that Work shall terminate as of the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the
86
+ Work or Derivative Works thereof in any medium, with or without
87
+ modifications, and in Source or Object form, provided that You
88
+ meet the following conditions:
89
+
90
+ (a) You must give any other recipients of the Work or
91
+ Derivative Works a copy of this License; and
92
+
93
+ (b) You must cause any modified files to carry prominent notices
94
+ stating that You changed the files; and
95
+
96
+ (c) You must retain, in the Source form of any Derivative Works
97
+ that You distribute, all copyright, patent, trademark, and
98
+ attribution notices from the Source form of the Work,
99
+ excluding those notices that do not pertain to any part of
100
+ the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its
103
+ distribution, You must include a readable copy of the
104
+ attribution notices contained within such NOTICE file, in
105
+ at least one of the following places: within a NOTICE text
106
+ file distributed as part of the Derivative Works; within
107
+ the Source form or documentation, if provided along with the
108
+ Derivative Works; or, within a display generated by the
109
+ Derivative Works, if and wherever such third-party notices
110
+ normally appear. The contents of the NOTICE file are for
111
+ informational purposes only and do not modify the License.
112
+ You may add Your own attribution notices within Derivative
113
+ Works that You distribute, alongside or as an addendum to
114
+ the NOTICE text from the Work, provided that such additional
115
+ attribution notices cannot be construed as modifying the License.
116
+
117
+ You may add Your own license statement for Your modifications and
118
+ may provide additional grant of rights to use, copy, modify, merge,
119
+ publish, distribute, sublicense, and/or sell copies of the
120
+ Contribution, either by you alone or on behalf of the Licensor.
121
+
122
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
123
+ any Contribution intentionally submitted for inclusion in the Work
124
+ by You to the Licensor shall be under the terms and conditions of
125
+ this License, without any additional terms or conditions.
126
+ Notwithstanding the above, nothing herein shall supersede or modify
127
+ the terms of any separate license agreement you may have executed
128
+ with Licensor regarding such Contributions.
129
+
130
+ 6. Trademarks. This License does not grant permission to use the trade
131
+ names, trademarks, service marks, or product names of the Licensor,
132
+ except as required for reasonable and customary use in describing the
133
+ origin of the Work and reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty. Unless required by applicable law or
136
+ agreed to in writing, Licensor provides the Work (and each
137
+ Contributor provides its Contributions) on an "AS IS" BASIS,
138
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
139
+ implied, including, without limitation, any warranties or conditions
140
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
141
+ PARTICULAR PURPOSE. You are solely responsible for determining the
142
+ appropriateness of using or reproducing the Work and assume any
143
+ risks associated with Your exercise of permissions under this License.
144
+
145
+ 8. Limitation of Liability. In no event and under no legal theory,
146
+ whether in tort (including negligence), contract, or otherwise,
147
+ unless required by applicable law (such as deliberate and grossly
148
+ negligent acts) or agreed to in writing, shall any Contributor be
149
+ liable to You for damages, including any direct, indirect, special,
150
+ incidental, or exemplary damages of any character arising as a
151
+ result of this License or out of the use or inability to use the
152
+ Work (including but not limited to damages for loss of goodwill,
153
+ work stoppage, computer failure or malfunction, or all other
154
+ commercial damages or losses), even if such Contributor has been
155
+ advised of the possibility of such damages.
156
+
157
+ 9. Accepting Warranty or Additional Liability. While redistributing
158
+ the Work or Derivative Works thereof, You may choose to offer,
159
+ and charge a fee for, acceptance of support, warranty, indemnity,
160
+ or other liability obligations and/or rights consistent with this
161
+ License. However, in accepting such obligations, You may act only
162
+ on Your own behalf and on Your sole responsibility, not on behalf
163
+ of any other Contributor, and only if You agree to indemnify,
164
+ defend, and hold each Contributor harmless for any liability
165
+ incurred by, or claims asserted against, such Contributor by reason
166
+ of your accepting any such warranty or additional liability.
167
+
168
+ END OF TERMS AND CONDITIONS
169
+
170
+ Copyright 2024 tak-labo
171
+
172
+ Licensed under the Apache License, Version 2.0 (the "License");
173
+ you may not use this file except in compliance with the License.
174
+ You may obtain a copy of the License at
175
+
176
+ http://www.apache.org/licenses/LICENSE-2.0
177
+
178
+ Unless required by applicable law or agreed to in writing, software
179
+ distributed under the License is distributed on an "AS IS" BASIS,
180
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
181
+ See the License for the specific language governing permissions and
182
+ limitations under the License.
@@ -0,0 +1,4 @@
1
+ netbox-bmc
2
+ Copyright 2024 tak-labo
3
+
4
+ This product is licensed under the Apache License, Version 2.0.
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.4
2
+ Name: netbox-bmc
3
+ Version: 0.4.0
4
+ Summary: Unified out-of-band management for NetBox: Redfish & IPMI inventory sync, power control, console access
5
+ Author: tak-labo
6
+ License: Apache-2.0
7
+ Project-URL: Documentation, https://github.com/tak-labo/netbox-bmc/blob/main/README.md
8
+ Project-URL: Source, https://github.com/tak-labo/netbox-bmc
9
+ Project-URL: Tracker, https://github.com/tak-labo/netbox-bmc/issues
10
+ Keywords: netbox,netbox-plugin
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Framework :: Django
13
+ Classifier: Framework :: Django :: 5.2
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Natural Language :: English
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: System :: Networking
24
+ Requires-Python: >=3.12.0
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ License-File: NOTICE
28
+ Requires-Dist: requests>=2.31
29
+ Requires-Dist: pyghmi>=1.5
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=8.0; extra == "dev"
32
+ Requires-Dist: pytest-mock>=3.14; extra == "dev"
33
+ Requires-Dist: ruff>=0.4; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # netbox-bmc
37
+
38
+ [![NetBox](https://img.shields.io/badge/NetBox-4.5%20|%204.6-blue)](https://github.com/netbox-community/netbox)
39
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-blue)](https://www.python.org/)
40
+ [![License](https://img.shields.io/badge/License-Apache%202.0-green)](LICENSE)
41
+
42
+ [日本語](README_ja.md)
43
+
44
+ Unified out-of-band management plugin for NetBox.
45
+ Inventory sync and power control via Redfish & IPMI.
46
+
47
+ ## Supported Protocols / Vendors
48
+
49
+ | Protocol | Vendors |
50
+ |---|---|
51
+ | Redfish | Dell iDRAC, HPE iLO, Lenovo XCC, Supermicro, Generic |
52
+ | IPMI | Fallback for any IPMI-capable BMC |
53
+
54
+ Protocol is auto-detected: probes `/redfish/v1` first, falls back to IPMI on failure.
55
+
56
+ ## Tested Hardware
57
+
58
+ | Manufacturer | Model Series | BMC | Protocol | Status |
59
+ |---|---|---|---|---|
60
+ | Dell | PowerEdge | iDRAC 9 | Redfish | Expected to work |
61
+ | HPE | ProLiant | iLO 5 | Redfish | Expected to work |
62
+ | HPE | ProLiant | iLO 6 | Redfish | Expected to work |
63
+ | Lenovo | ThinkSystem | XCC2 / XCC3 | Redfish | Expected to work |
64
+ | Supermicro | X12 / X13 | BMC | Redfish | Expected to work |
65
+ | Generic | — | Any IPMI-capable BMC | IPMI | Expected to work (fallback) |
66
+
67
+ ## Features
68
+
69
+ - **Module Builder**: Sync BMC hardware inventory to NetBox Modules
70
+ - Scan via Redfish → preview detected components with diff badges (new / updated / unchanged / removed)
71
+ - Select individual components before applying
72
+ - Auto-create ModuleBays when missing (warned in preview)
73
+ - Detect serial number changes after FRU replacement and apply diff updates
74
+ - Only manages `bmc-synced`-tagged Modules; never touches manually created Modules
75
+ - **Collected components**: CPU, Memory, Drive, PSU, Fan, Firmware, PCI devices
76
+ - PSU and Fan collected via Chassis link; PCIe via PCIeDevices collection
77
+ - **Vendor auto-detection**: Dispatches to Dell / HPE / Lenovo subclass drivers based on ServiceRoot `Vendor` / `Oem` keys
78
+ - **Power control**: on / off / soft / cycle / reset (both protocols)
79
+
80
+ ## Install
81
+
82
+ ### Standard (non-Docker)
83
+
84
+ ```bash
85
+ pip install netbox-bmc
86
+ ```
87
+
88
+ Add to `configuration.py`:
89
+
90
+ ```python
91
+ PLUGINS = ["netbox_bmc"]
92
+ PLUGINS_CONFIG = {
93
+ "netbox_bmc": {
94
+ "sync_interval_minutes": 0,
95
+ "default_verify_ssl": False,
96
+ },
97
+ }
98
+ ```
99
+
100
+ Run migrations:
101
+
102
+ ```bash
103
+ python manage.py migrate
104
+ ```
105
+
106
+ ### Docker (netbox-docker)
107
+
108
+ Add a volume mount in `docker-compose.override.yml`:
109
+
110
+ ```yaml
111
+ services:
112
+ netbox: &netbox
113
+ volumes:
114
+ - ./netbox-bmc:/opt/netbox-bmc
115
+ ```
116
+
117
+ Install in editable mode and restart:
118
+
119
+ ```bash
120
+ docker compose exec netbox pip install -e /opt/netbox-bmc
121
+ docker compose exec netbox python manage.py migrate
122
+ docker compose restart netbox netbox-worker
123
+ ```
124
+
125
+ ## Configure
126
+
127
+ Edit `PLUGINS_CONFIG["netbox_bmc"]` in `configuration.py`:
128
+
129
+ | Key | Default | Description |
130
+ |---|---|---|
131
+ | `sync_interval_minutes` | `0` | Scheduled bulk sync interval in minutes. `0` disables. |
132
+ | `default_verify_ssl` | `False` | Default SSL verification for new BMC Endpoints. |
133
+ | `service_account` | — | Service account name for background jobs (netbox-secrets). |
134
+ | `service_private_key_path` | — | Path to private key for service account (netbox-secrets). |
135
+
136
+ ## Use
137
+
138
+ 1. Open a Device in NetBox and click **BMC Endpoints** → **Add**
139
+ 2. Enter the BMC address and credentials, then save
140
+ 3. On the Endpoint detail page, click **[Build Modules]**
141
+ 4. Review the component preview (new / updated / unchanged / removed)
142
+ 5. Check the components to sync and click **[Apply Selected]**
143
+
144
+ ModuleBays, ModuleTypes, and Modules are created or updated automatically.
145
+
146
+ ### Module Naming
147
+
148
+ Vendor-specific names are normalized to a consistent format:
149
+
150
+ | Raw name (Redfish) | Normalized |
151
+ |---|---|
152
+ | `CPU.Socket.1` / `Processor 0` | `CPU 0` |
153
+ | `DIMM.A1` / `Memory 0` | `Memory 0` |
154
+ | `Disk.Bay.0` | `Drive 0` |
155
+ | `NIC.Slot.1` (PCIe) | `PCI 0` |
156
+
157
+ ### Custom Fields
158
+
159
+ The following custom fields are set automatically on each Module:
160
+
161
+ | Field | Content |
162
+ |---|---|
163
+ | `bmc_redfish_path` | Source Redfish URI |
164
+ | `bmc_firmware_version` | Firmware version string |
165
+
166
+ ## Versions
167
+
168
+ | netbox-bmc | NetBox |
169
+ |---|---|
170
+ | 0.4.x | 4.5, 4.6 |
171
+
172
+ ## Vendor Notes
173
+
174
+ ### Dell iDRAC
175
+
176
+ iDRAC 9 (Redfish 1.x) is the primary target. URI traversal starts from `ServiceRoot` links — no hardcoded paths — so firmware variations should be absorbed automatically.
177
+
178
+ ### HPE iLO
179
+
180
+ iLO 5 and iLO 6 are supported via the HPE subclass driver. iLO 4 (Redfish 1.0 partial compliance) is **not tested** and may not work correctly.
181
+
182
+ ### Lenovo XCC
183
+
184
+ XCC2 and XCC3 are supported. Some older XCC firmware versions expose non-standard collection URIs; the link-traversal approach handles most variations.
185
+
186
+ ### Supermicro
187
+
188
+ Generic Redfish driver is used. Supermicro BMC firmware varies significantly; behaviour may differ across firmware versions.
189
+
190
+ ## Development
191
+
192
+ ```bash
193
+ # Install dev dependencies
194
+ uv sync --extra dev
195
+
196
+ # Run tests
197
+ uv run pytest
198
+ ```
199
+
200
+ ### Adding a New Vendor
201
+
202
+ 1. Add a subclass in `netbox_bmc/drivers/redfish.py` extending `RedfishDriver`
203
+ 2. Register it in `detect_and_build()` in `netbox_bmc/drivers/base.py` by matching `ServiceRoot` vendor keys
204
+ 3. Add unit tests in `tests/test_redfish_extensions.py`
205
+
206
+ ### Adding a New Protocol
207
+
208
+ Implement `BaseDriver` (`netbox_bmc/drivers/base.py`) and return `InventoryResult` from `get_inventory()`.
209
+
210
+ ## Credentials
211
+
212
+ netbox-bmc resolves BMC credentials in the following order:
213
+
214
+ 1. **netbox-secrets** (preferred) — `Secret` with role `bmc-credentials` assigned to the Device.
215
+ `Secret.name` = BMC username, `Secret.plaintext` = BMC password (RSA-encrypted).
216
+ 2. **Plaintext fallback** — `username` / `password` fields on `BMCEndpoint`, used when netbox-secrets is not installed or no matching secret is found.
217
+
218
+ For background jobs (scheduled sync), set `service_account` and `service_private_key_path` in `PLUGINS_CONFIG` so the job can decrypt secrets without an HTTP session.
219
+
220
+ ## Known Limitations
221
+
222
+ - REST API (serializers / viewsets) not yet implemented
223
+ - Multi-node chassis (multiple `Systems`) not supported
224
+ - Scheduled bulk sync (`ScheduledInventorySyncJob`) not yet implemented
225
+ - KVM / SOL console not yet ported from the predecessor plugin
226
+ - Old BMCs with low Redfish compliance (e.g. HPE iLO 4) not validated
227
+
228
+ ## License
229
+
230
+ Apache License 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,195 @@
1
+ # netbox-bmc
2
+
3
+ [![NetBox](https://img.shields.io/badge/NetBox-4.5%20|%204.6-blue)](https://github.com/netbox-community/netbox)
4
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-blue)](https://www.python.org/)
5
+ [![License](https://img.shields.io/badge/License-Apache%202.0-green)](LICENSE)
6
+
7
+ [日本語](README_ja.md)
8
+
9
+ Unified out-of-band management plugin for NetBox.
10
+ Inventory sync and power control via Redfish & IPMI.
11
+
12
+ ## Supported Protocols / Vendors
13
+
14
+ | Protocol | Vendors |
15
+ |---|---|
16
+ | Redfish | Dell iDRAC, HPE iLO, Lenovo XCC, Supermicro, Generic |
17
+ | IPMI | Fallback for any IPMI-capable BMC |
18
+
19
+ Protocol is auto-detected: probes `/redfish/v1` first, falls back to IPMI on failure.
20
+
21
+ ## Tested Hardware
22
+
23
+ | Manufacturer | Model Series | BMC | Protocol | Status |
24
+ |---|---|---|---|---|
25
+ | Dell | PowerEdge | iDRAC 9 | Redfish | Expected to work |
26
+ | HPE | ProLiant | iLO 5 | Redfish | Expected to work |
27
+ | HPE | ProLiant | iLO 6 | Redfish | Expected to work |
28
+ | Lenovo | ThinkSystem | XCC2 / XCC3 | Redfish | Expected to work |
29
+ | Supermicro | X12 / X13 | BMC | Redfish | Expected to work |
30
+ | Generic | — | Any IPMI-capable BMC | IPMI | Expected to work (fallback) |
31
+
32
+ ## Features
33
+
34
+ - **Module Builder**: Sync BMC hardware inventory to NetBox Modules
35
+ - Scan via Redfish → preview detected components with diff badges (new / updated / unchanged / removed)
36
+ - Select individual components before applying
37
+ - Auto-create ModuleBays when missing (warned in preview)
38
+ - Detect serial number changes after FRU replacement and apply diff updates
39
+ - Only manages `bmc-synced`-tagged Modules; never touches manually created Modules
40
+ - **Collected components**: CPU, Memory, Drive, PSU, Fan, Firmware, PCI devices
41
+ - PSU and Fan collected via Chassis link; PCIe via PCIeDevices collection
42
+ - **Vendor auto-detection**: Dispatches to Dell / HPE / Lenovo subclass drivers based on ServiceRoot `Vendor` / `Oem` keys
43
+ - **Power control**: on / off / soft / cycle / reset (both protocols)
44
+
45
+ ## Install
46
+
47
+ ### Standard (non-Docker)
48
+
49
+ ```bash
50
+ pip install netbox-bmc
51
+ ```
52
+
53
+ Add to `configuration.py`:
54
+
55
+ ```python
56
+ PLUGINS = ["netbox_bmc"]
57
+ PLUGINS_CONFIG = {
58
+ "netbox_bmc": {
59
+ "sync_interval_minutes": 0,
60
+ "default_verify_ssl": False,
61
+ },
62
+ }
63
+ ```
64
+
65
+ Run migrations:
66
+
67
+ ```bash
68
+ python manage.py migrate
69
+ ```
70
+
71
+ ### Docker (netbox-docker)
72
+
73
+ Add a volume mount in `docker-compose.override.yml`:
74
+
75
+ ```yaml
76
+ services:
77
+ netbox: &netbox
78
+ volumes:
79
+ - ./netbox-bmc:/opt/netbox-bmc
80
+ ```
81
+
82
+ Install in editable mode and restart:
83
+
84
+ ```bash
85
+ docker compose exec netbox pip install -e /opt/netbox-bmc
86
+ docker compose exec netbox python manage.py migrate
87
+ docker compose restart netbox netbox-worker
88
+ ```
89
+
90
+ ## Configure
91
+
92
+ Edit `PLUGINS_CONFIG["netbox_bmc"]` in `configuration.py`:
93
+
94
+ | Key | Default | Description |
95
+ |---|---|---|
96
+ | `sync_interval_minutes` | `0` | Scheduled bulk sync interval in minutes. `0` disables. |
97
+ | `default_verify_ssl` | `False` | Default SSL verification for new BMC Endpoints. |
98
+ | `service_account` | — | Service account name for background jobs (netbox-secrets). |
99
+ | `service_private_key_path` | — | Path to private key for service account (netbox-secrets). |
100
+
101
+ ## Use
102
+
103
+ 1. Open a Device in NetBox and click **BMC Endpoints** → **Add**
104
+ 2. Enter the BMC address and credentials, then save
105
+ 3. On the Endpoint detail page, click **[Build Modules]**
106
+ 4. Review the component preview (new / updated / unchanged / removed)
107
+ 5. Check the components to sync and click **[Apply Selected]**
108
+
109
+ ModuleBays, ModuleTypes, and Modules are created or updated automatically.
110
+
111
+ ### Module Naming
112
+
113
+ Vendor-specific names are normalized to a consistent format:
114
+
115
+ | Raw name (Redfish) | Normalized |
116
+ |---|---|
117
+ | `CPU.Socket.1` / `Processor 0` | `CPU 0` |
118
+ | `DIMM.A1` / `Memory 0` | `Memory 0` |
119
+ | `Disk.Bay.0` | `Drive 0` |
120
+ | `NIC.Slot.1` (PCIe) | `PCI 0` |
121
+
122
+ ### Custom Fields
123
+
124
+ The following custom fields are set automatically on each Module:
125
+
126
+ | Field | Content |
127
+ |---|---|
128
+ | `bmc_redfish_path` | Source Redfish URI |
129
+ | `bmc_firmware_version` | Firmware version string |
130
+
131
+ ## Versions
132
+
133
+ | netbox-bmc | NetBox |
134
+ |---|---|
135
+ | 0.4.x | 4.5, 4.6 |
136
+
137
+ ## Vendor Notes
138
+
139
+ ### Dell iDRAC
140
+
141
+ iDRAC 9 (Redfish 1.x) is the primary target. URI traversal starts from `ServiceRoot` links — no hardcoded paths — so firmware variations should be absorbed automatically.
142
+
143
+ ### HPE iLO
144
+
145
+ iLO 5 and iLO 6 are supported via the HPE subclass driver. iLO 4 (Redfish 1.0 partial compliance) is **not tested** and may not work correctly.
146
+
147
+ ### Lenovo XCC
148
+
149
+ XCC2 and XCC3 are supported. Some older XCC firmware versions expose non-standard collection URIs; the link-traversal approach handles most variations.
150
+
151
+ ### Supermicro
152
+
153
+ Generic Redfish driver is used. Supermicro BMC firmware varies significantly; behaviour may differ across firmware versions.
154
+
155
+ ## Development
156
+
157
+ ```bash
158
+ # Install dev dependencies
159
+ uv sync --extra dev
160
+
161
+ # Run tests
162
+ uv run pytest
163
+ ```
164
+
165
+ ### Adding a New Vendor
166
+
167
+ 1. Add a subclass in `netbox_bmc/drivers/redfish.py` extending `RedfishDriver`
168
+ 2. Register it in `detect_and_build()` in `netbox_bmc/drivers/base.py` by matching `ServiceRoot` vendor keys
169
+ 3. Add unit tests in `tests/test_redfish_extensions.py`
170
+
171
+ ### Adding a New Protocol
172
+
173
+ Implement `BaseDriver` (`netbox_bmc/drivers/base.py`) and return `InventoryResult` from `get_inventory()`.
174
+
175
+ ## Credentials
176
+
177
+ netbox-bmc resolves BMC credentials in the following order:
178
+
179
+ 1. **netbox-secrets** (preferred) — `Secret` with role `bmc-credentials` assigned to the Device.
180
+ `Secret.name` = BMC username, `Secret.plaintext` = BMC password (RSA-encrypted).
181
+ 2. **Plaintext fallback** — `username` / `password` fields on `BMCEndpoint`, used when netbox-secrets is not installed or no matching secret is found.
182
+
183
+ For background jobs (scheduled sync), set `service_account` and `service_private_key_path` in `PLUGINS_CONFIG` so the job can decrypt secrets without an HTTP session.
184
+
185
+ ## Known Limitations
186
+
187
+ - REST API (serializers / viewsets) not yet implemented
188
+ - Multi-node chassis (multiple `Systems`) not supported
189
+ - Scheduled bulk sync (`ScheduledInventorySyncJob`) not yet implemented
190
+ - KVM / SOL console not yet ported from the predecessor plugin
191
+ - Old BMCs with low Redfish compliance (e.g. HPE iLO 4) not validated
192
+
193
+ ## License
194
+
195
+ Apache License 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,78 @@
1
+ from netbox.plugins import PluginConfig
2
+
3
+ __version__ = "0.4.0"
4
+ __author__ = "tak-labo"
5
+ __email__ = ""
6
+
7
+
8
+ class NetBoxBMCConfig(PluginConfig):
9
+ name = "netbox_bmc"
10
+ verbose_name = "NetBox BMC (IPMI/Redfish)"
11
+ description = "Unified out-of-band management: Redfish & IPMI inventory sync, power control, console access"
12
+ version = __version__
13
+ author = __author__
14
+ author_email = __email__
15
+ base_url = "bmc"
16
+ min_version = "4.5"
17
+ max_version = "4.6.99"
18
+ default_settings = {
19
+ # 定期一括同期の間隔 (分)。0 で無効。
20
+ "sync_interval_minutes": 0,
21
+ "default_verify_ssl": False,
22
+ # netbox-secrets バックグラウンドジョブ用サービスアカウント設定
23
+ # (netbox-secrets 使用時のみ必要)
24
+ # "service_account": "bmc-sync",
25
+ # "service_private_key_path": "/opt/netbox/bmc-sync.pem",
26
+ }
27
+
28
+ def ready(self):
29
+ super().ready()
30
+ from . import jobs # noqa: F401
31
+
32
+ interval = (getattr(self, "settings", None) or {}).get("sync_interval_minutes") or 0
33
+ if interval:
34
+ self._enqueue_scheduled_sync(interval)
35
+
36
+ @staticmethod
37
+ def _enqueue_scheduled_sync(interval_minutes: int) -> None:
38
+ """
39
+ ScheduledInventorySyncJob の定期ジョブを登録する。
40
+
41
+ ready() は workers / web プロセスの起動ごとに呼ばれるため、
42
+ 既に pending / scheduled / running の同名ジョブがあればスキップして
43
+ 冪等にする。初回マイグレーション前など Job テーブル未作成の場合は黙って抜ける。
44
+ """
45
+ import logging
46
+
47
+ from django.db import DatabaseError
48
+
49
+ from .jobs import ScheduledInventorySyncJob
50
+
51
+ logger = logging.getLogger("netbox_bmc")
52
+
53
+ try:
54
+ from datetime import timedelta
55
+
56
+ from core.models import Job
57
+ from django.utils import timezone
58
+
59
+ active = Job.objects.filter(
60
+ name=ScheduledInventorySyncJob.Meta.name,
61
+ status__in=("pending", "scheduled", "running"),
62
+ ).exists()
63
+ if active:
64
+ return
65
+
66
+ ScheduledInventorySyncJob.enqueue(
67
+ instance=None,
68
+ schedule_at=timezone.now() + timedelta(minutes=interval_minutes),
69
+ interval=interval_minutes,
70
+ )
71
+ except DatabaseError:
72
+ # マイグレーション前: Job テーブルが存在しない
73
+ pass
74
+ except Exception as e:
75
+ logger.warning("Failed to schedule recurring inventory sync: %s", e)
76
+
77
+
78
+ config = NetBoxBMCConfig
File without changes