VM Power Management API
Complete guide to managing VM power states in VergeOS, including starting, stopping, rebooting, and monitoring power status
This guide covers managing virtual machine power states in VergeOS, including starting, stopping, rebooting, and monitoring VMs. The VergeOS API provides comprehensive power management capabilities with both graceful and forced operations.
Stage: VM Power Management (2 of 4) Input: VM key (42) from creation, power operation type Output: Power state changes, runtime status Previous: VM created → VM Creation Common Next Steps:
Configure VM settings →
VM ConfigurationAdvanced operations →
VM Advanced Operations
This Document Helps With
"How to start/stop VMs via API"
"Checking VM power status"
"Graceful vs forced VM shutdown"
"VM reboot and reset operations"
"Monitoring VM power state"
"Power management automation"
"VM startup troubleshooting"
"Scheduled power operations"
"Resource optimization through power control"
Quick Reference
Primary Endpoints
Power Actions:
POST /api/v4/vm_actionsVM Status:
GET /api/v4/vms/{id}Power State:
GET /api/v4/machine_status/{machine_id}
Key Actions
poweron: Start VMpoweroff: Graceful shutdown (ACPI)kill: Force power offreset: Reboot VM
Authentication
Prerequisites
VM must be created first → See VM Creation
API Quick Reference
Power On
POST
/api/v4/vm_actions
VM key
Start virtual machine
Power Off
POST
/api/v4/vm_actions
VM key
Graceful shutdown (ACPI)
Force Off
POST
/api/v4/vm_actions
VM key
Immediate termination
Reboot
POST
/api/v4/vm_actions
VM key
Restart VM
VM Info
GET
/api/v4/vms/{id}
VM key
Configuration data
Power State
GET
/api/v4/machine_status/{id}
Machine key
Runtime status
Troubleshooting Index
409 Conflict: VM already running, VM not running, power state mismatch
507 Insufficient Resources: Not enough cluster resources, memory/CPU unavailable
403 Forbidden: API key permissions, cluster access denied, VM access restricted
404 Not Found: Invalid VM key, VM deleted, machine key not found
408 Request Timeout: Power operation timeout, VM unresponsive, cluster communication failure
500 Internal Server Error: Hypervisor issues, node problems, storage failures
Starting VMs
POST /api/v4/vm_actions
Description: Powers on a virtual machine and waits for it to reach running state.
Power On Request:
Complete API Call:
Response: 201 Created when action is initiated.
Best Practices
Always verify VM configuration before powering on
Ensure all required drives and network interfaces are attached
Check cluster resource availability
Verify VM is not already running to avoid conflicts
Stopping VMs
Graceful Power Off (ACPI)
Description: Sends an ACPI shutdown signal to the guest operating system, allowing it to shut down cleanly.
Complete API Call:
Force Power Off (Kill)
Description: Immediately terminates the VM without allowing the guest OS to shut down cleanly. Use only when graceful shutdown fails.
Complete API Call:
Force Power Off
Using kill action may cause data loss or corruption. Always try graceful poweroff first and only use kill when necessary.
Rebooting VMs
Graceful Reboot (ACPI)
Description: Sends an ACPI reset signal to the guest operating system for a clean restart.
Complete API Call:
Hard Reset (Power Cycle)
Description: Immediately restarts the VM without allowing the guest OS to shut down cleanly.
Complete API Call:
VM Status and Information
GET /api/v4/vms/{id}
Description: Retrieves VM configuration and metadata using various field filters.
Get Complete VM Information:
Response Example:
VM Power State and Runtime Status
GET /api/v4/machine_status/{machine_id}
Description: Retrieves the actual runtime status and power state of a VM using the machine key.
Check VM Power State:
Stopped VM Response Example
Running VM Response Example
VM vs Machine Status
VM Information (
/api/v4/vms/{vm_key}): Configuration, settings, and metadataPower State (
/api/v4/machine_status/{machine_key}): Runtime status, power state, and resource usageAlways use the machine key (not VM key) to check actual power state and runtime status
Status Fields
powerstate: Boolean indicating if VM is powered onrunning: Boolean indicating if VM is currently runningstatus: Text status ("running", "stopped", etc.)state: Overall state ("online", "offline")node: Which physical node the VM is running on (null if stopped)
Power State Monitoring
Checking Power State Only
For quick power state checks, you can request specific fields:
Response:
Monitoring Power State Changes
Common Power Management Workflows
Safe VM Shutdown Workflow
VM Restart Workflow
Error Handling
Common Power Management Errors
Error: 409 Conflict - VM already running
Solution: Check current power state before issuing power commands.
Error: 409 Conflict - VM not running
Solution: Verify VM is actually running before attempting shutdown.
Error: 507 Insufficient Resources
Solution: Check cluster resource availability or reduce VM resource requirements.
Operation Timeouts
Set appropriate timeouts for power operations:
Power On: 30-60 seconds
Graceful Shutdown: 60-120 seconds
Force Shutdown: 10-30 seconds
Reboot: 60-120 seconds
Last updated
Was this helpful?