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



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

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

  resolve_node(state)
  resolve_template(state)
  validate_config!
  resolve_clone_strategy(state)
  clone_and_start(state)
end

#destroy(state) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/kitchen/driver/proxmox.rb', line 56

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

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