Class: Actions::Foreman::Host::ImportFacts
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from EntryAction
#action_subject, all_action_names, #delay, #drop_all_locks!, serializer_class
#exclusive_lock!, #link!, #lock!
#serialize_args
Methods inherited from Base
#already_running?, #humanized_errors, #humanized_output, #notify_paused, #serializer_class, #task, #task_input, #task_output
included, #sync_execution_plan_to_task
included, #log_task_state_change
Class Method Details
.cleanup_after ⇒ Object
default value for cleaning up the tasks, it can be overriden by settings
51
52
53
|
# File 'app/lib/actions/foreman/host/import_facts.rb', line 51
def self.cleanup_after
'30d'
end
|
Instance Method Details
46
47
48
|
# File 'app/lib/actions/foreman/host/import_facts.rb', line 46
def humanized_input
input[:host] && input[:host][:name]
end
|
#humanized_name ⇒ Object
42
43
44
|
# File 'app/lib/actions/foreman/host/import_facts.rb', line 42
def humanized_name
_('Import facts')
end
|
#plan(_host_type, host_name, facts, certname, proxy_id) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/lib/actions/foreman/host/import_facts.rb', line 9
def plan(_host_type, host_name, facts, certname, proxy_id)
facts['domain'].try(:downcase!)
host = ::Host::Managed.import_host(host_name, certname)
host.save(:validate => false) if host.new_record?
action_subject(host, :facts => facts.to_unsafe_h, :proxy_id => proxy_id)
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
|
#proxy ⇒ Object
34
35
36
|
# File 'app/lib/actions/foreman/host/import_facts.rb', line 34
def proxy
SmartProxy.find_by(id: input[:proxy_id]) if input[:proxy_id].present?
end
|
#rescue_strategy ⇒ Object
38
39
40
|
# File 'app/lib/actions/foreman/host/import_facts.rb', line 38
def rescue_strategy
::Dynflow::Action::Rescue::Skip
end
|
#resource_locks ⇒ Object
5
6
7
|
# File 'app/lib/actions/foreman/host/import_facts.rb', line 5
def resource_locks
:import_facts
end
|
#run ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/lib/actions/foreman/host/import_facts.rb', line 21
def run
::User.as :admin do
host = ::Host.find(input[:host][:id])
state = ::HostFactImporter.new(host).import_facts(input[:facts], proxy)
output[:state] = state
end
rescue ::Foreman::Exception => e
raise e unless e.code == 'ERF51-9911'
end
|