Sha256: 1cd57db8485414812a4de5d44c5e86fdf040c68382a80859c6e41d05a79841ad

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

module Actions
  module Foreman
    module Host

      class ImportFacts < Actions::EntryAction

        def resource_locks
          :import_facts
        end

        def plan(host_type, host_name, facts, certname, proxy_id)
          host = ::Host::Base.importHost(host_name, certname, proxy_id)
          action_subject(host, :facts => facts)
          plan_self
        end

        def run
          ::User.as :admin do
            host           = ::Host.find(input[:host][:id])
            state          = host.import_facts(input[:facts])
            output[:state] = state
          end
        rescue ::Foreman::Exception => e
          # This error is what is thrown by Host#ImportHostAndFacts when
          # the Host is in the build state. This can be refactored once
          # issue #3959 is fixed.
          raise e unless e.code == 'ERF51-9911'
        end

        def humanized_name
          _("Import facts")
        end

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

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
foreman-tasks-0.7.1 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.7.0 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.6.15 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.6.14 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.6.13 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.6.12 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.6.11 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.6.10 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.6.9 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.6.8 app/lib/actions/foreman/host/import_facts.rb