Class: ForemanWreckingball::VmwareFacet

Inherits:
ApplicationRecord
  • Object
show all
Includes:
Facets::Base
Defined in:
app/models/foreman_wreckingball/vmware_facet.rb

Constant Summary collapse

VALID_GUEST_STATUSES =
[:toolsNotInstalled, :toolsNotRunning, :toolsOk, :toolsOld].freeze
VALID_POWER_STATES =
[:poweredOff, :poweredOn, :suspended].freeze

Instance Method Summary collapse

Instance Method Details

#refresh!Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/models/foreman_wreckingball/vmware_facet.rb', line 40

def refresh!
  vm = host.compute_object
  return unless vm
  data_for_update = {
    vmware_cluster: ::ForemanWreckingball::VmwareCluster.find_by(name: vm.cluster, compute_resource: host.compute_resource),
    cpus: vm.cpus,
    corespersocket: vm.corespersocket,
    memory_mb: vm.memory_mb,
    tools_state: vm.tools_state,
    power_state: vm.power_state,
    guest_id: vm.guest_id,
    cpu_hot_add: vm.cpuHotAddEnabled,
    hardware_version: vm.hardware_version,
    cpu_features: []
  }
  data_for_update[:cpu_features] = raw_vm_object.runtime.featureRequirement.map(&:key) if vm.ready?
  update(data_for_update)
end

#refresh_statusesObject



59
60
61
62
# File 'app/models/foreman_wreckingball/vmware_facet.rb', line 59

def refresh_statuses
  ::HostStatus.wreckingball_statuses.each { |status| host.get_status(status).refresh! }
  host.refresh_global_status!
end

#tools_state_labelObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/foreman_wreckingball/vmware_facet.rb', line 27

def tools_state_label
  case tools_state.to_sym
  when :toolsNotInstalled
    N_('Not installed')
  when :toolsNotRunning
    N_('Not running')
  when :toolsOk
    N_('OK')
  when :toolsOld
    N_('Out of date')
  end
end

#vm_ready?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'app/models/foreman_wreckingball/vmware_facet.rb', line 64

def vm_ready?
  power_state == 'poweredOn'
end