Class: Actions::Katello::Host::HypervisorsUpdate

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

Instance Method Summary collapse

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/lib/actions/katello/host/hypervisors_update.rb', line 11

def run
  output[:results] = input[:results]
  @hypervisors = input[:hypervisors]
  return unless @hypervisors

  @duplicate_uuid_hypervisors = {}

  User.as_anonymous_admin do
    ActiveRecord::Base.transaction do
      load_resources
    end

    load_hosts_guests

    ActiveRecord::Base.transaction do
      @hosts.each do |uuid, host|
        update_host(uuid, host)
      end
    end

    @hosts.each do |uuid, host|
      update_facts(uuid, host)
    end
  end

  @duplicate_uuid_hypervisors.each do |hypervisor, existing_host|
    fail _("Host creation was skipped for %s because it shares a BIOS UUID with %s. " \
           "To report this hypervisor, override its dmi.system.uuid fact or set 'candlepin.use_system_uuid_for_matching' " \
           "to 'true' in the Candlepin configuration." % [hypervisor[:name], existing_host.name])
  end
end