hypersdk

hyperctl - Feature Overview

hyperctl is a powerful CLI tool for managing VMware vSphere VMs and orchestrating migrations to KVM.

๐ŸŽฏ Core Features

1. VM Discovery & Listing

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

2. VM Operations

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                                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

3. Job Management

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

4. Beautiful UX

Features:

๐Ÿ“‹ Job Definition Examples

YAML Format

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

JSON Format

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
      }
    }
  ]
}

๐Ÿ”ง API Integration

All hyperctl commands interact with hypervisord daemon via REST API:

๐ŸŽฏ Use Cases

1. VM Discovery Workflow

# 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

2. Pre-Migration Preparation

# 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

3. Automated Migration

# 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'

๐Ÿš€ Advantages Over govc

  1. Rich UX: Beautiful colored output, spinners, progress bars
  2. Migration-Focused: Built specifically for VM migration workflows
  3. Job Management: Asynchronous job submission and tracking
  4. Batch Operations: Submit multiple migrations at once
  5. Integrated: Works seamlessly with hypervisord daemon
  6. Modern: Clean JSON/YAML support for automation
  7. User-Friendly: Helpful tips, examples, and error messages

๐Ÿ“– Quick Reference

Common Commands

# 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

Environment Variables

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'

๐Ÿ”ฎ Roadmap

Planned Features

๐Ÿ“š Documentation

๐Ÿค Contributing

This tool is part of the hyper2kvm project. Contributions welcome!


Built with โค๏ธ using Go and pterm