Sha256: 52c8b98af818f3a7c61d6971e35a9ae895b81cec62a53469a345a3f216d18aa5

Contents?: true

Size: 1.49 KB

Versions: 12

Compression:

Stored size: 1.49 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)
          facts['domain'].try(:downcase!)
          host = ::Host::Base.import_host(host_name, certname, facts, proxy_id)
          action_subject(host, :facts => facts)
          if host.build?
            ::Foreman::Logging.logger('foreman-tasks').info "Skipping importing of facts for #{host.name} because it's in build mode"
          else
            plan_self
          end
        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 rescue_strategy
          ::Dynflow::Action::Rescue::Skip
        end

        def humanized_name
          _("Import facts")
        end

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

        # default value for cleaning up the tasks, it can be overriden by settings
        def self.cleanup_after
          '30d'
        end

      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
foreman-tasks-0.8.6 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.8.5 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.8.4 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.8.3 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.8.2 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.8.1 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.8.0 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.7.20 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.7.19 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.7.18 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.7.17 app/lib/actions/foreman/host/import_facts.rb
foreman-tasks-0.7.16 app/lib/actions/foreman/host/import_facts.rb