Skip to main content

Python SDK for the VergeOS REST API

Project description

pyvergeos

Python SDK for the VergeOS REST API.

PyPI version Python 3.9+ License: MIT

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
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.snapshot(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.snapshot()
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")

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.

Related Projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvergeos-0.1.1.tar.gz (495.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvergeos-0.1.1-py3-none-any.whl (235.8 kB view details)

Uploaded Python 3

File details

Details for the file pyvergeos-0.1.1.tar.gz.

File metadata

  • Download URL: pyvergeos-0.1.1.tar.gz
  • Upload date:
  • Size: 495.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyvergeos-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dbcbeaa7b3d7ff265f814704cc174bc314cdfc5c3ff870edd294d303c54b8767
MD5 0523e0211e9f20b9e65203ae3fd45bbf
BLAKE2b-256 0bd6ddbdb0405caa7d2cd5d5c6cd5a5541b4708e68d8c96fef2f54149d74be1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvergeos-0.1.1.tar.gz:

Publisher: publish.yml on verge-io/pyVergeOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvergeos-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyvergeos-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 235.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyvergeos-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 97fa51aa4d4cd01a4b7f56c74ba2b8b22029382cd18bf2e5f0d89ea760151490
MD5 2d6dab74e4e6b81f658a51b93dab8087
BLAKE2b-256 2b56405f2d0f099b346f8df73901ba8cedee745de12ad1c4eab9b2abbf1050b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvergeos-0.1.1-py3-none-any.whl:

Publisher: publish.yml on verge-io/pyVergeOS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page