Metadata-Version: 2.4
Name: netbox-canvas
Version: 0.6.0
Summary: Interactive canvas for NetBox: services, hosts, networks, VIPs and circuits, how they connect and what breaks if one fails. Fork of netbox-service-canvas.
Author: Jasper Claus
Author-email: sieteunoseis <jeremy.worden@gmail.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/sieteunoseis/netbox-canvas
Project-URL: Source, https://github.com/sieteunoseis/netbox-canvas
Project-URL: Issues, https://github.com/sieteunoseis/netbox-canvas/issues
Project-URL: Changelog, https://github.com/sieteunoseis/netbox-canvas/blob/main/CHANGELOG.md
Keywords: netbox,netbox-plugin,homelab,service-map,dependency-mapping,impact-analysis,ipam,dcim,diagram,network-documentation
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: JavaScript
Classifier: Topic :: System :: Networking
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Dynamic: license-file

<div align="center">

# 🗺️ NetBox Canvas

A NetBox plugin that shows on an interactive canvas which services run where, how they talk to each other, which
networks, VIPs and circuits they depend on, and what breaks if a host fails.

<sub>A fork of [NetBox Service Canvas](https://github.com/Jasper-Claus/netbox-service-canvas) by Jasper Claus, see
[Where this comes from](#where-this-comes-from).</sub>

[![NetBox](https://img.shields.io/badge/NetBox-4.7-0d6efd?logo=netbox&logoColor=white)](https://github.com/netbox-community/netbox)
[![Python](https://img.shields.io/badge/Python-3.12+-3776ab?logo=python&logoColor=white)](https://www.python.org/)
[![PyPI](https://img.shields.io/pypi/v/netbox-canvas?logo=pypi&logoColor=white)](https://pypi.org/project/netbox-canvas/)
[![License](https://img.shields.io/badge/License-Apache--2.0-green)](https://github.com/sieteunoseis/netbox-canvas/blob/main/LICENSE)
[![CI](https://github.com/sieteunoseis/netbox-canvas/actions/workflows/ci.yml/badge.svg)](https://github.com/sieteunoseis/netbox-canvas/actions/workflows/ci.yml)
[![Built with AI](https://img.shields.io/badge/Built%20with-AI-8a2be2?logo=anthropic&logoColor=white)](#built-with-ai)

[Installation](#installation) · [How it works](#how-it-works) · [Features](#features) ·
[Permissions](#permissions) · [Wiki](https://github.com/sieteunoseis/netbox-canvas/tree/main/docs/wiki) ·
[Deutsch](https://github.com/sieteunoseis/netbox-canvas/blob/main/docs/README.de.md)

</div>

<p align="center">
  <img src="https://raw.githubusercontent.com/sieteunoseis/netbox-canvas/main/docs/images/demo.gif" alt="Demo: drag a NAS onto the canvas, add its services, draw a connection, run the impact analysis" width="100%">
  <br><sub>Drag a host in, let <i>Add missing</i> pull in its services, draw a connection, then check what breaks if it fails.</sub>
</p>

---

## Installation

Requirements: NetBox 4.7 (tested on 4.7.6) and Python 3.12 or newer.

> [!WARNING]
> The plugin declares support for NetBox 4.7 (4.7.6 or newer). On a newer minor version (for example 4.8) the whole of NetBox
> refuses to start while the plugin is enabled. Before upgrading NetBox, check the
> [releases](https://github.com/sieteunoseis/netbox-canvas/releases) for a matching plugin version, or
> remove `netbox_service_canvas` from `PLUGINS` first.

### netbox-docker

All files below are in your netbox-docker folder, next to `docker-compose.yml`. If you have never installed a plugin
there, read [No plugins installed yet?](#no-plugins-installed-yet) first.

1. Open `plugin_requirements.txt` (for example with `nano plugin_requirements.txt`) and add this line. It goes into
   the file, not into the terminal:

   ```text
   netbox-canvas
   ```

2. Open `Dockerfile-Plugins` and make sure it ends with these three lines. They copy the editor's JavaScript and
   CSS into NetBox while the image is built. The two `COPY` lines are needed because NetBox only collects the files of
   plugins listed in `plugins.py`, and netbox-docker mounts that file only when the container starts:

   ```dockerfile
   COPY configuration/configuration.py /etc/netbox/config/configuration.py
   COPY configuration/plugins.py /etc/netbox/config/plugins.py
   RUN DEBUG="true" SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
   ```

3. Open `configuration/plugins.py` and add `"netbox_service_canvas"` to the existing `PLUGINS` list. Add it to the
   list, do not replace the list. If you use netbox-branching, `netbox_branching` must stay the last entry:

   ```python
   PLUGINS = [
       # ... your other plugins ...
       "netbox_service_canvas",
   ]
   ```

4. Rebuild the image and restart. Database migrations run automatically when the container starts:

   ```bash
   docker compose build --no-cache
   docker compose up -d
   ```

5. Check: the menu shows *Plugins → Service Canvas*. Create a canvas and open its *Editor* tab. If the editor stays at
   "Loading canvas…", see [Troubleshooting](#troubleshooting).

#### No plugins installed yet?

netbox-docker needs three files to install plugins. The official guide is
[Using NetBox Plugins](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins). For this plugin
alone, the files look like this:

`plugin_requirements.txt`

```text
netbox-canvas
```

`Dockerfile-Plugins` (use the same image tag as in your `docker-compose.yml`)

```dockerfile
FROM netboxcommunity/netbox:v4.7

COPY ./plugin_requirements.txt /opt/netbox/
RUN /usr/local/bin/uv pip install -r /opt/netbox/plugin_requirements.txt

COPY configuration/configuration.py /etc/netbox/config/configuration.py
COPY configuration/plugins.py /etc/netbox/config/plugins.py
RUN DEBUG="true" SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
```

`docker-compose.override.yml` (if the file already exists, add the `image`, `pull_policy` and `build` lines and keep
your other settings, for example `ports`)

```yaml
services:
  netbox:
    image: netbox:latest-plugins
    pull_policy: never
    build:
      context: .
      dockerfile: Dockerfile-Plugins
  netbox-worker:
    image: netbox:latest-plugins
    pull_policy: never
```

Then continue with step 3 above.

### Plain install (without Docker)

Run these commands as the user that owns the NetBox installation (usually with `sudo`):

```bash
source /opt/netbox/venv/bin/activate
pip install netbox-canvas
echo netbox-canvas >> /opt/netbox/local_requirements.txt   # keeps the plugin across NetBox upgrades
```

Open `/opt/netbox/netbox/netbox/configuration.py` and add `"netbox_service_canvas"` to the existing `PLUGINS` list.
Then:

```bash
cd /opt/netbox/netbox
python manage.py migrate
python manage.py collectstatic --no-input
sudo systemctl restart netbox netbox-rq
```

Check as in step 5 above.

### Configuration (optional)

The plugin works without any settings. If you want a different grid, line shape or menu placement, add this to `PLUGINS_CONFIG`
(next to your existing entries):

```python
PLUGINS_CONFIG = {
    "netbox_service_canvas": {
        "grid_size": 10,               # grid in pixels, default 10
        "edge_line_style": "curved",   # default shape of connection lines: "curved", "straight" or "step"
        "top_level_menu": True,        # False: list the items under NetBox's shared "Plugins" menu
    },
}
```

Single lines can still pick their own shape in the editor.

**More connection protocols.** The built-in list is TCP, UDP, HTTP, HTTPS, MQTT, gRPC, SMB, NFS, SIP, MGCP and Other.
Add your own in NetBox's `configuration.py` with NetBox's standard
[`FIELD_CHOICES`](https://netboxlabs.com/docs/netbox/configuration/data-validation/#field_choices) setting, no plugin
change needed. A trailing `+` extends the list, without it the list is replaced:

```python
FIELD_CHOICES = {
    "netbox_service_canvas.ServiceConnection.protocol+": (
        ("sccp", "SCCP"),
        ("ldap", "LDAP"),
        ("snmp", "SNMP"),
    ),
}
```

The editor, the forms, the API and the filters all pick the extra protocols up after a NetBox restart.

### Update

Make a database backup first. With netbox-docker, run `docker compose build --no-cache` and `docker compose up -d`
again; this installs the newest release (or the version you pinned in `plugin_requirements.txt`). With a plain
install, run `pip install --upgrade netbox-canvas` and repeat `migrate`, `collectstatic` and the restart.
Then reload the editor once with Ctrl+F5.

### Uninstall

> [!CAUTION]
> The first step deletes all canvases, connections, hops and applications of this plugin. Make a database backup
> first. Devices, VMs and services in NetBox are not touched.

1. Remove the plugin's tables while the plugin is still installed:
   `docker compose exec netbox /opt/netbox/netbox/manage.py migrate netbox_service_canvas zero`
   (plain install: `python manage.py migrate netbox_service_canvas zero`).
2. Remove `netbox_service_canvas` from `PLUGINS` and `PLUGINS_CONFIG`, and the line from `plugin_requirements.txt`
   or `local_requirements.txt`.
3. Rebuild and restart (netbox-docker) or `pip uninstall netbox-canvas` and restart (plain install).
4. Optional: delete the leftover static files. In netbox-docker this needs root:
   `docker compose exec -u root netbox rm -rf /opt/netbox/netbox/static/netbox_service_canvas`

A German step-by-step guide with backup and restore is in
[docs/install-netbox-docker.md](https://github.com/sieteunoseis/netbox-canvas/blob/main/docs/install-netbox-docker.md).

### Troubleshooting

| Symptom | Cause and fix |
|---|---|
| The editor stays at "Loading canvas…". The browser console shows a 404 for `canvas.js` or "MIME type ("") blocked". | The static files were not collected. Add the two `COPY` lines and the `collectstatic` line to `Dockerfile-Plugins` (step 2) and rebuild. Running `collectstatic` by hand (`docker compose exec -u root netbox /opt/netbox/netbox/manage.py collectstatic --no-input`) only helps until the container is recreated, and fails if files such as a logo are mounted into the static folder. Then reload with Ctrl+F5. |
| NetBox does not start: `ImproperlyConfigured … requires NetBox …` | The NetBox version is older than 4.7.6 or newer than 4.7. See the warning above. |
| `ModuleNotFoundError: No module named 'netbox_service_canvas'` | The image was not rebuilt, or the package line is missing from `plugin_requirements.txt`. |
| 403 when saving | The user lacks a permission. The editor names the missing one. See [Permissions](#permissions). |

---

## How it works

1. Go to *Plugins → Service Canvas → Canvases → Add* and give the canvas a name, for example *Homelab*.
2. Open the *Editor* tab.
3. Drag devices and VMs from the sidebar onto the canvas, then click **Add missing** to pull in their services.
4. Drag from the dot on the right of a node to another node to create a connection.
5. Click a node or a connection to edit it. Set the connection's kind to **Proxy** if the target is only reachable
   through the source, for example a service behind Traefik.
6. Click **Impact analysis** in the node panel to see what breaks if the node fails.
7. Find anything with the search field in the toolbar, and export the canvas as PNG, SVG, an A4 PDF or an
   Excalidraw scene.

Relationships are stored as normal NetBox data, the canvas only stores the layout. The same object can appear on
several canvases. If an object is deleted in NetBox, it disappears from every canvas.

---

## Features

### Model your services

- **Applications**: a new NetBox object for software made of one or more services, for example Grafana, with status,
  version, URL and one of 24 icons (database, web, DNS, backup, media, …).
- **Connections** between services, devices, VMs, applications, IP addresses (e.g. load balancer VIPs) and circuits, with direction, protocol, port, a description of
  the data and status (active, planned, …).
- **Proxy connections**: mark a connection as *Proxy* when the target is only reachable through the source, for
  example Traefik → Paperless. Proxy chains such as Traefik → Authelia → Grafana work too.
- **Hops**: intermediate stations of a connection, such as a router, firewall, VLAN or tunnel, in a fixed order.
- **"Runs on" from NetBox**: services sit on their device or VM, and a VM pinned to a device runs on it. Nothing has
  to be entered twice.

### Draw the canvas

- **Editor**: drag and drop from a searchable sidebar. **Add missing** pulls in the services and the cabled switches
  and routers of what is already on the canvas. Groups, sticky notes, automatic layout, minimap and autosave.
- **Bendable, colourable lines**: drag the + points of a selected line to route it around other nodes, and pick a
  colour and a shape (curved, straight or step) per line and canvas.
- **Networks**: place prefixes and VLANs on the canvas. Devices and VMs with an IP address in a prefix, or an
  interface in a VLAN, are linked to it automatically ("member of"), and a prefix is linked to its VLAN. Only the most
  specific prefix on the canvas counts, so a /16 and a /24 do not both get a line. **Add missing** on a network pulls
  in its members.
- **VIPs and circuits**: place IP addresses (the sidebar lists those with the VIP role) and circuits on the canvas. A
  VIP runs on the device or VM it is configured on and is linked to its prefix; draw a **Proxy** connection from the
  VIP to its backends. Circuits are drawn as nodes or used as hops.
- **Physical layer**: the cables documented in NetBox are drawn between devices, with the interface names as label.
  Paths through patch panels count as one link. Toggle it in the toolbar.
- **Search** in the toolbar: find an object by name, host, IP or port and jump to it.
- **Node panel**: details, connections and cables of the selected object, quick edit for services and applications,
  links to the NetBox pages.

### Ask "what if this fails?"

- **Impact analysis** for any node, colour-coded on the canvas:
  - **fails with it** (red): services and VMs running on the failed host,
  - **affected** (orange): everything that depends on one of them, or whose connection runs through a failed hop,
  - **unreachable** (yellow): everything behind a failed proxy, behind a switch that was its only cable, or whose
    networks on the canvas have all failed. A prefix fails with its VLAN; a failing member never takes a network down.
- Everything comes from the documentation in NetBox. Nothing is pinged or measured, see
  [What this is not](#what-this-is-not).

### Share it and stay in NetBox

- **Preview** on the canvas page: the drawing read-only, one click to the editor.
- **Export** as PNG, SVG, a printable A4 PDF with title, date and legend, or an **Excalidraw** scene to whiteboard
  a copy.
- **Integrated into NetBox**: lists, filters, CSV import, global search, REST API, GraphQL and change log for all
  objects. Device, VM, service and application pages get a *Connections* tab and a *Show on canvas* button.
- **Follows NetBox**: permissions, light and dark theme, English or German depending on the NetBox language.
- **Works offline**: no CDNs, no external requests. The frontend is bundled with the plugin.

More details and screenshots are in the [wiki](https://github.com/sieteunoseis/netbox-canvas/tree/main/docs/wiki).

<table>
  <tr>
    <td width="50%"><img src="https://raw.githubusercontent.com/sieteunoseis/netbox-canvas/main/docs/images/impact.png" alt="Impact analysis: truenas fails, red and orange mark everything that breaks with it"></td>
    <td width="50%"><img src="https://raw.githubusercontent.com/sieteunoseis/netbox-canvas/main/docs/images/new-service.png" alt="Create a service and its application in one dialog"></td>
  </tr>
  <tr>
    <td align="center">Impact analysis: what breaks if <code>truenas</code> goes down?</td>
    <td align="center">New service with an optional application, in one dialog</td>
  </tr>
</table>

<sub>Screenshots show a demo homelab.</sub>

### Service vs. Application (in one sentence each)

- **Service** (NetBox core) = *where* something listens: one port on one host, for example `grafana · TCP 3000 · nas`.
- **Application** (this plugin) = *what* it is: the software, optionally spanning several services and hosts, for
  example `Grafana`.

For a simple one-port app a service is enough. When you create a service in the editor, you can create or link the
application in the same dialog.

---

## Permissions

| Action | Required permission |
|---|---|
| View a canvas | `view` on *canvas* (objects and connections only as far as you may view them) |
| Move, add, remove nodes | `change` on the canvas + `add/change/delete` on *canvas node* |
| Groups / notes | additionally `add/change/delete` on *canvas group* / *canvas note* |
| Create / edit / delete connections | `add/change/delete` on *service connection* |
| Hops | `add/change/delete` on *connection hop* |
| New service, "runs on", quick edit | `add` / `change` on *ipam › service* |
| Applications | `add` / `change` on *application* |

Users without change permission see the canvas in view-only mode.

---

## More

- [Wiki](https://github.com/sieteunoseis/netbox-canvas/tree/main/docs/wiki): getting started, editor guide, impact analysis,
  export, FAQ
- REST API under `/api/plugins/service-canvas/` and GraphQL: see
  [API in the wiki](https://github.com/sieteunoseis/netbox-canvas/blob/main/docs/wiki/API.md)
- Bug reports, development setup and tests: [CONTRIBUTING.md](https://github.com/sieteunoseis/netbox-canvas/blob/main/CONTRIBUTING.md)
- Changes per version: [CHANGELOG.md](https://github.com/sieteunoseis/netbox-canvas/blob/main/CHANGELOG.md)

## Why this exists

In the words of the original author, Jasper Claus: "NetBox documents my homelab down to every cable and IP, but it
did not show which service runs on which host and who talks to whom. This plugin adds that service layer." This fork
takes it to an enterprise network: the networks, VIPs and circuits those services depend on.

## What this is not

- **Not a monitoring tool.** Nothing is pinged, polled or measured. The canvas shows what is documented in NetBox,
  and the impact analysis answers "what if this fails?" from that documentation. Live state belongs in your
  monitoring (Uptime Kuma, Zabbix, Prometheus, …).
- **Not a discovery tool.** It does not scan your network or import anything automatically. Discovery and imports
  are better done by the tools made for that (Diode, Orb, NAPALM, …) feeding NetBox.
- **Not another network diagram.** Topology plugins draw cables and devices. This plugin adds the service layer on
  top: which service runs where, who talks to whom, through which proxy, and what breaks. The cables are only an
  optional layer for the impact analysis.

## Built with AI

The code, tests and documentation of the original plugin were written by AI ([Claude](https://claude.ai) via Claude
Code), with Jasper Claus contributing the idea and requirements, testing and feedback. This fork's additions were
written the same way. Issues and pull requests are welcome.

How it is kept maintainable: every change runs the Django tests against NetBox 4.7 and the frontend tests in CI, dependencies are updated through Dependabot, security reports go through
[SECURITY.md](https://github.com/sieteunoseis/netbox-canvas/blob/main/SECURITY.md), and every release is listed
in the changelog. The plugin only uses NetBox's own models, permissions and change log, so it does not touch NetBox
core.

## Where this comes from

NetBox Canvas started as a fork of [NetBox Service Canvas](https://github.com/Jasper-Claus/netbox-service-canvas)
by **Jasper Claus** (Apache-2.0), at version 0.5.1. The editor, the service/application model, connections, hops,
impact analysis, exports and the documentation are his work. Thank you, Jasper, for building and sharing it.

This fork adds what we needed to document an enterprise voice and data network on the canvas: prefixes and VLANs as
nodes with derived "member of" lines, IP addresses (load balancer VIPs) and circuits as nodes and connection
endpoints, straight and step line shapes, an Excalidraw export, and export fixes. See the
[CHANGELOG](https://github.com/sieteunoseis/netbox-canvas/blob/main/CHANGELOG.md) for details. The Python module
is still `netbox_service_canvas` and the URLs still live under `/plugins/service-canvas/`, so a database set up with
the original plugin keeps working: uninstall `netbox-service-canvas`, install `netbox-canvas`, run `migrate`.

## Support

If you find this plugin helpful, consider supporting development:

[![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-support-yellow?style=flat&logo=buy-me-a-coffee)](https://buymeacoffee.com/automatebldrs)

## License

[Apache-2.0](https://github.com/sieteunoseis/netbox-canvas/blob/main/LICENSE), see also
[NOTICE](https://github.com/sieteunoseis/netbox-canvas/blob/main/NOTICE). Original work © Jasper Claus. Not
affiliated with NetBox Labs. NetBox is a trademark of NetBox Labs, Inc.
