Netbox plugin for module swapping.
Project description
Module Swap
Module Swap is a plugin for NetBox that allows easy swapping of Modules between Devices, linking of Modules and InventoryItems and makes sure that linked Modules and InventoryItems have synchronized data.
Features
- Easy Module swapping: Swapping Modules between Devices made easy with just a few clicks and keeping module history.
- One-to-One Binding: Establish a unique relationship between a module and an inventory item.
- CRUD Operations: Create, read, update, and delete bindings between modules and inventory items.
- Safe Deletion: Deletes associated inventory items when a module is deleted.
- Integration with NetBox UI: Seamlessly integrates into NetBox's main menu for easy access to binding functionalities.
Requirements
These are the versions of NetBox and Python that I used when developing my plugin. I highly recommend using this version of NetBox since i don't know if they changed anything in newer versions that could break the plugin.
- NetBox NetBox Community
v4.1.6(2024-10-31). - Python version
3.10.12or higher.
Installation
Plugin is available on PYPI so you can install it easily with pip.
Step 1: Install using pip
pip install module_swap
Step 2: Add the plugin into PLUGINS array in configuration.py
PLUGINS = [
'module_swap',
# Other plugins...
]
Step 3: Apply migrations(don't forget activating virtual enviroment)
python manage.py migrate module_swap
Step 4: Run netbox(for example)
python manage.py runserver
Usage
✉️ Transfer a module between devices
- Open the module detail page
- Click the "Transfer module" button
- Select the target device and module bay
or
- From the plugin navigation, open "Module Swap"
- Select the target device and module bay
- Done
The transfer:
- automatically removes the module from the original device,
- reassigns it to the target device,
- updates the associated Inventory Item if linked.
⚙️ Linking with Inventory Item
- From the plugin navigation, open "Inventory item and module links"
- Create a new link between a Module and an InventoryItem
- When the module is transferred, the InventoryItem device will update automatically
Project Structure
module_swap/
├── models.py # Link model definition
├── views.py # Transfer and linking logic
├── forms.py # User forms
├── templates/ # HTML templates
├── urls.py # Plugin URLs
├── navigation.py # Plugin menu entries
└── migrations/ # DB migrations
Changelog
v1.2.1
- Added headers into each file
v1.2
- Added Inventory Item ↔ Module linking
- Automatic Inventory Item updates on module movement
- Removed debugging code parts, added comments in code, cleanup
- Added complete README
v1.1
- Added templates to the PYPI project (forgot about it in v1.0)
v1.0
- Initial implementation of module swapping logic and templates
Notes
-
The plugin does not override NetBox core behavior (only extends it)
- This means, that i didn't do any sort of changes to the core code - would it be logic or appearence since this would be against the logic of using plugins - if you want to do sort of edits to the application core do it on your own NetBox instance
-
When linking Module and InventoryItem, the InventoryItem Device gets updated to the Device that is linked with the Module - this made sense to me since when you create InventoryItem it requires Device and we shouldn't keep a different device in the InventoryItem other than the one that is linked with the Module - hope this makes sense :)
-
If you wish to add some sort of buttons for accessing plugin you can do it a couple of ways
- you can edit the core of NetBox app - edit html template file you want the button on
- you can use the Custom Links function in NetBox under the customization section
- you can try to override html template - i tried but it didn't work - maybe i did something wrong
-
As i said earlier this is a PLUGIN - it should be adding new functionality, not poke in core thing hence i strogly recommend using the stuff i created because when you will edit the core app you will probably have to do it everytime you upgrade NetBox - only Custom Links should stay since i think they are saved as a DB object so as long as you keep your DB you should be good
-
Supports changelog history (Journal + changelog tabs)
Author
Viktor Kubec
BUT FIT Brno student
MIT License
GitHub: vubeckubec/Module_Swap
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file module_swap-1.2.1.tar.gz.
File metadata
- Download URL: module_swap-1.2.1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daf62c77c520582342f00ee925a84808cc63655ecfd46f8fd6335a231d72b2e2
|
|
| MD5 |
43261cf22a6797ae7f11077470ad3f2c
|
|
| BLAKE2b-256 |
8b758bd9cd1e656ae1c668c9050f9e2934f6253793b1eda9347eefabfa6aaa85
|
File details
Details for the file module_swap-1.2.1-py3-none-any.whl.
File metadata
- Download URL: module_swap-1.2.1-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdb633e5fb8a9dfff87b8fa7fc605fc2a4bdab7deacdda22a0c7fe0d717a5627
|
|
| MD5 |
a56dd7f5a076f3ef16cec12e35026569
|
|
| BLAKE2b-256 |
8054318c724d261ddbc35d147b483074856f42ef5b746834b88ecd819cd9a6c1
|