Python SDK (pyvergeos)
Automate VergeOS infrastructure with the pyvergeos Python SDK — VM lifecycle, networking, multi-tenancy, storage, and disaster recovery from Python scripts.
The pyvergeos SDK provides a Pythonic, type-annotated interface for the entire VergeOS REST API. Rather than crafting raw HTTP requests, you work with resource managers — client.vms, client.networks, client.tenants — that map directly to VergeOS objects. The SDK handles authentication, pagination, retries, and async task polling so your automation scripts stay clean and focused on business logic.
Requirements & Installation
Prerequisites:
Python 3.9 or later
VergeOS 26.0 or later
Works on Windows, macOS, and Linux
Install from PyPI (recommended):
pip install pyvergeosOr with uv (faster alternative):
uv add pyvergeosFrom source (development):
git clone https://github.com/verge-io/pyvergeos.git
cd pyvergeos
pip install .Authentication
The SDK supports three authentication methods, each suited to different environments.
Username & Password
The simplest approach for interactive scripts and development:
API Token
For production automation where you have a pre-generated API key:
Environment Variables
The recommended approach for production — keeps credentials out of source code:
Context Manager
Always use the context manager in production code to ensure connections are properly closed, even when exceptions occur:
Resource Managers
Every VergeOS resource type is exposed through a resource manager on the client object. Each manager provides consistent list(), get(), create(), and action methods.
Virtual Machines
client.vms — Create, configure, power control, clone, snapshot, and manage drives/NICs for VMs.
Networks
client.networks — Virtual networks, firewall rules, DHCP, DNS, and network power management.
Tenants
client.tenants — Multi-tenant provisioning, resource isolation, snapshots, storage and network blocks.
NAS & Storage
client.nas — NAS services, volumes, CIFS/NFS shares, and volume synchronization.
Disaster Recovery
client.dr — Cloud snapshots, site synchronization, and recovery workflows.
Users & Groups
client.users — User accounts, groups, permissions, and API key management.
Tasks & Monitoring
client.tasks — Async task tracking, waiting, timeouts. Also: alarms and logs.
System & GPU
client.clusters, client.nodes, client.gpu — Cluster/node info, storage tiers, GPU device management.
Full Resource Table
Virtual Machines
VMs, drives, NICs, snapshots
Networking
Networks, firewall rules, DNS, DHCP, aliases, hosts
VPN
IPSec connections, WireGuard interfaces and peers
NAS/Storage
NAS services, volumes, CIFS/NFS shares, volume syncs
Tenants
Tenant management, snapshots, storage blocks, network blocks
Users & Groups
Users, groups, permissions, API keys
System
Clusters, nodes, storage tiers, certificates
Monitoring
Alarms, logs, tasks
Backup & DR
Snapshot profiles, cloud snapshots, sites, site syncs
Filtering Resources
The SDK provides three approaches for filtering resources, from simple keyword arguments to a full OData filter builder.
Keyword Arguments
The simplest approach for basic filters — pass field names directly:
OData Filter Strings
For complex queries, pass raw OData filter expressions:
Filter Builder (Fluent API)
Build filters programmatically with type safety and auto-completion:
Available filter operators:
.eq()
eq
Filter().eq("status", "running")
.ne()
ne
Filter().ne("os_family", "windows")
.gt()
gt
Filter().gt("ram", 4096)
.lt()
lt
Filter().lt("cpu_cores", 8)
.ge()
ge
Filter().ge("ram", 2048)
.le()
le
Filter().le("ram", 8192)
.and_()
and
Chain multiple conditions
.or_()
or
Combine alternative conditions
Async Task Handling
Many VergeOS operations — snapshots, clones, migrations — run asynchronously and return a task ID immediately. The SDK provides a task manager to poll for completion:
If the task does not complete within the timeout, a TaskTimeoutError is raised with the task_id property so you can check status later:
Error Handling
The SDK provides a structured exception hierarchy so you can catch specific failure modes:
VergeError
Base exception for all SDK errors
AuthenticationError
Invalid credentials or expired token
NotFoundError
Requested resource does not exist
ConflictError
Resource state conflict (e.g., VM already running)
ValidationError
Invalid parameter values
TaskTimeoutError
Task did not complete within timeout
TaskError
Task failed during execution
Retry Configuration
The SDK automatically retries transient errors (HTTP 429, 500, 502, 503, 504) with exponential backoff:
Set retry_total=0 to disable retries entirely for time-sensitive operations.
Tenant Context Switching
pyvergeos can connect into tenant contexts from the host system, enabling centralized automation scripts that manage resources across multiple tenants:
This is particularly valuable for MSPs and service providers who need to automate provisioning across dozens or hundreds of tenant environments from a single script.
Practical Examples
VM Lifecycle Management
Network with Firewall Rules
Bulk Operations with Filtering
Multi-Tenant Inventory Report
Important Notes
Thread Safety
The pyvergeos client is not thread-safe. If you need concurrent operations, create separate VergeClient instances for each thread. For truly parallel workloads, consider the govergeos Go SDK which is designed for concurrent use with goroutines.
Additional Resources
GitHub Repository — Source code, issues, and contributions
PyPI Package — Latest release and version history
Last updated
Was this helpful?