Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
afe96f5
Test: Update CI workflow to align with NetBox plugin testing patterns
bonzo81 Jan 23, 2026
6920679
Fix: Exclude tests from package, use editable install in CI
bonzo81 Jan 23, 2026
ed5d47f
CI: Strict lint/format on all pushes, tests only on develop/master
bonzo81 Jan 23, 2026
15e6ed0
Merge pull request #208 from bonzo81/test/ci-workflow
bonzo81 Jan 26, 2026
ba86827
Add SNMPv1 support to LibreNMS add device form
bonzo81 Jan 26, 2026
1480d3a
refactor(devices): simplify SNMP version retrieval logic
bonzo81 Jan 26, 2026
7b81f07
Merge pull request #209 from bonzo81/feature/snmpv1-support
bonzo81 Jan 26, 2026
afcdd0e
Format: Fix trailing whitespace and end-of-file issues
bonzo81 Jan 26, 2026
249fad6
ci(lint-format): update Ruff commands for better output
bonzo81 Jan 26, 2026
9b165e4
feat: add two-tier permission system with plugin and object-level acc…
bonzo81 Feb 5, 2026
5774f77
chore: update copilot instructions with permission and background job…
bonzo81 Feb 5, 2026
3128059
Enhance lint-format workflow for multiple branches
bonzo81 Feb 6, 2026
1344889
feat: devcontainer proxy/codespaces support, auto-create librenms_id …
marcinpsk Feb 15, 2026
b613d1c
Update devcontainer.json
marcinpsk Feb 15, 2026
cd7b823
Merge pull request #1 from marcinpsk/devcontainer-codespaces
marcinpsk Feb 15, 2026
5273a65
refactor(interfaces): run ruff format with versoin 0.15.1
bonzo81 Feb 16, 2026
3e3dfb0
Merge pull request #214 from bonzo81/chore/update-copilot-instructions
bonzo81 Feb 16, 2026
663e36b
refactor(interfaces): run ruff format with version 0.15.1
bonzo81 Feb 16, 2026
2509607
fix: prevent open-redirect via HTTP_REFERER in permission redirects
bonzo81 Feb 16, 2026
1f61c94
fix: add virtualchassis permission check and validate object_type
bonzo81 Feb 16, 2026
42a251d
docs: fix heading grammar, typo, and outdated troubleshooting note
bonzo81 Feb 16, 2026
aa7d15b
fix: use flash message + redirect for import permission denied
bonzo81 Feb 16, 2026
bef41ab
test: add tests for redirect validation, VC perm, and object_type
bonzo81 Feb 16, 2026
d665ea1
Merge pull request #213 from bonzo81/feature/permissions
bonzo81 Feb 16, 2026
3096419
feat: devcontainer proxy/codespaces support, auto-create librenms_id …
marcinpsk Feb 15, 2026
e97bdac
Update devcontainer.json
marcinpsk Feb 15, 2026
1b29eb4
feat: serial number matching, conflict resolution, and device sync im…
marcinpsk Feb 16, 2026
d6c9ea6
Merge branch 'master' into serial
marcinpsk Feb 16, 2026
a160e1f
fix: address code review findings across views, templates, and forms
marcinpsk Feb 16, 2026
101bb98
docs: clarify underscore-prefixed helper naming convention in utils.py
marcinpsk Feb 16, 2026
a5e9c21
fix: cables tab ignoring interface_name_field user preference
marcinpsk Feb 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .devcontainer/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@ SKIP_SUPERUSER=false
# .devcontainer/plugin-config.py.example → .devcontainer/plugin-config.py
# Advanced NetBox configuration (optional):
# .devcontainer/extra-configuration.py.example → .devcontainer/extra-configuration.py

# Proxy Configuration (optional, for corporate networks with MITM proxies)
# Uncomment and set these if you're behind a proxy
# HTTP_PROXY=http://proxy.example.com:8080
# HTTPS_PROXY=http://proxy.example.com:8080
# NO_PROXY=localhost,127.0.0.1,postgres,redis
# REQUESTS_CA_BUNDLE=/path/to/ca-bundle.crt
# SSL_CERT_FILE=/path/to/ca-bundle.crt
# CURL_CA_BUNDLE=/path/to/ca-bundle.crt

# Git SSL verification override (default: false)
# Only set to true if behind a MITM proxy and you cannot provide a CA bundle.
# Prefer placing a ca-bundle.crt in the workspace root instead.
# ALLOW_GIT_SSL_DISABLE=false
94 changes: 94 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ If you need to test with a LibreNMS instance on a private network (local lab, co
- **GitHub CLI**: Automatically configured for easy PR submission
- **Logs**: Use `netbox-logs` to debug issues in real-time


### 📡 LibreNMS Server Configuration

You need a LibreNMS instance to use this plugin. Configure your LibreNMS server(s) in `plugin-config.py`:

1. Copy the example config:

```bash
cp .devcontainer/config/plugin-config.py.example .devcontainer/config/plugin-config.py
```

2. Edit it with your LibreNMS server URL(s) and API token(s)
3. Restart NetBox: `netbox-restart`

## Out-of-the-box defaults

Below are the dev container defaults. The field name to change these defaults is listed below each line.
Expand All @@ -84,6 +98,8 @@ Below are the dev container defaults. The field name to change these defaults is
- Plugin loader: enabled; reads `.devcontainer/config/plugin-config.py` if present
- If `plugin-config.py` is missing: plugin is enabled with empty config (features won’t work until configured)



## 🔧 Configuration

### NetBox Version and Environment (use .devcontainer/.env)
Expand Down Expand Up @@ -139,6 +155,84 @@ You might experience issues with database schemas and migrations when changing N
- Database: `DB_HOST`, `DB_NAME`, `DB_USER`, `DB_PASSWORD`
- Redis: `REDIS_HOST`, `REDIS_PASSWORD`
- Superuser: `SUPERUSER_NAME`, `SUPERUSER_EMAIL`, `SUPERUSER_PASSWORD`, `SKIP_SUPERUSER`
- Proxy: `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`, `REQUESTS_CA_BUNDLE`, `SSL_CERT_FILE`, `CURL_CA_BUNDLE`

### 🌐 Proxy Configuration (MITM Proxies)

If you're behind a corporate proxy or MITM proxy (like Zscaler, BlueCoat, etc.), you need to configure the proxy at two levels: the Docker client (for building) and the container runtime (for package installation inside the container).

**Step 1: Configure Docker client proxy** (`~/.docker/config.json`)

This is **required** so that `apt-get`, `curl`, etc. work during the container image build (e.g., when installing devcontainer features like `git` and `github-cli`).

Create or edit `~/.docker/config.json`:

```json
{
"proxies": {
"default": {
"httpProxy": "http://proxy.example.com:8080",
"httpsProxy": "http://proxy.example.com:8080",
"noProxy": "localhost,127.0.0.1,postgres,redis"
}
}
}
```

Docker automatically injects these as environment variables into every `RUN` instruction during `docker build`. No VS Code restart is needed — this takes effect immediately.

> **Docker Desktop users:** You can configure the same settings via Docker Desktop Settings → Resources → Proxies, which writes this file for you.

**Step 2: Create `.devcontainer/.env`** (for container runtime)

```bash
cp .devcontainer/.env.example .devcontainer/.env
```

Add your proxy settings to `.devcontainer/.env`:

```bash
# Proxy Configuration
HTTP_PROXY=http://proxy.example.com:8080
HTTPS_PROXY=http://proxy.example.com:8080
NO_PROXY=localhost,127.0.0.1,postgres,redis

# CA Certificate Bundle (if your proxy uses a custom CA)
# Place your CA cert in the workspace, e.g., /workspaces/netbox-librenms-plugin/ca-bundle.crt
# REQUESTS_CA_BUNDLE=/workspaces/netbox-librenms-plugin/ca-bundle.crt
# SSL_CERT_FILE=/workspaces/netbox-librenms-plugin/ca-bundle.crt
# CURL_CA_BUNDLE=/workspaces/netbox-librenms-plugin/ca-bundle.crt
```

**Step 3: Add your CA certificate** (optional, only if your proxy intercepts TLS):
- Export your proxy's CA certificate (usually available from your IT department or browser)
- Save it as `ca-bundle.crt` in the root of your workspace
- Uncomment and update the `*_CA_BUNDLE` / `SSL_CERT_FILE` lines in `.env`

**Step 4: Rebuild the container**:
- VS Code: Ctrl+Shift+P → "Dev Containers: Rebuild Container"

**What gets configured:**
- `~/.docker/config.json` → proxy for Docker build steps (devcontainer features, apt in Dockerfile)
- `.devcontainer/.env` → proxy for running containers (apt, pip, curl at runtime)
- `setup.sh` auto-configures apt proxy and git SSL settings inside the container

**Important Notes:**
- The `.env` file is ignored by git, so your proxy credentials stay private
- `~/.docker/config.json` is a per-user file outside the repo
- Add internal service names to `NO_PROXY` to avoid routing internal Docker traffic through the proxy
- **Proxy authentication:** Embedding credentials directly in the proxy URL (e.g., `http://username:password@proxy.example.com:8080`) is insecure — credentials can be visible in process listings, environment dumps, `docker inspect` output, and logs. Prefer safer alternatives such as Docker's `config.json` with `credsStore` or a secret manager for storing proxy credentials securely.

**Common Issues:**

*"Could not connect to archive.ubuntu.com" during build*
- → `~/.docker/config.json` is missing or has wrong proxy URL

*"SSL certificate errors" during build*
- → Your proxy uses a MITM certificate. Export it and add it to the system trust store, or set `SSL_CERT_FILE` in `.env`

*Container builds but apt/pip fails inside*
- → .env file is missing or has wrong proxy settings. Check .env matches Docker Desktop settings


After any `.env` change, rebuild the dev container to apply environment updates.
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/config/plugin-config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ Default plugin configuration for the NetBox LibreNMS Plugin in the dev container
- Copy this file to .devcontainer/plugin-config.py
- Edit values as needed.

- Add config for all other plugins here if any.
- Add config for all other plugins here if any.
"""

# Ensure our plugin is enabled in dev (the loader sets this as a default too)
PLUGINS = [
"netbox_librenms_plugin",
]

# Sample configuration with three example servers
# Sample configuration with example servers
PLUGINS_CONFIG = {
"netbox_librenms_plugin": {
"servers": {
"production": {
"display_name": "Production LibreNMS",
"librenms_url": "https://librenms-prod.exampel.com",
"librenms_url": "https://librenms-prod.example.com",
"api_token": "your-prod-token",
"cache_timeout": 300,
"verify_ssl": True,
Expand Down
18 changes: 12 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@
"SUPERUSER_NAME": "${localEnv:SUPERUSER_NAME:admin}",
"SUPERUSER_EMAIL": "${localEnv:SUPERUSER_EMAIL:admin@example.com}",
"SUPERUSER_PASSWORD": "${localEnv:SUPERUSER_PASSWORD:admin}",
"SKIP_SUPERUSER": "${localEnv:SKIP_SUPERUSER:false}"
},
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
"SKIP_SUPERUSER": "${localEnv:SKIP_SUPERUSER:false}",
"HTTP_PROXY": "${localEnv:HTTP_PROXY}",
"HTTPS_PROXY": "${localEnv:HTTPS_PROXY}",
"http_proxy": "${localEnv:HTTP_PROXY}",
"https_proxy": "${localEnv:HTTPS_PROXY}",
"NO_PROXY": "${localEnv:NO_PROXY}",
"no_proxy": "${localEnv:NO_PROXY}",
"REQUESTS_CA_BUNDLE": "${localEnv:REQUESTS_CA_BUNDLE}",
"SSL_CERT_FILE": "${localEnv:SSL_CERT_FILE}",
"CURL_CA_BUNDLE": "${localEnv:CURL_CA_BUNDLE}"
},
"features": {},
"customizations": {
"vscode": {
"extensions": [
Expand Down Expand Up @@ -72,4 +78,4 @@
"postCreateCommand": "bash .devcontainer/scripts/setup.sh",
"postAttachCommand": "bash .devcontainer/scripts/welcome.sh",
"remoteUser": "root"
}
}
10 changes: 10 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ services:
SUPERUSER_EMAIL: ${SUPERUSER_EMAIL:-admin@example.com}
SUPERUSER_PASSWORD: ${SUPERUSER_PASSWORD:-admin}
SKIP_SUPERUSER: ${SKIP_SUPERUSER:-false}
# Proxy settings (optional)
HTTP_PROXY: ${HTTP_PROXY:-}
HTTPS_PROXY: ${HTTPS_PROXY:-}
http_proxy: ${HTTP_PROXY:-}
https_proxy: ${HTTPS_PROXY:-}
NO_PROXY: ${NO_PROXY:-}
no_proxy: ${NO_PROXY:-}
REQUESTS_CA_BUNDLE: ${REQUESTS_CA_BUNDLE:-}
SSL_CERT_FILE: ${SSL_CERT_FILE:-}
CURL_CA_BUNDLE: ${CURL_CA_BUNDLE:-}
depends_on:
postgres:
condition: service_healthy
Expand Down
5 changes: 4 additions & 1 deletion .devcontainer/scripts/load-aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ alias rq-jobs="cd /opt/netbox/netbox && source /opt/netbox/venv/bin/activate &&
alias rq-failed="cd /opt/netbox/netbox && source /opt/netbox/venv/bin/activate && python manage.py shell -c \"from django_rq import get_failed_queue; q = get_failed_queue(); print(f'Failed jobs: {len(q)}'); [print(f' {job.id[:8]}: {job.func_name}') for job in q.jobs[:10]]\""
alias rq-recent="cd /opt/netbox/netbox && source /opt/netbox/venv/bin/activate && python manage.py shell -c \"from core.models import Job; jobs = Job.objects.all().order_by('-created')[:10]; [print(f'{j.id}: {j.name[:50]} - {getattr(j.status, \\\"value\\\", j.status)} ({j.user})') for j in jobs]\""

echo "✅ Aliases loaded! Try: rq-status, rq-stats, rq-recent"
# Help
alias dev-help='echo "🎯 NetBox LibreNMS Plugin Development Commands:"; echo ""; echo "📊 NetBox Server Management:"; echo " netbox-run-bg : Start NetBox in background"; echo " netbox-run : Start NetBox in foreground (for debugging)"; echo " netbox-stop : Stop NetBox and RQ worker"; echo " netbox-restart : Restart NetBox and RQ worker"; echo " netbox-reload : Reinstall plugin and restart NetBox"; echo " netbox-status : Check if NetBox and RQ worker are running"; echo " netbox-logs : View NetBox server logs"; echo ""; echo "⚙️ Background Jobs (RQ Worker):"; echo " rq-status : Check if RQ worker is running"; echo " rq-logs : View RQ worker logs"; echo " rq-stats : Show RQ queue statistics"; echo " rq-jobs : List jobs in default queue"; echo " rq-failed : List failed jobs"; echo " rq-recent : Show recent NetBox jobs"; echo ""; echo "🛠️ Development Tools:"; echo " netbox-shell : Open NetBox Django shell"; echo " netbox-test : Run plugin tests"; echo " netbox-manage : Run Django management commands"; echo " plugin-install : Reinstall plugin in development mode"; echo ""; echo "🧹 Code Quality:"; echo " ruff-check : Check code with Ruff"; echo " ruff-format : Format code with Ruff"; echo " ruff-fix : Auto-fix code issues with Ruff"; echo ""; echo "🔎 Diagnostics:"; echo " diagnose : Run startup diagnostics"; echo " dev-help : Show this help message"; echo ""; echo "📖 NetBox available at: http://localhost:8000 (admin/admin)"; echo ""'

echo "✅ Aliases loaded! Try: rq-status, rq-stats, rq-recent, dev-help"
Loading