VM Advanced Operations API
Complete guide to advanced VM operations in VergeOS, including cloning, snapshots, deletion, and troubleshooting
This guide covers advanced virtual machine operations in VergeOS, including cloning, snapshot management, deletion, and troubleshooting. These operations provide powerful capabilities for VM lifecycle management and disaster recovery.
Stage: VM Advanced Operations (4 of 4) Input: VM key (42), operation type, parameters Output: Cloned VMs, snapshots, cleanup confirmation Previous: VM configured → VM Configuration Common Operations:
Clone for templates → New VM creation cycle
Snapshot for backup → Recovery workflows
Delete for cleanup → End of lifecycle
This Document Helps With
"How to clone VMs via API"
"Creating VM snapshots and backups"
"Restoring VMs from snapshots"
"Safely deleting VMs and cleanup"
"VM troubleshooting and diagnostics"
"Template creation workflows"
"Disaster recovery operations"
"Bulk VM management"
"Resource cleanup automation"
Quick Reference
Primary Endpoints
VM Actions:
POST /api/v4/vm_actionsVM Deletion:
DELETE /api/v4/vms/{vm_key}VM Listing:
GET /api/v4/vms
Key Actions
clone: Create complete VM copysnapshot: Create VM snapshotrestore: Restore from snapshot
Authentication
Prerequisites
VM must exist → See VM Creation
API Quick Reference
Clone VM
POST
/api/v4/vm_actions
VM key
Create complete copy
Create Snapshot
POST
/api/v4/vm_actions
VM key
Point-in-time backup
Restore Snapshot
POST
/api/v4/vm_actions
VM key
Recovery operation
List Snapshots
GET
/api/v4/vms
Filter query
Find snapshots
Delete VM
DELETE
/api/v4/vms/{id}
VM key
Complete removal
VM Status
GET
/api/v4/vms/{id}
VM key
Configuration check
Operation Status
GET
/api/v4/machine_status/{id}
Machine key
Runtime monitoring
Troubleshooting Index
409 Conflict: Clone name exists, VM already running, operation in progress
507 Insufficient Storage: Not enough space for clone, snapshot storage full
403 Forbidden: API key permissions, VM access denied, cluster restrictions
404 Not Found: VM not found, snapshot not found, invalid VM key
408 Request Timeout: Clone operation timeout, snapshot creation timeout
422 Unprocessable Entity: Invalid clone parameters, snapshot restore conflict
500 Internal Server Error: Storage system issues, hypervisor problems, cluster failures
VM Cloning
POST /api/v4/vm_actions
Description: Creates a complete copy of a VM including all drives and configuration.
Basic Clone
Complete API Call:
Response Example:
Advanced Clone Options
Clone Parameters
name
string
Yes
Name for the cloned VM
description
string
No
Description for the clone
quiesce
string
No
Quiesce VM before cloning ("true"/"false") for data consistency
preserve_macs
string
No
Preserve MAC addresses ("true"/"false")
preserve_device_uuids
string
No
Preserve device UUIDs ("true"/"false")
cluster
string
No
Target cluster ID
Clone Options
Quiesce: Use
"quiesce": "true"to ensure data consistency by pausing the VM brieflyPreserve MACs: Use
"preserve_macs": "true"to keep the same MAC addresses (may cause network conflicts)Preserve Device UUIDs: Use
"preserve_device_uuids": "true"to maintain device identifiersCross-Cluster: Specify different cluster ID to clone to another cluster
Clone Workflow Example
VM Snapshots
Creating Snapshots
Complete API Call:
Restoring from Snapshots
Complete API Call:
Listing VM Snapshots
GET /api/v4/vms
Use filters to find snapshots:
Find All Snapshots for a VM:
Snapshot Management Workflow
VM Deletion and Cleanup
Complete VM Deletion
DELETE /api/v4/vms/{vm_key}
Description: Deletes a VM and automatically removes all associated resources including drives, NICs, devices, and configurations.
Response: 200 OK on successful deletion.
Automatic Cleanup
When you delete a VM using DELETE /api/v4/vms/{vm_key}, VergeOS automatically removes:
All drives attached to the VM
All network interfaces (NICs)
All devices (GPU, PCI passthrough, USB, TPM, etc.)
VM configuration and metadata
Cloud-init files and configurations
VM notes and documentation
Associated machine resources
Pre-Deletion Considerations
Before deleting a VM, consider:
Data Backup: Ensure important data is backed up
Snapshots: VM snapshots may be deleted with the VM
Dependencies: Check if other systems depend on this VM
Network Configuration: Note any special network configurations
Licensing: Consider software licensing implications
Safe Deletion Process
Step 1: Power Off VM (Recommended)
Step 2: Verify Power State
Step 3: Create Final Backup (Optional)
Step 4: Delete VM and All Resources
VM Key Usage
Use the VM key (e.g., 42) from the VM creation response or VM listing, not the machine key. The deletion process automatically handles all associated machine resources.
No Manual Cleanup Required
Unlike some virtualization platforms, VergeOS handles complete resource cleanup automatically. You do not need to manually:
Delete individual drives
Remove network interfaces
Detach devices
Clean up configuration files
Remove machine status entries
The single DELETE /api/v4/vms/{vm_key} operation handles all cleanup automatically.
Finding Orphaned Resources
Error Handling and Troubleshooting
Common Error Scenarios
VM Creation Failures
Error: 400 Bad Request - Invalid machine type
Solution: Use valid machine types from the supported list.
Power State Conflicts
Error: 409 Conflict - VM already running
Solution: Check current power state before issuing power commands.
Resource Constraints
Error: 507 Insufficient Storage
Solution: Choose different storage tier or reduce disk size.
Clone Failures
Error: 409 Conflict - Clone name already exists
Solution: Use unique names for cloned VMs.
Monitoring VM Operations
Checking Operation Status
Many VM operations are asynchronous. Monitor progress using:
Operation Timeouts
Set appropriate timeouts for long-running operations:
VM Creation: 5-10 minutes
Clone Operations: 10-30 minutes (depending on size)
Snapshot Creation: 2-5 minutes
Snapshot Restore: 5-15 minutes
Power State Changes: 30-60 seconds
VM Deletion: 2-5 minutes
Retry Logic
Implement retry logic for transient failures:
Debugging VM Issues
Check VM Configuration
Check Machine Status
Check System Resources
Best Practices
Always test operations in development environments first
Create snapshots before major changes
Monitor resource usage during operations
Implement proper error handling in automation scripts
Use descriptive names for clones and snapshots
Clean up unused resources regularly
Document operational procedures for your team
Last updated
Was this helpful?