netbox-proxbox Documentation

repository·main·Indexed 20 days ago

https://github.com/emersonfelipesp/netbox-proxbox

A NetBox plugin and toolset designed to synchronize Proxmox infrastructure data—including clusters, nodes, VMs, containers, storage, and networking—into NetBox for accurate DCIM and inventory management. The package includes a CLI (pxb) for managing endpoints and triggering syncs, and a standalone scheduler container for advanced timing requirements such as cron expressions, sub-minute intervals, and continuous reconciliation.

Tokens
175.4K
Snippets
374
Records
803
Agent score
66%

What's inside netbox-proxbox

  1. Overview of edgeuno/netbox-proxbox

    main

    The edgeuno/netbox-proxbox plugin is a NetBox extension designed to import Proxmox VE inventory state into NetBox. It mirrors Proxmox clusters, nodes, virtual machines (VMs), and LXC containers into NetBox's dcim and virtualization applications.

    Key Capabilities

    • Proxmox to NetBox Importer: Performs read-only synchronization of Proxmox resources.
    • Multi-cluster Support: The v2 sync engine allows a single configuration_options.json file to define multiple Proxmox clusters for a single sync run.
    • Dual-mode Runtime:
      • Synchronous (v1): Triggered via the NetBox UI ("Full Update" button).
      • Asynchronous (v2): Triggered via a scheduled container using the proxboxscrapper command.

    Important Limitations

    • Read-Only: All Proxmox API interactions are GET requests; the plugin does not push state from NetBox to Proxmox.
    • Fork Divergence: This is an EdgeUno fork and contains specific business logic (e.g., regex-based tenant assignment, role pinning to "VPS" and "LXC") that differs from the upstream netbox-proxbox project.
  2. Overview of proxbox-scheduler

    main

    The proxbox-scheduler is a standalone container designed to trigger periodic Proxbox syncs on a configurable cadence. Unlike the NetBox plugin, this container is stateless and holds no NetBox models or plugin configurations; all settings are managed via environment variables.

    When to use proxbox-scheduler instead of NetBox-side scheduling:

    • Managed Environments: When the NetBox container is managed by a tenant (e.g., Kubernetes or managed-NetBox) and you cannot add cron jobs directly to the host.
    • Advanced Timing: When you need cron=<expression> semantics, as NetBox's built-in Job.interval only supports minute-level increments (minimum 1 minute).
    • Continuous Sync: When you require continuous zero-gap reconciliation, which provides immediate re-triggering after a sync completes, a behavior not supported by NetBox's JobRunner.handle().
  3. Overview of Proxbox Companion Plugins

    main

    The Proxbox ecosystem uses a central FastAPI backend (proxbox-api) and a core NetBox plugin (netbox-proxbox). To extend inventory to adjacent Proxmox-family infrastructure, you can install standalone companion plugins. Each plugin is an independent NetBox package, allowing you to install only what matches your specific infrastructure.

    Available Companion Plugins

    PluginPyPI packageInventory Scope
    netbox-pbsnetbox-pbsProxmox Backup Server (servers, datastores, snapshots, jobs)
    netbox-pdmnetbox-pdmProxmox Datacenter Manager (PDM endpoints and remotes: PVE + PBS)
    netbox-cephnetbox-cephCeph clusters (nodes, OSDs, pools, filesystems, CRUSH rules, flags, health checks)
    netbox-packernetbox-packerHashiCorp Packer (image definitions and build execution records)
  4. Overview of netbox-proxmox-automation

    main

    What it is

    netbox-proxmox-automation is an event-driven integration that uses NetBox as the desired state source of truth for Proxmox VE workloads (VMs and LXC containers).

    When a NetBox object is created, updated, or deleted, NetBox triggers a webhook via an event rule. This webhook is then translated into a Proxmox API operation (e.g., cloning a template, resizing a disk, starting/stopping a workload, or migrating between nodes).

    Execution Paths

    The project provides two interchangeable ways to handle webhooks:

    1. AWX / Tower / AAP: Uses a set of Ansible playbooks executed by job templates triggered by webhooks.
    2. Flask application: A small Flask + Flask-RESTX HTTP service that receives webhooks and calls the Proxmox API directly in-process.

    Key Distinctions

    • Not a NetBox plugin: It does not install Django apps, migrations, or models; it layers custom fields and event rules onto an existing NetBox instance.
    • Not a continuous sync tool: Unlike ProxBox, it does not continuously sync Proxmox state back to NetBox. The only reverse flow (Proxmox $\rightarrow$ NetBox) occurs during one-shot discovery scripts.
    • No reconciliation loop: The system is purely reactive. The webhook payload is the only trigger; there is no background scheduler or reconciliation loop to fix drift.
  5. Navigate Proxbox UI Resource Views

    main

    The Proxbox plugin organizes Proxmox-related data into several logical views within the NetBox interface:

    Core Management

    • Plugin Home: Displays endpoint status cards, quick-sync actions, and primary navigation.
    • Dashboard: Provides operational summaries of clusters and nodes sourced from the proxbox-api backend.

    Endpoint Configuration

    • Proxmox Endpoints: Configuration for the Proxmox API endpoints the plugin connects to.
    • FastAPI (Proxbox) Endpoints: Configuration for the companion proxbox-api backend.
    • NetBox Endpoints: The self-referential NetBox endpoint used by proxbox-api for write-back operations.

    Infrastructure & Virtualization

    • Clusters: Discovered Proxmox clusters synchronized into NetBox.
    • Nodes: Proxmox nodes (devices) associated with specific clusters.
    • Storage: Proxmox storage pools tracked per cluster.
    • Virtual Machines: Proxmox VMs synchronized into NetBox Virtualization.
    • LXC Containers: Linux containers managed by Proxmox and tracked in NetBox.

    Backup & Recovery

    • Backups: VM backup jobs discovered from Proxmox storage.
    • Snapshots: VM and container snapshots tracked per virtual machine.
  6. Understand the netbox-proxbox package layout

    main

    The netbox-proxbox plugin is organized into several functional directories:

    • netbox_proxbox/models/: Contains 13 persisted Django models.
    • netbox_proxbox/views/: Handles dashboard, endpoint CRUD, sync actions, job helpers, and status checks.
    • netbox_proxbox/api/: Provides the NetBox plugin REST API using NetBoxModelViewSet.
    • netbox_proxbox/services/: Contains the backend HTTP proxy, keepalive checks, schema caching, and sync coordination.
    • netbox_proxbox/jobs.py: Defines ProxboxSyncJob, a NetBox background job that wraps the FastAPI SSE sync.
    • netbox_proxbox/template_content.py: Extends NetBox templates to inject "Run Sync" and "Cancel" buttons into Job and VirtualMachine detail pages.
    • netbox_proxbox/websocket_client.py: A long-lived WebSocket client for backend broadcast messages.
  7. Understand the Proxbox Repository Layout

    main

    The repository is organized into two main parts: the root directory containing deployment and orchestration files, and the netbox_proxbox/ directory which contains the actual Django plugin package.

    Key Components

    • Root Directory: Contains tasks.py (Invoke runner), Dockerfile (for containerized deployment), docker-compose.yaml (for the scheduler service), and configuration_options_default.json (the configuration template).
    • netbox_proxbox/ (The Plugin):
      • api/: REST API endpoints for the plugin.
      • management/commands/proxboxscrapper.py: The CLI command to run the scraper.
      • proxbox_api_v2/: The active, asynchronous, multi-cluster sync engine.
      • models.py: Defines ProxmoxVM and SyncTask models.
      • templates/: HTML templates for NetBox integration.
  8. What Proxbox does

    main

    Proxbox is a NetBox plugin that synchronizes Proxmox infrastructure data into NetBox. It automates the inventory of:

    • Clusters and Nodes: Names, modes, quorum status, node counts, and Proxmox VE versions. Includes real-time metrics (CPU, memory, uptime, IP, status) as point-in-time snapshots.
    • Virtual Machines & Containers: VM/LXC status, resources, and configurations.
    • Firecracker Cloud inventory: Host pools, host-agent VMs, image templates, and micro-VMs.
    • Storage & Networking: Datastores, NICs (as NetBox VM interfaces), guest-OS interfaces, and assigned IP addresses.
    • Backup & Replication: VM snapshots, backup jobs, restore points, and replication status.
    • Service Monitoring: Opt-in monitoring of Proxmox endpoint systemd service states via netbox-rpc.
  9. Compare netbox-proxbox with the EdgeUno fork

    main

    This document provides a side-by-side comparison between the upstream netbox-proxbox (this repository) and the EdgeUno fork. While both aim to import Proxmox state into NetBox, they use fundamentally different architectures.

    Upstream (netbox-proxbox + proxbox-api)

    • Architecture: A two-service mirror model.
    • Components: A NetBox plugin (UI, models, settings, RQ jobs) and a separate FastAPI backend (proxbox-api) that handles Proxmox/NetBox connection logic and the sync engine.
    • Communication: Services communicate over HTTP/SSE/WebSocket using a pinned wire contract.
    • Security: Encrypted credentials live in the backend's Fernet store, not in NetBox.
    • Sync Mechanism: Triggered via RQ ProxboxSyncJob on NetBox's default queue; progress is streamed back to the plugin via SSE.

    EdgeUno Fork

    • Architecture: A single-process scrapper model.
    • Components: A single NetBox plugin containing two embedded sync engines (proxbox_api/ synchronous and proxbox_api_v2/ asynchronous).
    • Communication: The plugin talks directly to Proxmox and NetBox.
    • Security: Configuration and plaintext credentials are stored in an external configuration_options.json file.
    • Sync Mechanism: Triggered via a Django view, a management command (python manage.py proxboxscrapper), or a standalone container scheduler.
  10. Understand the netbox-proxbox Browser Frontend architecture

    main

    The netbox-proxbox UI is built using standard Django templates that extend the NetBox base layout. The frontend is enhanced with JavaScript to provide real-time capabilities, including:

    • SSE (Server-Sent Events) streaming for real-time sync progress.
    • WebSocket updates for dashboard synchronization.
    • Keepalive polling for endpoint status badges.
    • Dashboard hydration via asynchronous JSON requests.

    Templates are organized under netbox_proxbox/templates/netbox_proxbox/ and include specialized directories for home (dashboard), fastapi (endpoints), proxmox (cluster/node views), and table (shared fragments).

  11. Configure Proxmox endpoint access methods

    main

    Proxmox endpoints allow for granular control over how the backend communicates with them. You can select between:

    • API-only: Communication via REST API.
    • API+SSH: Communication via both REST API and SSH transport.

    The selected access_methods are sent to the backend registration payload, allowing backend SSH paths to enforce the same access gates. Additionally, operators can use a Fetch host key flow to pin SSH fingerprints for enhanced security.

  12. Configure netbox-sdk authentication (v1 and v2 tokens)

    main

    The netbox-sdk supports two types of NetBox authentication tokens:

    1. Token v1: Uses the classic Authorization: Token <value> header.
    2. Token v2: Uses the newer nbt_<key>.<secret> format. The SDK automatically handles the splitting and encoding of the key and secret.

    When building a Config object (e.g., via netbox_config_from_endpoint), you specify the token_version as either "v1" or "v2". For v2, you must provide the token_key (the <key> portion) and the token_secret (the <secret> portion).

    # Example of how the SDK config is constructed internally
    def netbox_config_from_endpoint(endpoint: NetBoxEndpoint) -> Config:
        tv = (endpoint.token_version or "v1").lower()   # "v1" or "v2"
        return Config(
            base_url=endpoint.url,
            token_version=tv,
            token_key=key,          # v2 only: key portion of nbt_key.secret
            token_secret=decrypted_token,
            timeout=_resolve_netbox_timeout(),  # PROXBOX_NETBOX_TIMEOUT env var
            ssl_verify=endpoint.verify_ssl,
        )