pvetui

repository·master·Indexed 20 days ago

https://github.com/devnullvoid/pvetui

A Terminal User Interface (TUI) for managing Proxmox Virtual Environment resources, including VMs, containers, and nodes. It features multi-profile and group mode management, API token or password authentication, integrated SSH and noVNC console access, and a CLI for automation. The project also includes pve-openapi-gen for generating OpenAPI 3.0 specifications from Proxmox VE's apidoc.js and a Proxmox Mock API server for simulating environments with stateful and generic mocking.

Tokens
44.6K
Snippets
153
Records
202
Agent score
71%

What's inside pvetui

  1. Overview of pvetui features

    master

    pvetui is a Terminal User Interface (TUI) designed for managing Proxmox Virtual Environment. Key capabilities include:

    • Resource Management: Full control over VMs, containers, nodes, and cluster resources.
    • Multi-Profile & Group Mode: Manage multiple Proxmox connections via profile switching or combine multiple profiles into a unified view (Group Mode) with routed actions per cluster.
    • Authentication: Supports API tokens or password-based authentication with automatic renewal.
    • Integrated Access: Direct SSH to nodes, VMs, and containers, plus an embedded noVNC client for VNC console access.
    • Extensibility: An opt-in plugin system (e.g., Community Scripts installer) enabled via the Manage Plugins dialog or configuration files.
    • Navigation: Vim-style navigation with customizable key bindings and automatic terminal color scheme adaptation.
    • Automation: A CLI with subcommands for non-interactive use in scripts or AI agent workflows (listing nodes/guests, creating/migrating VMs/LXCs, managing storage, and backups).
  2. Integration test structure and coverage

    master

    Integration tests are located in the test/integration/ directory and cover the following functional areas:

    • API Client Integration: Tests client instantiation, password/token authentication, API operations (VM listing, etc.), caching behavior, and retry mechanisms.
    • Configuration Integration: Tests YAML file loading, environment variable overrides, and configuration validation.
    • Cache Integration: Tests both Badger (persistent) and in-memory cache operations, including complex data structures and concurrent access.
    • End-to-End Workflows: Validates complete paths from configuration (YAML or Environment) through to successful API execution.
  3. Explore pvetui Documentation

    master

    The documentation is organized into three main categories to help different types of users:

    For Users

    • Configuration: Detailed guide on all configuration options, including practical examples and best practices.
    • Theming: Instructions for visual customization, including color schemes and themes.
    • Docker: Guidance on deploying and using pvetui within containers.

    For Developers

    • API Documentation: A complete reference of the public API with usage examples.
    • Testing: Procedures and guidelines for running tests.
    • Integration: Workflows for integration testing and general development.

    Core Reference Files

    • CONFIGURATION.md: Complete configuration guide.
    • THEMING.md: Detailed theming and color customization.
    • DOCKER.md: Docker usage and deployment.
    • PACKAGE_MANAGERS.md: Distribution information (AUR, Homebrew, Scoop, etc.).
    • DOCUMENTATION.md: API documentation and development guide.
    • SCREENSHOTS.md: Interface showcase and screenshots.
  4. Use Group Mode for multi-cluster views

    master

    Group Mode allows you to combine several profiles into a single unified view of CPU, memory, storage, tasks, and guests.

    Operating Modes

    • aggregate: Combines resources from all profiles in the group.
    • cluster: Used for HA-style setups. pvetui connects through one healthy profile at a time and fails over automatically.

    Usage

    You can launch directly into a specific group using the --profile flag:

    pvetui --profile="my-group"

    Note: Migrations are restricted to the VM's original cluster. If a group contains standalone nodes, migration targets will show "No other online nodes available."

  5. Important notes for pve-openapi-gen users

    master

    Versioning

    Upstream apidoc.js is unversioned. You should regenerate your OpenAPI spec whenever you upgrade Proxmox VE to ensure the documentation matches the API.

    Data Normalization

    • Unknown or null responses are normalized to a nullable object.
    • File download endpoints are automatically mapped to application/octet-stream.

    Licensing

    apidoc.js is licensed under AGPLv3 as part of the Proxmox VE documentation. Because the generated OpenAPI specs are derivative works, you should keep them for internal use or comply with AGPL sharing requirements if distributing them.

  6. Manage profile groups and modes

    master

    You can assign profiles to groups and define how those groups behave using group_settings. This allows you to manage multiple servers as a single logical unit.

    Supported modes for groups:

    • aggregate (default): Merges resources from all member profiles into a single view.
    • cluster: Connects through one healthy member profile at a time with automatic failover.

    Set the default_profile to a profile name or a group name to determine what loads on startup.

    default_profile: "all-servers"
    group_settings:
      all-servers:
        mode: aggregate
      prod-ha:
        mode: cluster
  7. Handle task-producing commands and status

    master

    Commands that trigger Proxmox tasks (such as guests create, guests migrate, storage content delete, storage download *, or storage restore) block by default until the task completes. Upon completion, they return a JSON object containing the task status.

    To return the task UPID immediately without waiting for completion, use the --no-wait flag.

    Example JSON output:

    {
      "vmid": 105,
      "node": "pve01",
      "upid": "UPID:pve01:...",
      "status": "complete",
      "exit_status": "OK"
    }

    A non-"OK" exit_status will result in a non-zero process exit code.

    {
      "vmid": 105,
      "node": "pve01",
      "upid": "UPID:pve01:...",
      "status": "complete",
      "exit_status": "OK"
    }
  8. Handle file system operations in tests

    master

    When tests require file system interaction, use t.TempDir() to create a temporary directory. This directory is automatically cleaned up by the Go testing framework after the test completes, preventing side effects and leftover files.

    func TestFileOperations(t *testing.T) {
        tempDir := t.TempDir() // Automatically cleaned up
    
        filePath := filepath.Join(tempDir, "test.txt")
        err := os.WriteFile(filePath, []byte("test"), 0644)
        require.NoError(t, err)
    
        // Test your file operations
    }
  9. How to write a new pvetui plugin

    master

    To author a new plugin for pvetui, follow these steps:

    1. Implement the Interface: Implement the components.Plugin interface (defined in internal/ui/components/plugins.go). You must provide:
      • ID() string: A stable identifier used for configuration.
      • Name() string: User-facing name.
      • Description() string: User-facing description.
      • Initialize(ctx, app, registrar): Called at startup. Use the registrar to register UI contributions (like node actions). Use the app helper to access config, API clients, and UI primitives.
      • Shutdown(ctx): Called at shutdown to release resources.
    2. File Structure: Place your implementation in internal/ui/plugins/<yourplugin>/ and expose a constructor like func New() components.Plugin.
    3. Registration: Register your plugin in internal/ui/plugins/loader.go by adding it to the registry map.
    4. Testing: Add unit tests in internal/ui/plugins to cover registration and logic.

    Best Practices:

    • Respect the provided context.Context for long-running tasks to ensure they are cancellable.
    • Use the components.App methods for interacting with the system state.
  10. How theming works in pvetui

    master

    pvetui uses a dual-layer theming system:

    1. Terminal Emulator Layer: By default, the application uses semantic color constants that map to your terminal's ANSI palette. This allows the UI to automatically adapt to your existing terminal themes (like Dracula, Nord, or Solarized).
    2. Application-Level Layer: You can override specific semantic colors in your configuration file to gain precise control over the UI appearance, regardless of your terminal's palette.

    If you omit a color key in your configuration, pvetui falls back to the built-in default for that specific semantic role.

    theme:
      name: nord
      colors:
        error: "#ff0000"
        background: "#2e3440"
  11. Understand pvetui interface visual indicators

    master

    The pvetui interface uses visual cues to communicate the state of your Proxmox environment:

    • Status Indicators: Resources are color-coded by state:
      • Green: Running
      • Red: Stopped
      • Yellow: Pending
    • Resource Usage: CPU, memory, and storage usage are displayed via visual bars.
    • Hierarchy: The UI organizes resources into a clear hierarchy of Nodes, Guests (VMs/Containers), and Tasks.
  12. Understand color semantics

    master

    pvetui uses semantic colors to ensure consistent meaning across different themes. Understanding these mappings helps when designing custom themes:

    Status Colors

    • Green: Running VMs, online nodes, successful operations
    • Red: Stopped VMs, offline nodes, errors
    • Yellow: Pending operations, warnings, partial failures
    • Blue: Informational elements, descriptions

    Resource Usage Colors

    • Green: Low usage (< 50%)
    • Yellow: Medium usage (50-75%)
    • Red: High usage (75-90%)
    • Red (bright): Critical usage (> 90%)

    UI Element Colors

    • Primary: Main text and important information
    • Secondary: Supporting text and labels
    • Border: Separators and borders
    • Selection: Selected items and focus indicators