Class: Actions::ForemanWreckingball::Host::RemediateHardwareVersion

Inherits:
EntryAction
  • Object
show all
Defined in:
app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb

Instance Method Summary collapse

Instance Method Details

#append_error(message) ⇒ Object



52
53
54
55
# File 'app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb', line 52

def append_error(message)
  output[:errors] ||= []
  output[:errors] << message
end

#delay(delay_options, host) ⇒ Object



9
10
11
12
# File 'app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb', line 9

def delay(delay_options, host)
  action_subject(host)
  super(delay_options, host)
end

#humanized_inputObject



48
49
50
# File 'app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb', line 48

def humanized_input
  input[:host] && input[:host][:name]
end

#humanized_nameObject



44
45
46
# File 'app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb', line 44

def humanized_name
  _('Upgrade VM Hardware Version')
end

#plan(host) ⇒ Object



14
15
16
17
# File 'app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb', line 14

def plan(host)
  action_subject(host)
  plan_self
end

#rescue_strategyObject



57
58
59
# File 'app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb', line 57

def rescue_strategy
  Dynflow::Action::Rescue::Skip
end

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb', line 19

def run
  host = ::Host.find(input[:host][:id])

  output[:old_hardware_version] = host.vmware_facet.hardware_version

  initially_powered_on = host.power.ready?
  output[:initially_powered_on] = initially_powered_on

  vm = host.compute_object

  if initially_powered_on
    vm.stop
    vm.wait_for { power_state == 'poweredOff' }
    fail _('Could not shut down VM.') if vm.ready?
  end

  vm.vm_upgrade_hardware

  state = host.refresh_vmware_facet!
  output[:state] = state
  output[:new_hardware_version] = host.vmware_facet.hardware_version
ensure
  vm.start if vm && initially_powered_on
end