Module: Fog::Kubevirt::Compute::VmAction

Included in:
Server, Vm
Defined in:
lib/fog/kubevirt/compute/models/vm_action.rb

Instance Method Summary collapse

Instance Method Details

#start(options = {}) ⇒ Object

Handles both legacy (spec.running) and modern (spec.runStrategy) formats



7
8
9
10
11
12
13
14
# File 'lib/fog/kubevirt/compute/models/vm_action.rb', line 7

def start(options = {})
  vm = service.get_raw_vm(name)

  spec = vm.dig(:spec, :running).nil? ? { runStrategy: "Always" } : { running: true }
  vm = deep_merge!(vm, :spec => spec)

  service.update_vm(vm)
end

#stop(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/fog/kubevirt/compute/models/vm_action.rb', line 16

def stop(options = {})
  vm = service.get_raw_vm(name)

  spec = vm.dig(:spec, :running).nil? ? { runStrategy: "Halted" } : { running: false }
  vm = deep_merge!(vm, :spec => spec)

  service.update_vm(vm)
end