Archived
122 lines
3.2 KiB
Markdown
122 lines
3.2 KiB
Markdown
# NetBox Site Prefix
|
||
|
||
Adds a **Prefix** column as the first data column of the NetBox device and rack
|
||
lists. The value is always the first word of the assigned site name
|
||
(`Site.name`).
|
||
|
||
| | |
|
||
|---|---|
|
||
| **Plugin name** | `netbox_site_prefix` |
|
||
| **Package** | `netbox-site-prefix` |
|
||
| **NetBox** | `4.6.5` – `4.7.x` |
|
||
| **Python** | `>=3.12` |
|
||
| **Repository** | <https://git.mrblake.cc/MrBlake/Netbox-Prefixes> |
|
||
|
||
## Screenshots
|
||
|
||
Device list with the site prefix as the first column:
|
||
|
||

|
||
|
||
## Features
|
||
|
||
- **Prefix** column in the device and rack lists, derived from the site name:
|
||
|
||
| Site | Prefix |
|
||
|---|---|
|
||
| `Berlin Campus West` | `Berlin` |
|
||
| `DC01 Frankfurt` | `DC01` |
|
||
| no site | `—` |
|
||
|
||
- No database models, no migrations, no stored data.
|
||
|
||
## Compatibility
|
||
|
||
- NetBox `4.6.5` – `4.7.x`
|
||
- Python `>=3.12`
|
||
- Not to be installed together with
|
||
[Netbox-Utilities](https://git.mrblake.cc/MrBlake/Netbox-Utilities), which
|
||
includes the same column and supersedes this plugin. Both register a
|
||
`site_prefix` column, so NetBox refuses to start with both enabled.
|
||
|
||
## Installation
|
||
|
||
All paths assume a standard installation under `/opt/netbox`.
|
||
|
||
### 1. Install the package
|
||
|
||
```bash
|
||
/opt/netbox/venv/bin/pip install --upgrade --force-reinstall \
|
||
"git+https://git.mrblake.cc/MrBlake/Netbox-Prefixes.git@main"
|
||
```
|
||
|
||
For reproducible production installs, replace `main` with a release tag or a
|
||
full commit ID.
|
||
|
||
### 2. Add the plugin to `local_requirements.txt`
|
||
|
||
This makes `upgrade.sh` reinstall the plugin automatically on every NetBox upgrade:
|
||
|
||
```bash
|
||
grep -qxF "git+https://git.mrblake.cc/MrBlake/Netbox-Prefixes.git@main" /opt/netbox/local_requirements.txt \
|
||
|| echo "git+https://git.mrblake.cc/MrBlake/Netbox-Prefixes.git@main" | sudo tee -a /opt/netbox/local_requirements.txt
|
||
```
|
||
|
||
If the repository is private, the NetBox server needs a read-only deploy token
|
||
or an SSH key. Do not store credentials in `local_requirements.txt`.
|
||
|
||
### 3. Enable the plugin
|
||
|
||
In `/opt/netbox/netbox/netbox/configuration.py`:
|
||
|
||
```python
|
||
PLUGINS = [
|
||
"netbox_site_prefix",
|
||
]
|
||
```
|
||
|
||
If other plugins are already configured, add `netbox_site_prefix` to the
|
||
existing list instead of replacing it.
|
||
|
||
### 4. Restart
|
||
|
||
The plugin has no database models, so no migration is required.
|
||
|
||
```bash
|
||
sudo systemctl restart netbox netbox-rq
|
||
```
|
||
|
||
## Update
|
||
|
||
```bash
|
||
/opt/netbox/venv/bin/pip install --upgrade --force-reinstall \
|
||
"git+https://git.mrblake.cc/MrBlake/Netbox-Prefixes.git@main"
|
||
sudo systemctl restart netbox netbox-rq
|
||
```
|
||
|
||
When NetBox itself is upgraded, `upgrade.sh` reinstalls the plugin from
|
||
`local_requirements.txt`:
|
||
|
||
```bash
|
||
sudo /opt/netbox/upgrade.sh
|
||
sudo systemctl restart netbox netbox-rq
|
||
```
|
||
|
||
## Uninstall
|
||
|
||
1. Remove `"netbox_site_prefix"` from `PLUGINS`.
|
||
2. Remove the line from `/opt/netbox/local_requirements.txt`.
|
||
3. Uninstall the package and restart NetBox:
|
||
|
||
```bash
|
||
/opt/netbox/venv/bin/pip uninstall netbox-site-prefix
|
||
sudo systemctl restart netbox netbox-rq
|
||
```
|
||
|
||
## Usage
|
||
|
||
The column is part of the default columns. Users with a saved personal column
|
||
selection may not see it: open **Configure Table** in the device or rack list,
|
||
select **Prefix** and move it to the first position, or reset the saved table
|
||
configuration.
|