Python SDK for the VergeOS REST API
Project description
pyvergeos
Python SDK for the VergeOS REST API.
Overview
pyvergeos provides a Pythonic interface for managing VergeOS infrastructure. It abstracts the VergeOS REST API behind a clean, type-annotated SDK suitable for automation, tooling, and integration development.
Installation
pip install pyvergeos
# Or with uv
uv add pyvergeos
Quick Start
from pyvergeos import VergeClient
# Connect to VergeOS
client = VergeClient(
host="192.168.1.100",
username="admin",
password="secret",
verify_ssl=False # For self-signed certificates
)
# List all VMs
for vm in client.vms.list():
print(f"{vm.name}: {vm.ram}MB RAM, {vm.cpu_cores} cores")
# Get a specific VM
vm = client.vms.get(name="web-server")
# Power operations
vm.power_on()
vm.power_off()
# Create a VM
new_vm = client.vms.create(
name="test-vm",
ram=2048,
cpu_cores=2,
os_family="linux"
)
# Cleanup
client.disconnect()
Context Manager
with VergeClient(host="192.168.1.100", token="api-token") as client:
vms = client.vms.list_running()
Authentication
Username/Password
client = VergeClient(
host="192.168.1.100",
username="admin",
password="secret"
)
API Token
client = VergeClient(
host="192.168.1.100",
token="your-api-token"
)
Environment Variables
export VERGE_HOST=192.168.1.100
export VERGE_USERNAME=admin
export VERGE_PASSWORD=secret
# Optional
export VERGE_VERIFY_SSL=true
export VERGE_TIMEOUT=30
export VERGE_RETRY_TOTAL=3
export VERGE_RETRY_BACKOFF=1
client = VergeClient.from_env()
Features
Virtual Machines
# List, filter, create, update, delete
vms = client.vms.list(os_family="linux", name="web-*")
vm = client.vms.create(name="test", ram=2048, cpu_cores=2)
# Power operations
vm.power_on()
vm.power_off()
vm.reset()
# Snapshots
vm.snapshots.create(retention=86400, quiesce=True)
# Clone
clone = vm.clone(name="test-clone")
# Drives and NICs
vm.drives.add(name="data", size=50*1024*1024*1024)
vm.nics.add(network=network.key)
Networks
# Create and manage virtual networks
network = client.networks.create(
name="app-network",
network_address="10.10.1.0/24",
ip_address="10.10.1.1",
dhcp_enabled=True
)
network.power_on()
network.apply_rules()
# Firewall rules
network.rules.create(name="Allow SSH", action="accept", protocol="tcp", dest_port=22)
Tenants
tenant = client.tenants.create(name="customer-a")
tenant.power_on()
Filtering
# Keyword arguments
vms = client.vms.list(status="running", name="prod-*")
# OData filter string
vms = client.vms.list(filter="os_family eq 'linux' and ram gt 2048")
# Filter builder
from pyvergeos.filters import Filter
f = Filter().eq("os_family", "linux").and_().gt("ram", 2048)
vms = client.vms.list(filter=str(f))
Task Waiting
result = vm.snapshots.create(name="backup")
task = client.tasks.wait(result["task"], timeout=300)
Error Handling
from pyvergeos.exceptions import NotFoundError, AuthenticationError, TaskTimeoutError
try:
vm = client.vms.get(name="nonexistent")
except NotFoundError:
print("VM not found")
try:
task = client.tasks.wait(task_id, timeout=60)
except TaskTimeoutError as e:
print(f"Task {e.task_id} timed out")
Retry Configuration
The client automatically retries failed requests for transient errors (429, 500, 502, 503, 504). You can customize the retry behavior:
from http import HTTPStatus
# Custom retry configuration
client = VergeClient(
host="192.168.1.100",
username="admin",
password="secret",
retry_total=5, # Number of retry attempts (default: 3)
retry_backoff_factor=2.0, # Exponential backoff factor (default: 1)
retry_status_codes=frozenset({ # HTTP codes to retry (default: 429, 500, 502, 503, 504)
HTTPStatus.TOO_MANY_REQUESTS,
HTTPStatus.SERVICE_UNAVAILABLE,
}),
)
# Disable retries entirely
client = VergeClient(
host="192.168.1.100",
username="admin",
password="secret",
retry_total=0,
)
Requirements
- Python 3.9+
- VergeOS 26.0+
License
MIT License - see LICENSE for details.
Contributing
Contributions welcome! Please read the contributing guidelines before submitting PRs.
Resources
- VergeOS Documentation - Official VergeOS platform documentation
- VergeOS Website - Learn more about VergeOS
- pyvergeos Documentation - Full SDK documentation
Related Projects
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyvergeos-1.0.1.tar.gz.
File metadata
- Download URL: pyvergeos-1.0.1.tar.gz
- Upload date:
- Size: 799.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b713fd429e5b5049370de79ff9f19de58e9f656ade29c8db82b8b939d54600c
|
|
| MD5 |
8f50c306c24bb21ee91a0c3ff564a1fb
|
|
| BLAKE2b-256 |
3b90e14bb3232cd8f3d2ad570ee4b851e233192ae59ec7855166f9cab67e57ab
|
Provenance
The following attestation bundles were made for pyvergeos-1.0.1.tar.gz:
Publisher:
publish.yml on verge-io/pyVergeOS
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyvergeos-1.0.1.tar.gz -
Subject digest:
9b713fd429e5b5049370de79ff9f19de58e9f656ade29c8db82b8b939d54600c - Sigstore transparency entry: 920019585
- Sigstore integration time:
-
Permalink:
verge-io/pyVergeOS@345cc927bb4be336c331a773c91598658ab15608 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/verge-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@345cc927bb4be336c331a773c91598658ab15608 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyvergeos-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pyvergeos-1.0.1-py3-none-any.whl
- Upload date:
- Size: 397.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fab5a403a30b13749b3addebd5ba16aac94521a626bcaaec62e1ecd12b36923c
|
|
| MD5 |
5838f744866bb21343a49237bbbc1a8c
|
|
| BLAKE2b-256 |
36cb13f2faf14634113a18fedf5773424c310715a61d62552bea4179b25cf092
|
Provenance
The following attestation bundles were made for pyvergeos-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on verge-io/pyVergeOS
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyvergeos-1.0.1-py3-none-any.whl -
Subject digest:
fab5a403a30b13749b3addebd5ba16aac94521a626bcaaec62e1ecd12b36923c - Sigstore transparency entry: 920019590
- Sigstore integration time:
-
Permalink:
verge-io/pyVergeOS@345cc927bb4be336c331a773c91598658ab15608 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/verge-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@345cc927bb4be336c331a773c91598658ab15608 -
Trigger Event:
release
-
Statement type: