Sha256: 955bb5f82016d9d637433087bacc804ee8b8fb69ed8fa180845aa5871ff4c469

Contents?: true

Size: 1.43 KB

Versions: 50

Compression:

Stored size: 1.43 KB

Contents

module Actions
  module Katello
    module Host
      class Hypervisors < Actions::EntryAction
        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

        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

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

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
katello-3.12.3 app/lib/actions/katello/host/hypervisors.rb
katello-3.12.2 app/lib/actions/katello/host/hypervisors.rb
katello-3.13.0.rc1 app/lib/actions/katello/host/hypervisors.rb
katello-3.12.1 app/lib/actions/katello/host/hypervisors.rb
katello-3.11.2 app/lib/actions/katello/host/hypervisors.rb
katello-3.10.2 app/lib/actions/katello/host/hypervisors.rb
katello-3.12.0 app/lib/actions/katello/host/hypervisors.rb
katello-3.12.0.rc2 app/lib/actions/katello/host/hypervisors.rb
katello-3.10.1.1 app/lib/actions/katello/host/hypervisors.rb
katello-3.12.0.rc1 app/lib/actions/katello/host/hypervisors.rb
katello-3.10.1 app/lib/actions/katello/host/hypervisors.rb
katello-3.11.1 app/lib/actions/katello/host/hypervisors.rb
katello-3.11.0 app/lib/actions/katello/host/hypervisors.rb
katello-3.11.0.rc2 app/lib/actions/katello/host/hypervisors.rb
katello-3.11.0.rc1 app/lib/actions/katello/host/hypervisors.rb
katello-3.10.0 app/lib/actions/katello/host/hypervisors.rb
katello-3.10.0.rc1.1 app/lib/actions/katello/host/hypervisors.rb
katello-3.9.1 app/lib/actions/katello/host/hypervisors.rb
katello-3.10.0.rc1 app/lib/actions/katello/host/hypervisors.rb
katello-3.9.0 app/lib/actions/katello/host/hypervisors.rb