netbox-assets 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.
Files changed (82) hide show
  1. netbox_assets-0.1.0/LICENSE +22 -0
  2. netbox_assets-0.1.0/MANIFEST.in +2 -0
  3. netbox_assets-0.1.0/PKG-INFO +258 -0
  4. netbox_assets-0.1.0/README.md +235 -0
  5. netbox_assets-0.1.0/netbox_assets/__init__.py +51 -0
  6. netbox_assets-0.1.0/netbox_assets/api/__init__.py +0 -0
  7. netbox_assets-0.1.0/netbox_assets/api/serializers.py +1 -0
  8. netbox_assets-0.1.0/netbox_assets/api/serializers_/__init__.py +0 -0
  9. netbox_assets-0.1.0/netbox_assets/api/serializers_/assets.py +185 -0
  10. netbox_assets-0.1.0/netbox_assets/api/serializers_/nested.py +16 -0
  11. netbox_assets-0.1.0/netbox_assets/api/urls.py +19 -0
  12. netbox_assets-0.1.0/netbox_assets/api/views.py +80 -0
  13. netbox_assets-0.1.0/netbox_assets/choices.py +23 -0
  14. netbox_assets-0.1.0/netbox_assets/filtersets.py +430 -0
  15. netbox_assets-0.1.0/netbox_assets/forms/__init__.py +8 -0
  16. netbox_assets-0.1.0/netbox_assets/forms/assign.py +218 -0
  17. netbox_assets-0.1.0/netbox_assets/forms/bulk_add.py +45 -0
  18. netbox_assets-0.1.0/netbox_assets/forms/bulk_edit.py +161 -0
  19. netbox_assets-0.1.0/netbox_assets/forms/bulk_import.py +313 -0
  20. netbox_assets-0.1.0/netbox_assets/forms/create.py +95 -0
  21. netbox_assets-0.1.0/netbox_assets/forms/filters.py +288 -0
  22. netbox_assets-0.1.0/netbox_assets/forms/models.py +197 -0
  23. netbox_assets-0.1.0/netbox_assets/forms/reassign.py +192 -0
  24. netbox_assets-0.1.0/netbox_assets/graphql/__init__.py +7 -0
  25. netbox_assets-0.1.0/netbox_assets/graphql/filters.py +43 -0
  26. netbox_assets-0.1.0/netbox_assets/graphql/schema.py +20 -0
  27. netbox_assets-0.1.0/netbox_assets/graphql/types.py +80 -0
  28. netbox_assets-0.1.0/netbox_assets/managers.py +15 -0
  29. netbox_assets-0.1.0/netbox_assets/migrations/0001_initial.py +339 -0
  30. netbox_assets-0.1.0/netbox_assets/migrations/__init__.py +0 -0
  31. netbox_assets-0.1.0/netbox_assets/models/__init__.py +2 -0
  32. netbox_assets-0.1.0/netbox_assets/models/assets.py +404 -0
  33. netbox_assets-0.1.0/netbox_assets/models/roles.py +57 -0
  34. netbox_assets-0.1.0/netbox_assets/navigation.py +54 -0
  35. netbox_assets-0.1.0/netbox_assets/search.py +32 -0
  36. netbox_assets-0.1.0/netbox_assets/signals.py +68 -0
  37. netbox_assets-0.1.0/netbox_assets/tables.py +374 -0
  38. netbox_assets-0.1.0/netbox_assets/template_content.py +206 -0
  39. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/asset.html +187 -0
  40. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/asset_assign.html +13 -0
  41. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/asset_bulk_add.html +20 -0
  42. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/asset_bulk_import.html +61 -0
  43. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/asset_create.html +10 -0
  44. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/asset_edit.html +110 -0
  45. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/asset_reassign.html +18 -0
  46. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/assetrole.html +10 -0
  47. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/inc/asset_edit_header.html +22 -0
  48. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/inc/asset_info.html +42 -0
  49. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/inc/asset_stats_counts.html +19 -0
  50. netbox_assets-0.1.0/netbox_assets/templates/netbox_assets/inc/assetrole_status.html +16 -0
  51. netbox_assets-0.1.0/netbox_assets/tests/__init__.py +0 -0
  52. netbox_assets-0.1.0/netbox_assets/tests/asset/__init__.py +0 -0
  53. netbox_assets-0.1.0/netbox_assets/tests/asset/test_api.py +191 -0
  54. netbox_assets-0.1.0/netbox_assets/tests/asset/test_models.py +195 -0
  55. netbox_assets-0.1.0/netbox_assets/tests/asset/test_views.py +198 -0
  56. netbox_assets-0.1.0/netbox_assets/tests/asset/test_views_create.py +243 -0
  57. netbox_assets-0.1.0/netbox_assets/tests/asset/test_views_reassign.py +295 -0
  58. netbox_assets-0.1.0/netbox_assets/tests/asset_role/__init__.py +0 -0
  59. netbox_assets-0.1.0/netbox_assets/tests/asset_role/test_api.py +58 -0
  60. netbox_assets-0.1.0/netbox_assets/tests/asset_role/test_tree.py +115 -0
  61. netbox_assets-0.1.0/netbox_assets/tests/asset_role/test_views.py +55 -0
  62. netbox_assets-0.1.0/netbox_assets/tests/custom.py +39 -0
  63. netbox_assets-0.1.0/netbox_assets/tests/query_counts.json +6 -0
  64. netbox_assets-0.1.0/netbox_assets/tests/settings.py +17 -0
  65. netbox_assets-0.1.0/netbox_assets/tests/test_load.py +46 -0
  66. netbox_assets-0.1.0/netbox_assets/ui/__init__.py +0 -0
  67. netbox_assets-0.1.0/netbox_assets/ui/panels.py +46 -0
  68. netbox_assets-0.1.0/netbox_assets/urls.py +61 -0
  69. netbox_assets-0.1.0/netbox_assets/utils.py +167 -0
  70. netbox_assets-0.1.0/netbox_assets/version.py +1 -0
  71. netbox_assets-0.1.0/netbox_assets/views/__init__.py +5 -0
  72. netbox_assets-0.1.0/netbox_assets/views/asset.py +167 -0
  73. netbox_assets-0.1.0/netbox_assets/views/asset_assign.py +21 -0
  74. netbox_assets-0.1.0/netbox_assets/views/asset_create.py +63 -0
  75. netbox_assets-0.1.0/netbox_assets/views/asset_reassign.py +28 -0
  76. netbox_assets-0.1.0/netbox_assets/views/asset_role.py +127 -0
  77. netbox_assets-0.1.0/netbox_assets.egg-info/PKG-INFO +258 -0
  78. netbox_assets-0.1.0/netbox_assets.egg-info/SOURCES.txt +80 -0
  79. netbox_assets-0.1.0/netbox_assets.egg-info/dependency_links.txt +1 -0
  80. netbox_assets-0.1.0/netbox_assets.egg-info/top_level.txt +1 -0
  81. netbox_assets-0.1.0/pyproject.toml +61 -0
  82. netbox_assets-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Arnes
4
+ Copyright (c) 2026 Maksym Ototiuk
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ recursive-include netbox_assets/templates *.html
2
+ include netbox_assets/tests/query_counts.json
@@ -0,0 +1,258 @@
1
+ Metadata-Version: 2.4
2
+ Name: netbox-assets
3
+ Version: 0.1.0
4
+ Summary: Simple asset tracking for NetBox. A stripped-down fork of netbox-inventory.
5
+ Author-email: Maksym Ototiuk <pypi@masik.slmail.me>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Maksym-Ototiuk/netbox-assets
8
+ Project-URL: Issues, https://github.com/Maksym-Ototiuk/netbox-assets/issues
9
+ Project-URL: Upstream, https://github.com/ArnesSI/netbox-inventory
10
+ Keywords: netbox,netbox-plugin,assets,inventory
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Framework :: Django
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Requires-Python: >=3.12
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # NetBox Assets
25
+
26
+ A [NetBox](https://github.com/netbox-community/netbox) plugin for simple asset
27
+ tracking: keep a record of hardware (devices, modules and racks) that is **not
28
+ currently installed**, for example spare parts and equipment in storage.
29
+
30
+ > **This project is a stripped-down fork of
31
+ > [netbox-inventory](https://github.com/ArnesSI/netbox-inventory)** by Arnes.
32
+ > It is based on upstream commit
33
+ > [`e749f6f`](https://github.com/ArnesSI/netbox-inventory/commit/e749f6fd0aa2494746218537deb5c8727a0fe04a)
34
+ > (v2.7.0). All credit for the original design and code goes to the upstream
35
+ > authors. If you need the full feature set (inventory item types and groups,
36
+ > suppliers, purchases, deliveries, warranty tracking, audit flows), use the
37
+ > original plugin.
38
+
39
+ ## Purpose
40
+
41
+ NetBox documents what is installed in your network. netbox-assets adds a
42
+ place for hardware that is not installed yet, or not any more: what it is,
43
+ its serial number and asset tag, and where it is stored. When an asset is
44
+ installed, you link it to the device, module or rack that represents it in
45
+ NetBox.
46
+
47
+ The goal is simple record keeping, not full inventory management.
48
+
49
+ ## Differences from netbox-inventory
50
+
51
+ | Feature | netbox-inventory | netbox-assets |
52
+ | --------------------------------- | ----------------------------- | ------------------------------------------------ |
53
+ | Assets | Yes | Yes |
54
+ | Asset roles (hierarchical) | Yes (django-mptt) | Yes (PostgreSQL `ltree`, native to NetBox 4.7) |
55
+ | Asset kinds: device, module, rack | Yes | Yes |
56
+ | Asset kind: inventory item | Yes | Removed (inventory items are deprecated in NetBox since v4.3) |
57
+ | Inventory item types and groups | Yes | Removed |
58
+ | Suppliers, purchases, deliveries | Yes | Removed |
59
+ | Warranty tracking | Yes | Removed |
60
+ | Audit flows and audit trails | Yes | Removed |
61
+ | Navigation menu | "Inventory" (configurable) | Always a top-level "Assets" menu |
62
+
63
+ ## Limitations
64
+
65
+ - **Cannot be installed together with netbox-inventory.** Both plugins define
66
+ the same relations on NetBox core models (for example
67
+ `Device.assigned_asset`) and the same GraphQL type names. netbox-assets
68
+ refuses to start if `netbox_inventory` is also enabled. This is a
69
+ deliberate simplification.
70
+ - **No data migration from netbox-inventory.** netbox-assets is meant for a
71
+ clean installation. It ships its own fresh database migrations and does not
72
+ read or convert netbox-inventory data.
73
+
74
+ ## Compatibility
75
+
76
+ | NetBox | netbox-assets |
77
+ | ---------------- | ------------- |
78
+ | 4.7.1 and later | 0.1.x |
79
+
80
+ NetBox 4.7 requires Python 3.12 or later, PostgreSQL 15 or later with the
81
+ `ltree` extension, and Redis 6 or later.
82
+
83
+ NetBox 4.7.0 is not supported: the database triggers that maintain
84
+ hierarchical paths could not be restored from a database dump in that release
85
+ ([netbox#23130](https://github.com/netbox-community/netbox/issues/23130)).
86
+
87
+ ## Features
88
+
89
+ - Assets with name, asset tag, serial number, status, role, description,
90
+ comments, tags, custom fields and images.
91
+ - Each asset has exactly one hardware type: a device type, a module type or a
92
+ rack type.
93
+ - Assign an asset to a device, module or rack, reassign it or unassign it.
94
+ - Create a new device, module or rack directly from an asset.
95
+ - Storage location, tenant, owning tenant and contact for each asset.
96
+ - Automatic status: `stored` when an asset is unassigned, `used` when it is
97
+ assigned (configurable).
98
+ - Optional synchronization of serial number and asset tag between an asset and
99
+ the hardware it is assigned to.
100
+ - Bulk add with an asset tag pattern, for example `ASSET-[001-010]`.
101
+ - Bulk import, export, edit and delete.
102
+ - Hierarchical asset roles (for example Optics → SFP) with cumulative asset
103
+ counts.
104
+ - Asset information on Device, Module and Rack pages, and asset counts on
105
+ Site, Location, Rack, Tenant, Contact and Manufacturer pages.
106
+ - Global search, REST API and GraphQL API.
107
+
108
+ ## Usage
109
+
110
+ 1. **Create an asset.** In *Assets → Assets*, click *Add* and choose the
111
+ hardware type (a device type, module type or rack type). Fill in the serial
112
+ number, asset tag, storage location and so on. This form describes *what*
113
+ the hardware is. It does not link the asset to a particular device.
114
+ 2. **Assign the asset to hardware.** Use one of these buttons:
115
+ - *Edit Assignment* in the *Assigned To* panel on the asset page;
116
+ - *Edit Assignment* in the *Asset* panel on a device, module or rack page;
117
+ - *Create Device* (or *Create Module*, *Create Rack*) on the asset page, to
118
+ create the hardware and assign the asset in one step.
119
+
120
+ When an asset is assigned, its status changes to `used`. When it is
121
+ unassigned, its status changes to `stored` (see [Settings](#settings)).
122
+
123
+ Assets are displayed as `<manufacturer> <model> <name>`, for example
124
+ `Cisco ASR edge-01`, or as `<manufacturer> <model>` when the asset has no
125
+ name. Unnamed assets of the same model look the same in lists and selection
126
+ fields, so give assets a name if you need to tell them apart.
127
+
128
+ ## Installation
129
+
130
+ Activate the NetBox virtual environment and install the package:
131
+
132
+ ```shell
133
+ source /opt/netbox/venv/bin/activate
134
+ pip install netbox-assets
135
+ ```
136
+
137
+ To keep the plugin installed after NetBox upgrades, add it to
138
+ `local_requirements.txt`:
139
+
140
+ ```shell
141
+ echo netbox-assets >> /opt/netbox/local_requirements.txt
142
+ ```
143
+
144
+ Enable the plugin in `/opt/netbox/netbox/netbox/configuration.py`:
145
+
146
+ ```python
147
+ PLUGINS = [
148
+ 'netbox_assets',
149
+ ]
150
+
151
+ PLUGINS_CONFIG = {
152
+ 'netbox_assets': {},
153
+ }
154
+ ```
155
+
156
+ Apply the database migrations, update the search index and restart NetBox:
157
+
158
+ ```shell
159
+ cd /opt/netbox/netbox
160
+ python3 manage.py migrate netbox_assets
161
+ python3 manage.py reindex --lazy
162
+ sudo systemctl restart netbox netbox-rq
163
+ ```
164
+
165
+ ## Settings
166
+
167
+ Override the defaults in `PLUGINS_CONFIG`:
168
+
169
+ ```python
170
+ PLUGINS_CONFIG = {
171
+ 'netbox_assets': {
172
+ 'used_status_name': 'used',
173
+ 'stored_status_name': 'stored',
174
+ 'sync_hardware_serial_asset_tag': True,
175
+ },
176
+ }
177
+ ```
178
+
179
+ | Setting | Default | Description |
180
+ | ------------------------------------ | --------------- | ----------- |
181
+ | `used_status_name` | `'used'` | Status set when an asset is assigned to a device, module or rack. |
182
+ | `used_additional_status_names` | `[]` | Other statuses that also mean "in use". |
183
+ | `stored_status_name` | `'stored'` | Status set when an asset is unassigned. |
184
+ | `stored_additional_status_names` | `['retired']` | Other statuses that also mean "not in use". |
185
+ | `sync_hardware_serial_asset_tag` | `False` | Keep serial number and asset tag of the assigned device, module or rack in sync with the asset. The device type, module type or rack type is updated as well. |
186
+ | `asset_import_create_device_type` | `False` | When importing assets, create a missing manufacturer and device type. |
187
+ | `asset_import_create_module_type` | `False` | When importing assets, create a missing manufacturer and module type. |
188
+ | `asset_import_create_rack_type` | `False` | When importing assets, create a missing manufacturer and rack type. |
189
+ | `asset_import_create_tenant` | `False` | When importing assets, create a missing tenant (for the tenant and owning tenant fields). |
190
+ | `asset_custom_fields_search_filters` | `{}` | Custom fields and lookups to add to the asset search filters, for example `{'asset_mac': ['icontains', 'exact']}`. |
191
+
192
+ To disable automatic status changes, set both `used_status_name` and
193
+ `stored_status_name` to `None`.
194
+
195
+ ### Asset statuses
196
+
197
+ The default statuses are `stored`, `used` and `retired`. You can add your own
198
+ with the NetBox
199
+ [`FIELD_CHOICES`](https://netboxlabs.com/docs/netbox/configuration/data-validation/#field_choices)
200
+ setting:
201
+
202
+ ```python
203
+ FIELD_CHOICES = {
204
+ 'netbox_assets.Asset.status+': (
205
+ ('repair', 'In repair', 'orange'),
206
+ ),
207
+ }
208
+ ```
209
+
210
+ If you add statuses, also review `used_additional_status_names` and
211
+ `stored_additional_status_names`.
212
+
213
+ ## REST API and GraphQL
214
+
215
+ REST API endpoints:
216
+
217
+ | Endpoint | Description |
218
+ | --------------------------------------- | ----------- |
219
+ | `/api/plugins/assets/assets/` | Assets |
220
+ | `/api/plugins/assets/asset-roles/` | Asset roles |
221
+ | `/api/plugins/assets/dcim/devices/` | NetBox devices with an extra `has_asset_assigned` filter |
222
+ | `/api/plugins/assets/dcim/modules/` | NetBox modules with an extra `has_asset_assigned` filter |
223
+
224
+ GraphQL queries: `asset`, `asset_list`, `asset_role`, `asset_role_list`.
225
+
226
+ ## Development
227
+
228
+ The tests use the NetBox test framework. They need a NetBox 4.7 installation
229
+ with PostgreSQL and Redis, and a database user that is allowed to create the
230
+ test database. Install the plugin into the NetBox virtual environment in
231
+ editable mode (`pip install -e .`) and run:
232
+
233
+ ```shell
234
+ cd /opt/netbox/netbox
235
+ python3 manage.py test netbox_assets.tests --keepdb --parallel 4
236
+ ```
237
+
238
+ NetBox compares the number of database queries of list views with
239
+ `netbox_assets/tests/query_counts.json`. If you change a list view or an API
240
+ serializer on purpose, update the file (this does not work with `--parallel`):
241
+
242
+ ```shell
243
+ UPDATE_QUERY_COUNTS=1 python3 manage.py test netbox_assets.tests --keepdb
244
+ ```
245
+
246
+ GitHub Actions run `ruff` and the test suite against NetBox 4.7.1 and 4.7.2
247
+ on every push and pull request.
248
+
249
+ ## License
250
+
251
+ MIT License, see [LICENSE](LICENSE).
252
+
253
+ - Copyright (c) 2022 Arnes (original netbox-inventory code)
254
+ - Copyright (c) 2026 Maksym Ototiuk (changes in this fork)
255
+
256
+ You may use, copy, modify and distribute this software for any purpose. It is
257
+ provided "as is", without warranty of any kind, and the authors are not liable
258
+ for any damage caused by its use.
@@ -0,0 +1,235 @@
1
+ # NetBox Assets
2
+
3
+ A [NetBox](https://github.com/netbox-community/netbox) plugin for simple asset
4
+ tracking: keep a record of hardware (devices, modules and racks) that is **not
5
+ currently installed**, for example spare parts and equipment in storage.
6
+
7
+ > **This project is a stripped-down fork of
8
+ > [netbox-inventory](https://github.com/ArnesSI/netbox-inventory)** by Arnes.
9
+ > It is based on upstream commit
10
+ > [`e749f6f`](https://github.com/ArnesSI/netbox-inventory/commit/e749f6fd0aa2494746218537deb5c8727a0fe04a)
11
+ > (v2.7.0). All credit for the original design and code goes to the upstream
12
+ > authors. If you need the full feature set (inventory item types and groups,
13
+ > suppliers, purchases, deliveries, warranty tracking, audit flows), use the
14
+ > original plugin.
15
+
16
+ ## Purpose
17
+
18
+ NetBox documents what is installed in your network. netbox-assets adds a
19
+ place for hardware that is not installed yet, or not any more: what it is,
20
+ its serial number and asset tag, and where it is stored. When an asset is
21
+ installed, you link it to the device, module or rack that represents it in
22
+ NetBox.
23
+
24
+ The goal is simple record keeping, not full inventory management.
25
+
26
+ ## Differences from netbox-inventory
27
+
28
+ | Feature | netbox-inventory | netbox-assets |
29
+ | --------------------------------- | ----------------------------- | ------------------------------------------------ |
30
+ | Assets | Yes | Yes |
31
+ | Asset roles (hierarchical) | Yes (django-mptt) | Yes (PostgreSQL `ltree`, native to NetBox 4.7) |
32
+ | Asset kinds: device, module, rack | Yes | Yes |
33
+ | Asset kind: inventory item | Yes | Removed (inventory items are deprecated in NetBox since v4.3) |
34
+ | Inventory item types and groups | Yes | Removed |
35
+ | Suppliers, purchases, deliveries | Yes | Removed |
36
+ | Warranty tracking | Yes | Removed |
37
+ | Audit flows and audit trails | Yes | Removed |
38
+ | Navigation menu | "Inventory" (configurable) | Always a top-level "Assets" menu |
39
+
40
+ ## Limitations
41
+
42
+ - **Cannot be installed together with netbox-inventory.** Both plugins define
43
+ the same relations on NetBox core models (for example
44
+ `Device.assigned_asset`) and the same GraphQL type names. netbox-assets
45
+ refuses to start if `netbox_inventory` is also enabled. This is a
46
+ deliberate simplification.
47
+ - **No data migration from netbox-inventory.** netbox-assets is meant for a
48
+ clean installation. It ships its own fresh database migrations and does not
49
+ read or convert netbox-inventory data.
50
+
51
+ ## Compatibility
52
+
53
+ | NetBox | netbox-assets |
54
+ | ---------------- | ------------- |
55
+ | 4.7.1 and later | 0.1.x |
56
+
57
+ NetBox 4.7 requires Python 3.12 or later, PostgreSQL 15 or later with the
58
+ `ltree` extension, and Redis 6 or later.
59
+
60
+ NetBox 4.7.0 is not supported: the database triggers that maintain
61
+ hierarchical paths could not be restored from a database dump in that release
62
+ ([netbox#23130](https://github.com/netbox-community/netbox/issues/23130)).
63
+
64
+ ## Features
65
+
66
+ - Assets with name, asset tag, serial number, status, role, description,
67
+ comments, tags, custom fields and images.
68
+ - Each asset has exactly one hardware type: a device type, a module type or a
69
+ rack type.
70
+ - Assign an asset to a device, module or rack, reassign it or unassign it.
71
+ - Create a new device, module or rack directly from an asset.
72
+ - Storage location, tenant, owning tenant and contact for each asset.
73
+ - Automatic status: `stored` when an asset is unassigned, `used` when it is
74
+ assigned (configurable).
75
+ - Optional synchronization of serial number and asset tag between an asset and
76
+ the hardware it is assigned to.
77
+ - Bulk add with an asset tag pattern, for example `ASSET-[001-010]`.
78
+ - Bulk import, export, edit and delete.
79
+ - Hierarchical asset roles (for example Optics → SFP) with cumulative asset
80
+ counts.
81
+ - Asset information on Device, Module and Rack pages, and asset counts on
82
+ Site, Location, Rack, Tenant, Contact and Manufacturer pages.
83
+ - Global search, REST API and GraphQL API.
84
+
85
+ ## Usage
86
+
87
+ 1. **Create an asset.** In *Assets → Assets*, click *Add* and choose the
88
+ hardware type (a device type, module type or rack type). Fill in the serial
89
+ number, asset tag, storage location and so on. This form describes *what*
90
+ the hardware is. It does not link the asset to a particular device.
91
+ 2. **Assign the asset to hardware.** Use one of these buttons:
92
+ - *Edit Assignment* in the *Assigned To* panel on the asset page;
93
+ - *Edit Assignment* in the *Asset* panel on a device, module or rack page;
94
+ - *Create Device* (or *Create Module*, *Create Rack*) on the asset page, to
95
+ create the hardware and assign the asset in one step.
96
+
97
+ When an asset is assigned, its status changes to `used`. When it is
98
+ unassigned, its status changes to `stored` (see [Settings](#settings)).
99
+
100
+ Assets are displayed as `<manufacturer> <model> <name>`, for example
101
+ `Cisco ASR edge-01`, or as `<manufacturer> <model>` when the asset has no
102
+ name. Unnamed assets of the same model look the same in lists and selection
103
+ fields, so give assets a name if you need to tell them apart.
104
+
105
+ ## Installation
106
+
107
+ Activate the NetBox virtual environment and install the package:
108
+
109
+ ```shell
110
+ source /opt/netbox/venv/bin/activate
111
+ pip install netbox-assets
112
+ ```
113
+
114
+ To keep the plugin installed after NetBox upgrades, add it to
115
+ `local_requirements.txt`:
116
+
117
+ ```shell
118
+ echo netbox-assets >> /opt/netbox/local_requirements.txt
119
+ ```
120
+
121
+ Enable the plugin in `/opt/netbox/netbox/netbox/configuration.py`:
122
+
123
+ ```python
124
+ PLUGINS = [
125
+ 'netbox_assets',
126
+ ]
127
+
128
+ PLUGINS_CONFIG = {
129
+ 'netbox_assets': {},
130
+ }
131
+ ```
132
+
133
+ Apply the database migrations, update the search index and restart NetBox:
134
+
135
+ ```shell
136
+ cd /opt/netbox/netbox
137
+ python3 manage.py migrate netbox_assets
138
+ python3 manage.py reindex --lazy
139
+ sudo systemctl restart netbox netbox-rq
140
+ ```
141
+
142
+ ## Settings
143
+
144
+ Override the defaults in `PLUGINS_CONFIG`:
145
+
146
+ ```python
147
+ PLUGINS_CONFIG = {
148
+ 'netbox_assets': {
149
+ 'used_status_name': 'used',
150
+ 'stored_status_name': 'stored',
151
+ 'sync_hardware_serial_asset_tag': True,
152
+ },
153
+ }
154
+ ```
155
+
156
+ | Setting | Default | Description |
157
+ | ------------------------------------ | --------------- | ----------- |
158
+ | `used_status_name` | `'used'` | Status set when an asset is assigned to a device, module or rack. |
159
+ | `used_additional_status_names` | `[]` | Other statuses that also mean "in use". |
160
+ | `stored_status_name` | `'stored'` | Status set when an asset is unassigned. |
161
+ | `stored_additional_status_names` | `['retired']` | Other statuses that also mean "not in use". |
162
+ | `sync_hardware_serial_asset_tag` | `False` | Keep serial number and asset tag of the assigned device, module or rack in sync with the asset. The device type, module type or rack type is updated as well. |
163
+ | `asset_import_create_device_type` | `False` | When importing assets, create a missing manufacturer and device type. |
164
+ | `asset_import_create_module_type` | `False` | When importing assets, create a missing manufacturer and module type. |
165
+ | `asset_import_create_rack_type` | `False` | When importing assets, create a missing manufacturer and rack type. |
166
+ | `asset_import_create_tenant` | `False` | When importing assets, create a missing tenant (for the tenant and owning tenant fields). |
167
+ | `asset_custom_fields_search_filters` | `{}` | Custom fields and lookups to add to the asset search filters, for example `{'asset_mac': ['icontains', 'exact']}`. |
168
+
169
+ To disable automatic status changes, set both `used_status_name` and
170
+ `stored_status_name` to `None`.
171
+
172
+ ### Asset statuses
173
+
174
+ The default statuses are `stored`, `used` and `retired`. You can add your own
175
+ with the NetBox
176
+ [`FIELD_CHOICES`](https://netboxlabs.com/docs/netbox/configuration/data-validation/#field_choices)
177
+ setting:
178
+
179
+ ```python
180
+ FIELD_CHOICES = {
181
+ 'netbox_assets.Asset.status+': (
182
+ ('repair', 'In repair', 'orange'),
183
+ ),
184
+ }
185
+ ```
186
+
187
+ If you add statuses, also review `used_additional_status_names` and
188
+ `stored_additional_status_names`.
189
+
190
+ ## REST API and GraphQL
191
+
192
+ REST API endpoints:
193
+
194
+ | Endpoint | Description |
195
+ | --------------------------------------- | ----------- |
196
+ | `/api/plugins/assets/assets/` | Assets |
197
+ | `/api/plugins/assets/asset-roles/` | Asset roles |
198
+ | `/api/plugins/assets/dcim/devices/` | NetBox devices with an extra `has_asset_assigned` filter |
199
+ | `/api/plugins/assets/dcim/modules/` | NetBox modules with an extra `has_asset_assigned` filter |
200
+
201
+ GraphQL queries: `asset`, `asset_list`, `asset_role`, `asset_role_list`.
202
+
203
+ ## Development
204
+
205
+ The tests use the NetBox test framework. They need a NetBox 4.7 installation
206
+ with PostgreSQL and Redis, and a database user that is allowed to create the
207
+ test database. Install the plugin into the NetBox virtual environment in
208
+ editable mode (`pip install -e .`) and run:
209
+
210
+ ```shell
211
+ cd /opt/netbox/netbox
212
+ python3 manage.py test netbox_assets.tests --keepdb --parallel 4
213
+ ```
214
+
215
+ NetBox compares the number of database queries of list views with
216
+ `netbox_assets/tests/query_counts.json`. If you change a list view or an API
217
+ serializer on purpose, update the file (this does not work with `--parallel`):
218
+
219
+ ```shell
220
+ UPDATE_QUERY_COUNTS=1 python3 manage.py test netbox_assets.tests --keepdb
221
+ ```
222
+
223
+ GitHub Actions run `ruff` and the test suite against NetBox 4.7.1 and 4.7.2
224
+ on every push and pull request.
225
+
226
+ ## License
227
+
228
+ MIT License, see [LICENSE](LICENSE).
229
+
230
+ - Copyright (c) 2022 Arnes (original netbox-inventory code)
231
+ - Copyright (c) 2026 Maksym Ototiuk (changes in this fork)
232
+
233
+ You may use, copy, modify and distribute this software for any purpose. It is
234
+ provided "as is", without warranty of any kind, and the authors are not liable
235
+ for any damage caused by its use.
@@ -0,0 +1,51 @@
1
+ from django.apps import apps
2
+ from django.core.exceptions import ImproperlyConfigured
3
+
4
+ from netbox.plugins import PluginConfig
5
+
6
+ from .version import __version__
7
+
8
+ # Plugins that cannot be enabled together with netbox-assets. They define the
9
+ # same reverse relations on NetBox core models (e.g. Device.assigned_asset) and
10
+ # the same GraphQL type names, so NetBox would fail with confusing errors.
11
+ INCOMPATIBLE_PLUGINS = ('netbox_inventory',)
12
+
13
+
14
+ class NetBoxAssetsConfig(PluginConfig):
15
+ name = 'netbox_assets'
16
+ verbose_name = 'NetBox Assets'
17
+ version = __version__
18
+ description = (
19
+ 'Simple asset tracking for NetBox. A stripped-down fork of netbox-inventory.'
20
+ )
21
+ author = 'Maksym Ototiuk'
22
+ author_email = 'pypi@masik.slmail.me'
23
+ base_url = 'assets'
24
+ min_version = '4.7.1'
25
+ default_settings = {
26
+ 'used_status_name': 'used',
27
+ 'used_additional_status_names': [],
28
+ 'stored_status_name': 'stored',
29
+ 'stored_additional_status_names': [
30
+ 'retired',
31
+ ],
32
+ 'sync_hardware_serial_asset_tag': False,
33
+ 'asset_import_create_device_type': False,
34
+ 'asset_import_create_module_type': False,
35
+ 'asset_import_create_rack_type': False,
36
+ 'asset_import_create_tenant': False,
37
+ 'asset_custom_fields_search_filters': {},
38
+ }
39
+
40
+ def ready(self):
41
+ conflicts = [name for name in INCOMPATIBLE_PLUGINS if apps.is_installed(name)]
42
+ if conflicts:
43
+ raise ImproperlyConfigured(
44
+ f'netbox_assets cannot be enabled together with: {", ".join(conflicts)}. '
45
+ f'Remove one of the plugins from PLUGINS in configuration.py.'
46
+ )
47
+ super().ready()
48
+ from . import signals # noqa: F401
49
+
50
+
51
+ config = NetBoxAssetsConfig
File without changes
@@ -0,0 +1 @@
1
+ from .serializers_.assets import *