Class: Pvectl::Wizards::CreateVm

Inherits:
Object
  • Object
show all
Defined in:
lib/pvectl/wizards/create_vm.rb

Overview

Interactive wizard for creating a VM step by step.

Uses TTY::Prompt (when available) or a fallback prompt to guide the user through VM configuration. Returns a normalized params hash compatible with Services::CreateVm, or nil if the user cancels.

Examples:

Running the wizard

wizard = CreateVm.new(options, global_options)
params = wizard.run
#=> { name: "web", node: "pve1", cores: 4, ... } or nil

Constant Summary collapse

OS_TYPES =
%w[l26 l24 win11 win10 win2k22 win2k19 win2k16 win8 win7 other].freeze

Instance Method Summary collapse

Constructor Details

#initialize(options, global_options, prompt: nil) ⇒ CreateVm

Creates a new CreateVm wizard.

Parameters:

  • options (Hash)

    command options (may contain pre-filled values)

  • global_options (Hash)

    global CLI options

  • prompt (Object) (defaults to: nil)

    prompt instance (injectable for testing)



24
25
26
27
28
# File 'lib/pvectl/wizards/create_vm.rb', line 24

def initialize(options, global_options, prompt: nil)
  @options = options
  @global_options = global_options
  @prompt = prompt || create_default_prompt
end

Instance Method Details

#runHash?

Runs the wizard and returns params or nil if cancelled.

Returns:

  • (Hash, nil)

    creation params or nil if user cancels



33
34
35
# File 'lib/pvectl/wizards/create_vm.rb', line 33

def run
  collect_params
end