Class: Kitchen::Driver::Proxmox

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/driver/proxmox.rb,
lib/kitchen/driver/proxmox/api_client.rb

Overview

Proxmox VE driver for Test Kitchen.

Manages VM lifecycle via the Proxmox REST API:

  • create: clone a template, configure hardware, start, wait for IP

  • destroy: stop and delete the VM

Defined Under Namespace

Classes: ApiClient

Constant Summary collapse

ApiError =
Kitchen::Driver::ProxmoxErrors::ApiError

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object



40
41
42
43
44
45
# File 'lib/kitchen/driver/proxmox.rb', line 40

def create(state)
  return if state[:vm_id]

  validate_config!
  clone_and_start(state)
end

#destroy(state) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/kitchen/driver/proxmox.rb', line 47

def destroy(state)
  return unless state[:vm_id]

  vm_id = state[:vm_id]
  info("Destroying Proxmox VM #{state[:vm_name]} (#{vm_id})...")
  safe_stop_vm(vm_id)
  api_client.destroy_vm(node: config[:node], vm_id:)
  clear_state(state)
  info("Proxmox VM #{vm_id} destroyed.")
end