Module: ForemanRemoteExecution::HostsHelperExtensions
- Defined in:
- app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
Instance Method Summary collapse
- #can_execute_on_host?(host) ⇒ Boolean
- #can_execute_on_infrastructure_host?(host) ⇒ Boolean
- #can_schedule_jobs? ⇒ Boolean
- #host_overview_buttons(host) ⇒ Object
- #host_title_actions(*args) ⇒ Object
- #multiple_actions ⇒ Object
- #rex_host_features(host, *_rest) ⇒ Object
- #schedule_job_button(host, *_rest) ⇒ Object
- #schedule_job_multi_button(*args) ⇒ Object
- #web_console_button(host, *args) ⇒ Object
Instance Method Details
#can_execute_on_host?(host) ⇒ Boolean
54 55 56 |
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 54 def can_execute_on_host?(host) can_schedule_jobs? && can_execute_on_infrastructure_host?(host) end |
#can_execute_on_infrastructure_host?(host) ⇒ Boolean
58 59 60 |
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 58 def can_execute_on_infrastructure_host?(host) !host.infrastructure_host? || User.current.can?(:execute_jobs_on_infrastructure_hosts) end |
#can_schedule_jobs? ⇒ Boolean
50 51 52 |
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 50 def can_schedule_jobs? (controller: :job_invocations, action: :create) end |
#host_overview_buttons(host) ⇒ Object
3 4 5 6 7 |
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 3 def (host) [ { :button => (_("Jobs"), hash_for_job_invocations_path(search: "host=#{host.name}"), :title => _("Job invocations"), :class => 'btn btn-default'), :priority => 200 }, ] end |
#host_title_actions(*args) ⇒ Object
44 45 46 47 48 |
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 44 def host_title_actions(*args) title_actions(((*args)), ((*args))) super(*args) end |
#multiple_actions ⇒ Object
9 10 11 12 13 |
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 9 def multiple_actions res = super res += [ [_('Schedule Remote Job'), new_job_invocation_path, false] ] if can_schedule_jobs? res end |
#rex_host_features(host, *_rest) ⇒ Object
25 26 27 28 29 30 |
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 25 def rex_host_features(host, *_rest) return [] unless can_execute_on_host?(host) RemoteExecutionFeature..order(:label).map do |feature| link_to(_('%s') % feature.name, job_invocations_path(:host_ids => [host.id], :feature => feature.label), :method => :post) end end |
#schedule_job_button(host, *_rest) ⇒ Object
32 33 34 35 |
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 32 def (host, *_rest) return unless can_execute_on_host?(host) link_to(_('Schedule Remote Job'), new_job_invocation_path(:host_ids => [host.id]), :id => :run_button, :class => 'btn btn-default') end |
#schedule_job_multi_button(*args) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 15 def (*args) host_features = rex_host_features(*args) if host_features.present? ((*args), *host_features) else (*args) end end |
#web_console_button(host, *args) ⇒ Object
37 38 39 40 41 42 |
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 37 def (host, *args) return if !(permission: 'cockpit_hosts', auth_object: host) || !can_execute_on_infrastructure_host?(host) url = SSHExecutionProvider.cockpit_url_for_host(host.name) url ? link_to(_('Web Console'), url, :class => 'btn btn-default', :id => :'web-console-button', :target => '_new') : nil end |