# | VM Configuration Schema Contracts
# | Migrated from: provisioning/kcl/vm.k
# | Pattern: Three-file (contracts + defaults + main)

{
  VmConfig = {
    name | String,
    description | String | optional,
    base_image | String,
    cpu | Number,
    memory_mb | Number,
    disk_gb | Number,
    backend | String,
    permanent | Bool,
    temporary | Bool,
    auto_cleanup | Bool,
    auto_cleanup_hours | Number | optional,
    taskserv | String | optional,
    taskservs,
    network_mode | String,
    networks | optional,
    ports | optional,
    mounts | optional,
    volumes | optional,
    cloud_init | optional,
    nested_virt | Bool | optional,
    graphics_enable | Bool | optional,
    serial_console | Bool | optional,
  },

  VmNetwork = {
    name | String,
    type | String,
    subnet | String | optional,
  },

  VmPortMapping = {
    host_port | Number,
    guest_port | Number,
    protocol | String,
    bind_addr | String | optional,
  },

  VmMount = {
    host_path | String,
    guest_path | String,
    readonly | Bool,
    mode | String | optional,
  },

  VmVolume = {
    name | String,
    size_gb | Number,
    mount_path | String | optional,
    format | String,
  },

  VmCloudInit = {
    enabled | Bool,
    user_data | String | optional,
    meta_data | String | optional,
    vendor_data | String | optional,
  },

  VmImage = {
    name | String,
    format | String,
    path | String,
    size_gb | Number,
    base_os | String,
    os_version | String,
  },

  VmState = {
    vm_name | String,
    state | String,
    permanent | Bool,
    created_at | String,
    started_at | String | optional,
    last_action | String | optional,
    auto_cleanup_at | String | optional,
    ip_address | String | optional,
    mac_address | String | optional,
    hypervisor | String | optional,
    backend_id | String | optional,
  },

  VmRegistry = {
    vms,
    permanent_count | Number,
    temporary_count | Number,
    updated_at | String,
  },

  VmCapacity = {
    host_name | String,
    total_cpu_cores | Number,
    used_cpu_cores | Number,
    total_memory_mb | Number,
    used_memory_mb | Number,
    total_disk_gb | Number,
    used_disk_gb | Number,
    max_vms | Number,
    running_vms | Number,
  },
}
