Class: Actions::Katello::Host::Hypervisors

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse_hypervisors(hypervisor_results) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/lib/actions/katello/host/hypervisors.rb', line 24

def self.parse_hypervisors(hypervisor_results)
  hypervisors = []
  %w(created updated unchanged).each do |group|
    if hypervisor_results[group]
      hypervisors += hypervisor_results[group].map do |hypervisor|
        {
          :name => hypervisor['name'],
          :uuid => hypervisor['uuid'],
          :organization_label => hypervisor['owner']['key']
        }
      end
    end
  end
  hypervisors
end

Instance Method Details

#plan(hypervisor_params, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/lib/actions/katello/host/hypervisors.rb', line 9

def plan(hypervisor_params, options = {})
  task_id = options.fetch(:task_id, nil)
  sequence do
    if task_id
      task_output = plan_action(Candlepin::AsyncHypervisors, :task_id => task_id).output
      parsed_response = task_output[:hypervisors]
    elsif hypervisor_params
      hypervisor_results = ::Katello::Resources::Candlepin::Consumer.register_hypervisors(hypervisor_params)
      parsed_response = Hypervisors.parse_hypervisors(hypervisor_results)
    end
    plan_self(:hypervisors => parsed_response)
    plan_action(Katello::Host::HypervisorsUpdate, :hypervisors => parsed_response)
  end
end

#queueObject



5
6
7
# File 'app/lib/actions/katello/host/hypervisors.rb', line 5

def queue
  ::Katello::HOST_TASKS_QUEUE
end

#rescue_strategyObject



40
41
42
# File 'app/lib/actions/katello/host/hypervisors.rb', line 40

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