Skip to content

Commit 66415ab

Browse files
committed
Merge branch 'docs' into 'main'
Docs See merge request 701/netbox/cesnet_service_path_plugin!34
2 parents 0380e25 + f740655 commit 66415ab

File tree

1 file changed

+198
-42
lines changed

1 file changed

+198
-42
lines changed

README.md

Lines changed: 198 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1-
# 🚨 WARNING – Work in Progress! 🚨
2-
3-
⚠️ This plugin is **under heavy development** and is **NOT production-ready**.
4-
- Database changes that are required for the current implementation are **missing**.
5-
- Documentation of the data model and functionality is **incomplete**.
6-
- Expect breaking changes, unfinished features, and possible instability.
7-
8-
Use this code **at your own risk** and only for testing or development purposes.
9-
10-
---
111
# CESNET ServicePath Plugin for NetBox
122

133
A NetBox plugin for managing service paths and segments in network infrastructure with advanced geographic path visualization.
144

155
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
6+
[![PyPI version](https://img.shields.io/pypi/v/cesnet-service-path-plugin.svg)](https://pypi.org/project/cesnet-service-path-plugin/)
7+
[![Python versions](https://img.shields.io/pypi/pyversions/cesnet-service-path-plugin.svg)](https://pypi.org/project/cesnet-service-path-plugin/)
8+
[![NetBox compatibility](https://img.shields.io/badge/NetBox-4.2%20|%204.3%20|%204.4-blue.svg)](https://github.com/netbox-community/netbox)
9+
10+
## 📑 Table of Contents
11+
12+
- [Overview](#overview)
13+
- [Compatibility Matrix](#compatibility-matrix)
14+
- [Features](#features)
15+
- [Data Model](#data-model)
16+
- [Installation and Configuration](#installation-and-configuration)
17+
- [Prerequisites](#prerequisites)
18+
- [Step-by-Step Installation](#step-1-enable-postgis-in-postgresql)
19+
- [Additional Configuration](#additional-configuration)
20+
- [Custom Status Choices](#custom-status-choices)
21+
- [Custom Kind Choices](#custom-kind-choices)
22+
- [Geographic Path Data](#geographic-path-data)
23+
- [API Usage](#api-usage)
24+
- [Development](#development)
25+
- [Navigation and UI](#navigation-and-ui)
26+
- [Troubleshooting](#troubleshooting)
27+
- [Credits](#credits)
28+
- [License](#license)
1629

1730
## Overview
1831

@@ -90,67 +103,207 @@ The CESNET ServicePath Plugin extends NetBox's capabilities by providing compreh
90103
- **Length calculation** using projected coordinates
91104
- **Source format tracking** (KML, KMZ, GeoJSON, manual)
92105

93-
## Quick Start
106+
## Installation and Configuration
107+
108+
⚠️ **Important**: This plugin requires PostGIS and geographic libraries. Standard NetBox installations need additional setup steps.
109+
110+
### Prerequisites
111+
112+
Before installing the plugin, ensure you have:
113+
114+
1. **PostgreSQL with PostGIS extension** (version 3.0 or higher recommended)
115+
2. **System libraries**: GDAL, GEOS, and PROJ runtime binaries
116+
3. **NetBox 4.2 or higher**
117+
118+
#### Installing System Dependencies
119+
120+
**Ubuntu/Debian:**
121+
```bash
122+
sudo apt-get update
123+
sudo apt-get install postgresql-15-postgis-3 gdal-bin libgdal34 libgeos-c1t64 libproj25
124+
```
125+
126+
**Note**: Package names may vary by Ubuntu/Debian version. Use `apt-cache search libgdal` to find the correct version for your system.
127+
128+
**macOS:**
129+
```bash
130+
brew install postgresql postgis gdal geos proj
131+
```
132+
133+
**Docker users**: The official `netboxcommunity/netbox` images do **NOT** include PostGIS and GDAL libraries by default. You will need to create a custom Docker image. See the Docker-specific instructions below.
134+
135+
### Step 1: Enable PostGIS in PostgreSQL
136+
137+
Connect to your NetBox database and enable the PostGIS extension:
138+
139+
```sql
140+
-- Connect to your NetBox database
141+
\c netbox
142+
143+
-- Enable PostGIS extension
144+
CREATE EXTENSION IF NOT EXISTS postgis;
145+
146+
-- Verify installation
147+
SELECT PostGIS_version();
148+
```
149+
150+
### Step 2: Configure NetBox Database Engine
151+
152+
**CRITICAL**: Update your NetBox `configuration.py` to use the PostGIS database engine:
153+
154+
```python
155+
# Set the database engine to PostGIS
156+
DATABASE_ENGINE = "django.contrib.gis.db.backends.postgis"
157+
158+
# PostgreSQL database configuration
159+
DATABASE = {
160+
"ENGINE": DATABASE_ENGINE, # Must use PostGIS engine
161+
"NAME": environ.get("DB_NAME", "netbox"),
162+
"USER": environ.get("DB_USER", ""),
163+
"PASSWORD": read_secret("db_password", environ.get("DB_PASSWORD", "")),
164+
"HOST": environ.get("DB_HOST", "localhost"),
165+
"PORT": environ.get("DB_PORT", ""),
166+
"OPTIONS": {"sslmode": environ.get("DB_SSLMODE", "prefer")},
167+
"CONN_MAX_AGE": int(environ.get("DB_CONN_MAX_AGE", "300")),
168+
}
169+
```
170+
171+
**Note**: This is just an example. If you're using NetBox Docker, this can be configured via environment variables in your `docker-compose.yml` or similar configuration files.
172+
173+
### Step 3: Install the Plugin
174+
175+
#### Standard Installation (pip)
94176

95-
1. Install the plugin:
96177
```bash
97178
pip install cesnet_service_path_plugin
98179
```
99180

100-
2. Enable the plugin in your NetBox configuration:
181+
#### Docker Installation
182+
183+
The official NetBox Docker images do not include the required geographic libraries. You need to create a custom Docker image.
184+
185+
**Option 1: Create a Custom Dockerfile**
186+
187+
Create a `Dockerfile` extending the official NetBox image:
188+
189+
```dockerfile
190+
FROM netboxcommunity/netbox:v4.4
191+
192+
# copy plugin requirements
193+
COPY ./plugin_requirements.txt /opt/netbox/
194+
195+
# Install git and minimal PostGIS runtime dependencies
196+
RUN apt-get update && apt-get install -y \
197+
git \
198+
gdal-bin \
199+
libgdal34 \
200+
libgeos-c1t64 \
201+
libproj25 \
202+
&& apt-get clean \
203+
&& rm -rf /var/lib/apt/lists/*
204+
205+
# Install PostGIS and geospatial Python dependencies
206+
RUN /usr/local/bin/uv pip install \
207+
psycopg2-binary \
208+
-r /opt/netbox/plugin_requirements.txt
209+
```
210+
211+
**Note**: Library package names (like `libgdal34`) may vary depending on the base image's Ubuntu/Debian version. Check available packages if you encounter errors.
212+
213+
Then create a `plugin_requirements.txt` file:
214+
```
215+
cesnet_service_path_plugin
216+
```
217+
218+
Build your custom image:
219+
```bash
220+
docker build -t netbox-with-gis:latest .
221+
```
222+
223+
Update your `docker-compose.yml` to use the custom image:
224+
```yaml
225+
services:
226+
netbox:
227+
image: netbox-with-gis:latest
228+
# ... rest of your configuration
229+
```
230+
231+
**Option 2: Use docker-compose override**
232+
233+
Add a `docker-compose.override.yml` file:
234+
235+
```yaml
236+
version: '3.8'
237+
services:
238+
netbox:
239+
build:
240+
context: .
241+
dockerfile: Dockerfile.custom
242+
```
243+
244+
For detailed Docker setup instructions, see [using netbox-docker with plugins](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins).
245+
246+
### Step 4: Enable the Plugin
247+
248+
Add the plugin to your NetBox `configuration.py`:
249+
101250
```python
102251
PLUGINS = [
103-
'cesnet_service_path_plugin'
252+
'cesnet_service_path_plugin',
104253
]
105254
106255
PLUGINS_CONFIG = {
107256
"cesnet_service_path_plugin": {},
108257
}
109258
```
110259

111-
3. Run NetBox migrations:
260+
### Step 5: Run Database Migrations
261+
262+
Apply the plugin's database migrations:
263+
112264
```bash
113-
python manage.py migrate
265+
cd /opt/netbox/netbox
266+
source venv/bin/activate
267+
python manage.py migrate cesnet_service_path_plugin
114268
```
115269

116-
4. **Configure GeoDjango** (required for geographic features):
117-
- Install GDAL, GEOS, and PROJ libraries
118-
- Configure PostGIS extension in PostgreSQL
119-
- See [GeoDjango installation guide](https://docs.djangoproject.com/en/stable/ref/contrib/gis/install/)
120-
121-
## Installation
270+
**Docker users:**
271+
```bash
272+
docker exec -it netbox python /opt/netbox/netbox/manage.py migrate cesnet_service_path_plugin
273+
```
122274

123-
### Prerequisites
275+
### Step 6: Restart NetBox
124276

125-
For geographic features, you need:
126-
- **PostGIS-enabled PostgreSQL database**
127-
- **GDAL, GEOS, and PROJ libraries**
128-
- **Python packages**: `geopandas`, `fiona`, `shapely`
277+
Restart your NetBox services to load the plugin:
129278

130-
### Using pip
131279
```bash
132-
pip install cesnet_service_path_plugin
280+
sudo systemctl restart netbox netbox-rq
133281
```
134282

135-
### Using Docker
136-
For NetBox Docker installations, add to your `plugin_requirements.txt`:
283+
**Docker users:**
137284
```bash
138-
cesnet_service_path_plugin
285+
docker-compose restart netbox netbox-worker
139286
```
140287

141-
**Docker users**: Ensure your NetBox Docker image includes PostGIS and GDAL libraries.
288+
### Verification
142289

143-
For detailed Docker setup instructions, see [using netbox-docker with plugins](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins).
290+
To verify the installation:
144291

145-
## Configuration
292+
1. Log into NetBox
293+
2. Check that "Service Paths" appears in the navigation menu
294+
3. Navigate to **Service Paths → Segments** to confirm the plugin is working
146295

147-
### Database Configuration
296+
For geographic feature verification, you can use the diagnostic function in the Django shell:
148297

149-
Ensure your NetBox database has PostGIS enabled:
150-
```sql
151-
CREATE EXTENSION IF NOT EXISTS postgis;
298+
```python
299+
python manage.py nbshell
300+
301+
from cesnet_service_path_plugin.utils import check_gis_environment
302+
check_gis_environment()
152303
```
153304

305+
## Additional Configuration
306+
154307
### Custom Status Choices
155308

156309
Extend or override default status choices in your `configuration.py`:
@@ -272,8 +425,8 @@ pip install -e ".[dev]"
272425

273426
4. Install geographic dependencies:
274427
```bash
275-
# Ubuntu/Debian
276-
sudo apt-get install gdal-bin libgdal-dev libgeos-dev libproj-dev
428+
# Ubuntu/Debian - only runtime libraries needed
429+
sudo apt-get install gdal-bin libgdal34 libgeos-c1t64 libproj25
277430
278431
# macOS
279432
brew install gdal geos proj
@@ -282,6 +435,8 @@ brew install gdal geos proj
282435
pip install geopandas fiona shapely
283436
```
284437

438+
**Note**: For development, you typically only need the runtime libraries. The Python packages (geopandas, fiona, shapely) use precompiled wheels that already include the necessary bindings. Development headers (`-dev` packages) are only needed if you're compiling these libraries from source.
439+
285440
### Testing Geographic Features
286441

287442
Use the built-in diagnostic function:
@@ -311,9 +466,10 @@ Automatic integration with existing NetBox models:
311466
### Common Issues
312467

313468
1. **PostGIS not enabled**: Ensure PostGIS extension is installed in your database
314-
2. **GDAL library missing**: Install system GDAL libraries before Python packages
469+
2. **GDAL library missing**: Install system GDAL runtime libraries (`gdal-bin`, `libgdal34`) before Python packages
315470
3. **Path upload fails**: Check file format and ensure it contains LineString geometries
316471
4. **Map not loading**: Verify JavaScript console for tile layer errors
472+
5. **Library version mismatch**: If you encounter errors about missing libraries, check that library package names match your OS version (e.g., `libgdal34` vs `libgdal32`)
317473

318474
### Debug Mode
319475

0 commit comments

Comments
 (0)