Sha256: 2e072d635784a54cf56f25966d0df2f3b2be27a17dbfc69e574b7f01642dedcd

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 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)
        end

        def run
          ::User.as :admin do
            host           = ::Host.find(input[:host][:id])
            state          = host.importFacts(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

9 entries across 9 versions & 1 rubygems

Version Path
foreman-tasks-0.2.2 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.2.1 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.2.0 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.1.5 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.1.4 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.1.3 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.1.2 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.1.1 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.1.0 app/lib/actions/foreman/host/import_facts.rb