diff --git a/README.md b/README.md index 8989a24..ea4b79a 100644 --- a/README.md +++ b/README.md @@ -1,53 +1,121 @@ # NetBox Site Prefix -Plugin für NetBox 4.6.5, das in den Geräte- und Rack-Listen eine Spalte -**Prefix** als erste Datenspalte anzeigt. Der Wert ist immer das erste Wort -des zugewiesenen Standortnamens (`Site.name`). +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`). -Beispiele: - -| Standort | Prefix | +| | | |---|---| -| `Berlin Campus West` | `Berlin` | -| `DC01 Frankfurt` | `DC01` | -| kein Standort | `—` | +| **Plugin name** | `netbox_site_prefix` | +| **Package** | `netbox-site-prefix` | +| **NetBox** | `4.6.5` – `4.7.x` | +| **Python** | `>=3.12` | +| **Repository** | | -Das Plugin benötigt keine Datenbankmigration und speichert keine eigenen -Daten. +## Screenshots + +Device list with the site prefix as the first column: + +![Device list with prefix column](docs/screenshots/devices.png) + +## 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 -Im Python-Virtualenv von NetBox installieren: +All paths assume a standard installation under `/opt/netbox`. -```shell -/opt/netbox/venv/bin/pip install git+https://git.mrblake.cc/MrBlake/Netbox-Prefixes.git +### 1. Install the package + +```bash +/opt/netbox/venv/bin/pip install --upgrade --force-reinstall \ + "git+https://git.mrblake.cc/MrBlake/Netbox-Prefixes.git@main" ``` -In Local Requirements aufnehmen: -```shell -echo "git+https://git.mrblake.cc/MrBlake/Netbox-Prefixes.git" >> /opt/netbox/local_requirements.txt +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 ``` -Danach in `configuration.py` aktivieren: +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 = [ - # weitere Plugins ... "netbox_site_prefix", ] ``` -Anschließend NetBox neu starten. `upgrade.sh` ist nicht erforderlich, kann -aber wie bei anderen Plugin-Installationen ausgeführt werden. +If other plugins are already configured, add `netbox_site_prefix` to the +existing list instead of replacing it. -Bei bestehenden Benutzern kann eine bereits gespeicherte persönliche -Spaltenauswahl Vorrang vor den Standardspalten haben. In diesem Fall in der -Geräte- bzw. Rack-Liste **Spalten konfigurieren** öffnen, **Prefix** auswählen -und an die erste Position schieben oder die gespeicherte Tabellenkonfiguration -zurücksetzen. +### 4. Restart -## Kompatibilität +The plugin has no database models, so no migration is required. -- NetBox: 4.6.5 bis einschließlich 4.6.x -- Python: ab 3.12 +```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. diff --git a/docs/screenshots/devices.png b/docs/screenshots/devices.png new file mode 100644 index 0000000..d4ad10d Binary files /dev/null and b/docs/screenshots/devices.png differ