A Python SDK for interacting with the Incus API. This SDK provides a simple and intuitive way to manage Incus containers, virtual machines, and other resources using Python.
pip install incus-sdk
Comprehensive documentation is available at https://orbical-dev.github.io/incus_sdk/
The documentation includes:
- Installation instructions
- Quick start guide
- API reference
- Code examples
- Error handling guide
- Contributing guidelines
To build and view the documentation locally:
# Install documentation dependencies
pip install -r docs/requirements.txt
# Build and serve the documentation
cd docs
mkdocs serve
Then open http://127.0.0.1:8000 in your browser.
- Full support for Incus REST API
- Asynchronous operation support
- Easy management of containers, virtual machines, networks, profiles, storage pools, and clusters
- Certificate-based authentication
- Support for local and remote Incus servers
- Comprehensive error handling with specific exception types
- Project-based resource management
from incus_sdk import Client
# Connect to local Incus socket
client = Client()
# List all instances
instances = client.instances.list()
for instance in instances:
print(f"Instance: {instance.name}, Status: {instance.status}")
# Create a new container
container = client.instances.create(
name="my-container",
source={
"type": "image",
"protocol": "simplestreams",
"server": "https://images.linuxcontainers.org",
"alias": "ubuntu/22.04"
},
wait=True
)
# Start the container
container.start(wait=True)
# Create a network
network = client.networks.create(
name="my-network",
config={
"ipv4.address": "10.0.0.1/24",
"ipv4.nat": "true"
}
)
# Error handling
try:
instance = client.instances.get("non-existent")
except incus_sdk.IncusNotFoundError as e:
print(f"Instance not found: {e}")
For detailed documentation, visit https://incus-sdk.readthedocs.io
The SDK provides the following API clients:
instances
- Manage containers and virtual machinesimages
- Manage images and aliasesnetworks
- Manage networksprofiles
- Manage profilesstorage_pools
- Manage storage pools and volumescertificates
- Manage certificatesoperations
- Manage operationsprojects
- Manage projectscluster
- Manage clusters and cluster members
The SDK provides specific exception types for different error scenarios:
IncusError
- Base exception for all Incus errorsIncusAPIError
- Exception for API request failuresIncusConnectionError
- Exception for connection failuresIncusOperationError
- Exception for operation failuresIncusNotFoundError
- Exception for resource not found errorsIncusAuthenticationError
- Exception for authentication failuresIncusPermissionError
- Exception for permission denied errors
MIT License