hyperctl is a powerful CLI tool for managing VMware vSphere VMs and orchestrating migrations to KVM.
Command:
hyperctl list # Show all VMs
hyperctl list -json # JSON output for automation
hyperctl list -filter <name> # Filter by VM name
Features:
Output Example:
โ
Found 201 VMs
๐ VM Summary
โโโโโโโโโโโโโโโโฌโโโโโโโโโ
โ ๐ฅ๏ธ Total VMs โ 201 โ
โ โ
Powered On โ 45 โ
โ โญ Powered Off โ 156 โ
โ ๐พ Total Memoryโ 512 GB โ
โ โก Total CPUs โ 384 โ
โ ๐ฟ Total Storageโ 12 TB โ
โโโโโโโโโโโโโโโโดโโโโโโโโโ
๐ป Virtual Machines
โโโโโฌโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโฌโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ # โ Name โ Power โ CPU โ Memory โ Storage โ Guest OS โ
โโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโผโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ 1 โ win2022 โ poweredOn โ 2 โ 4.0 GB โ 90 GB โ Windows 2022 โ
โ 2 โ rhel9.4 โ poweredOffโ 1 โ 2.0 GB โ 16 GB โ RHEL 9.4 โ
...
โโโโโดโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโดโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโโโโโโ
๐ก Tip: Use 'hyperctl list -json' for machine-readable output
๐ก Tip: Use 'hyperctl list -filter <name>' to filter VMs
Graceful Shutdown:
hyperctl vm -op shutdown -path /data/vm/my-vm
hyperctl vm -op shutdown -path /data/vm/my-vm -timeout 600 # 10 min timeout
Force Power Off:
hyperctl vm -op poweroff -path /data/vm/my-vm
Remove CD/DVD Devices:
hyperctl vm -op remove-cdrom -path /data/vm/my-vm
Get VM Information:
hyperctl vm -op info -path /data/vm/my-vm
Output Example:
โ
Retrieved VM info
๐ VM Information
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Property โ Value โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Name โ Auto-esx8.0-rhel8.9-with-snapshots โ
โ Path โ /data/vm/Auto-esx8.0-rhel8.9-... โ
โ Power State โ poweredOn โ
โ Guest OS โ Red Hat Enterprise Linux 8 (64-bit) โ
โ CPUs โ 1 โ
โ Memory โ 2.0 GB โ
โ Storage โ 16.0 GB โ
โโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Submit Export Job:
# From command line
hyperctl submit -vm /data/vm/my-vm -output /tmp/export
# From YAML file
hyperctl submit -file jobs.yaml
Query Jobs:
hyperctl query -all # All jobs
hyperctl query -id abc123 # Specific job
hyperctl query -status running # Filter by status
Get Job Details:
hyperctl jobs/abc123 # Job details
Cancel Jobs:
hyperctl cancel -id abc123,def456 # Cancel multiple jobs
Daemon Status:
hyperctl status
Features:
Single Job:
name: export-rhel9
vm_path: /data/vm/rhel9.4
output_path: /tmp/export-rhel9
options:
parallel_downloads: 4
remove_cdrom: true
show_individual_progress: false
Batch Jobs:
jobs:
- name: export-vm1
vm_path: /data/vm/vm1
output_path: /tmp/export-vm1
- name: export-vm2
vm_path: /data/vm/vm2
output_path: /tmp/export-vm2
options:
parallel_downloads: 8
Single Job:
{
"name": "export-rhel9",
"vm_path": "/data/vm/rhel9.4",
"output_path": "/tmp/export-rhel9",
"options": {
"parallel_downloads": 4,
"remove_cdrom": true,
"show_individual_progress": false
}
}
Batch Jobs:
{
"jobs": [
{
"name": "export-vm1",
"vm_path": "/data/vm/vm1",
"output_path": "/tmp/export-vm1"
},
{
"name": "export-vm2",
"vm_path": "/data/vm/vm2",
"output_path": "/tmp/export-vm2",
"options": {
"parallel_downloads": 8
}
}
]
}
All hyperctl commands interact with hypervisord daemon via REST API:
GET /vms/list - List all VMsPOST /vms/shutdown - Shutdown VMPOST /vms/poweroff - Power off VMPOST /vms/remove-cdrom - Remove CD/DVDPOST /vms/info - Get VM infoPOST /jobs/submit - Submit jobPOST /jobs/query - Query jobsPOST /jobs/cancel - Cancel jobsGET /jobs/{id} - Get job detailsGET /status - Daemon statusGET /health - Health check# Discover all VMs
hyperctl list
# Find Windows VMs
hyperctl list -filter win
# Export list to JSON for processing
hyperctl list -json > vms.json
# Get details of a specific VM
hyperctl vm -op info -path /data/vm/win2022
# Shutdown VM gracefully
hyperctl vm -op shutdown -path /data/vm/my-vm
# Remove CD/DVD devices
hyperctl vm -op remove-cdrom -path /data/vm/my-vm
# Verify VM is ready
hyperctl vm -op info -path /data/vm/my-vm
# Create job file
cat > migrate-batch.yaml <<EOF
jobs:
- name: migrate-web1
vm_path: /data/vm/web1
output_path: /migrations/web1
options:
parallel_downloads: 8
remove_cdrom: true
- name: migrate-db1
vm_path: /data/vm/db1
output_path: /migrations/db1
options:
parallel_downloads: 4
EOF
# Submit batch
hyperctl submit -file migrate-batch.yaml
# Monitor progress
watch -n 5 'hyperctl query -status running'
# Discovery
hyperctl list # List all VMs
hyperctl list -filter rhel -json # Find RHEL VMs (JSON)
# VM Operations
hyperctl vm -op shutdown -path /data/vm/my-vm # Shutdown
hyperctl vm -op poweroff -path /data/vm/my-vm # Power off
hyperctl vm -op remove-cdrom -path /data/vm/my-vm# Remove CD
hyperctl vm -op info -path /data/vm/my-vm # Get info
# Job Management
hyperctl submit -vm /data/vm/my-vm -output /tmp # Submit job
hyperctl query -all # List jobs
hyperctl query -status running # Running jobs
hyperctl cancel -id abc123 # Cancel job
hyperctl status # Daemon status
export GOVC_URL='https://vcenter.example.com/sdk'
export GOVC_USERNAME='administrator@vsphere.local'
export GOVC_PASSWORD='password'
export GOVC_INSECURE=1
export GOVC_DATACENTER='datacenter1'
This tool is part of the hyper2kvm project. Contributions welcome!
Built with โค๏ธ using Go and pterm