foreman_remote_execution 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +3 -0
  3. data/app/controllers/api/v2/template_invocations_controller.rb +46 -0
  4. data/app/controllers/job_invocations_controller.rb +6 -0
  5. data/app/models/job_invocation_composer.rb +5 -1
  6. data/app/models/remote_execution_provider.rb +1 -1
  7. data/app/views/api/v2/template_invocations/base.json.rabl +5 -0
  8. data/app/views/api/v2/template_invocations/template_invocations.json.rabl +3 -0
  9. data/app/views/job_invocations/welcome.html.erb +14 -0
  10. data/app/views/template_invocations/show.html.erb +10 -1
  11. data/config/routes.rb +1 -0
  12. data/db/seeds.d/70-job_templates.rb +5 -1
  13. data/foreman_remote_execution.gemspec +1 -0
  14. data/lib/foreman_remote_execution/engine.rb +2 -0
  15. data/lib/foreman_remote_execution/version.rb +1 -1
  16. data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  17. data/locale/de/foreman_remote_execution.po +165 -27
  18. data/locale/en/foreman_remote_execution.po +161 -23
  19. data/locale/en_GB/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  20. data/locale/en_GB/foreman_remote_execution.po +162 -24
  21. data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  22. data/locale/es/foreman_remote_execution.po +165 -27
  23. data/locale/foreman_remote_execution.pot +282 -189
  24. data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  25. data/locale/fr/foreman_remote_execution.po +165 -27
  26. data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  27. data/locale/ja/foreman_remote_execution.po +165 -27
  28. data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  29. data/locale/ko/foreman_remote_execution.po +165 -27
  30. data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  31. data/locale/pt_BR/foreman_remote_execution.po +165 -27
  32. data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  33. data/locale/ru/foreman_remote_execution.po +165 -27
  34. data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  35. data/locale/zh_CN/foreman_remote_execution.po +165 -27
  36. data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  37. data/locale/zh_TW/foreman_remote_execution.po +165 -27
  38. data/test/functional/api/v2/template_invocations_controller_test.rb +33 -0
  39. data/test/unit/remote_execution_provider_test.rb +6 -1
  40. metadata +11 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: cee9f09b684c8a829284e5eef226b75d241e91a3622fbad2f1626ff75855c812
4
- data.tar.gz: 160de6767048860228ab7007394d548d937d757d8f19f3cd401e1257b96950ad
2
+ SHA1:
3
+ metadata.gz: 4f9842eca9c6a28b109c5e9b7056a362908a8463
4
+ data.tar.gz: 8cf8bfd85fd584a9e18b756c4d7cf0d9e4adcc4c
5
5
  SHA512:
6
- metadata.gz: c4c7c5c3a2d9173defa65b8a9fa81de541698345a623cf870f76f70a6c83792f8ecf9a70939f103fb78b0ef5fc4e8dd763bfd541df46f965bfbe532aa1cee9e8
7
- data.tar.gz: 9311306fda1292ff48856e6f3c05808c61f89154f07491071f9e71bafbf089b13f18ef128749ad0c8726005d4f8d0658bc551ecacd3960d069fdce16387b485d
6
+ metadata.gz: 720b43d0d18f4521e329f0a690b8482048ee07297cf78ec6057bf20c05fe7c8da79d68f77406fbf637138d298fc4c68e3f4883df36916c36d4236e2e9e8e21c8
7
+ data.tar.gz: 5e2bd57fd39c8ecd7b09eb1ecca377edf608e8dd50007c9995af78a2f68b7828337582ea036b6dda37bdddf5f3e6bee2496cb8d75e9eb323c2bfad2937f0efd3
data/.rubocop.yml CHANGED
@@ -105,3 +105,6 @@ Metrics/PerceivedComplexity:
105
105
 
106
106
  Metrics/AbcSize:
107
107
  Max: 45
108
+
109
+ Style/FrozenStringLiteralComment:
110
+ Enabled: false
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Api
4
+ module V2
5
+ class TemplateInvocationsController < ::Api::V2::BaseController
6
+
7
+ before_action :find_job_invocation, :only => %w{template_invocations}
8
+
9
+ api :GET, '/job_invocations/:job_invocation_id/template_invocations',
10
+ N_('List template invocations belonging to job invocation')
11
+ param_group :search_and_pagination, ::Api::V2::BaseController
12
+ param :job_invocation_id, :identifier, :required => true
13
+ def template_invocations
14
+ @template_invocations = resource_scope.paginate(paginate_options)
15
+ render :layout => 'api/v2/layouts/index_layout'
16
+ end
17
+
18
+ def resource_scope
19
+ if params[:action] == 'template_invocations'
20
+ resource_scope_for_template_invocations
21
+ else
22
+ super
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def resource_scope_for_template_invocations
29
+ @job_invocation.template_invocations.search_for(*search_options)
30
+ end
31
+
32
+ def find_job_invocation
33
+ @job_invocation = JobInvocation.find(params[:id])
34
+ end
35
+
36
+ def action_permission
37
+ case params[:action]
38
+ when 'template_invocations'
39
+ :view
40
+ else
41
+ super
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -13,6 +13,12 @@ class JobInvocationsController < ApplicationController
13
13
  :bookmark_id => params[:bookmark_id]
14
14
  }
15
15
  }
16
+ # replace an empty string search with a dummy search query to match all hosts
17
+ # but only if search query was entered (based on presence of :search parameter)
18
+ if params.key?(:search)
19
+ query = params[:search].empty? ? "name != ''" : params[:search]
20
+ ui_params[:targeting].update(:search_query => query)
21
+ end
16
22
 
17
23
  if (template = JobTemplate.find_by(id: params[:template_id]))
18
24
  ui_params[:job_invocation] = {
@@ -8,7 +8,7 @@ class JobInvocationComposer
8
8
 
9
9
  def params
10
10
  { :job_category => job_invocation_base[:job_category],
11
- :targeting => ui_params.fetch(:targeting, {}).merge(:user_id => User.current.id),
11
+ :targeting => targeting(ui_params.fetch(:targeting, {})),
12
12
  :triggering => triggering,
13
13
  :host_ids => ui_params[:host_ids],
14
14
  :remote_execution_feature_id => job_invocation_base[:remote_execution_feature_id],
@@ -82,6 +82,10 @@ class JobInvocationComposer
82
82
  return trig unless trig.key?(:end_time) && trig[:end_time].keys == keys
83
83
  trig.merge(:end_time => Time.local(*trig[:end_time].values_at(*keys)))
84
84
  end
85
+
86
+ def targeting(targeting_params)
87
+ targeting_params.merge(:user_id => User.current.id)
88
+ end
85
89
  end
86
90
 
87
91
  class ApiParams
@@ -1,6 +1,6 @@
1
1
  class RemoteExecutionProvider
2
2
 
3
- EFFECTIVE_USER_METHODS = %w[sudo su].freeze
3
+ EFFECTIVE_USER_METHODS = %w[sudo dzdo su].freeze
4
4
 
5
5
  class << self
6
6
  def provider_for(type)
@@ -0,0 +1,5 @@
1
+ object @template_invocation
2
+
3
+ attributes :id, :template_id, :job_invocation_id, :effective_user, :host_id, :run_host_job_task_id
4
+
5
+ node(:host_name) { |ti| ti.host.name }
@@ -0,0 +1,3 @@
1
+ collection @template_invocations
2
+
3
+ extends 'api/v2/template_invocations/base'
@@ -0,0 +1,14 @@
1
+ <div class="blank-slate-pf">
2
+ <div class="blank-slate-pf-icon">
3
+ <%= icon_text("globe", "", :kind => "fa") %>
4
+ </div>
5
+ <h1><%= _('Job Invocations') %></h1>
6
+ <p>
7
+ <%= _("Foreman can run arbitrary commands on remote hosts using different providers, such as SSH or Ansible. Communication goes through the Smart Proxy so Foreman does not have to have direct access to the target hosts and can scale to control many hosts.") %></br>
8
+ </p>
9
+ <p><%= link_to _('Learn more about this in the documentation.'),
10
+ documentation_url('1.ForemanRemoteExecution1.3Manual', :root_url => 'https://www.theforeman.org/plugins/foreman_remote_execution/1.3/index.html#'), :rel => 'external' %></p>
11
+ <div class="blank-slate-pf-main-action">
12
+ <%= new_link(_("Run Job"), {}, { :class => "btn-lg" }) %>
13
+ </div>
14
+ </div>
@@ -1,4 +1,13 @@
1
- <% title _('Detail of %s run') % @template_invocation.job_invocation.job_category %>
1
+ <% items = [{ :caption => @template_invocation.job_invocation.description,
2
+ :url => job_invocation_path(@template_invocation.job_invocation_id) },
3
+ { :caption => _('Template Invocation for %s') % @template_invocation.host.name }] %>
4
+
5
+ <% breadcrumbs(:resource_url => template_invocations_api_job_invocation_path(@template_invocation.job_invocation_id),
6
+ :name_field => 'host_name',
7
+ :switcher_item_url => template_invocation_path(':id'),
8
+ :items => items)
9
+ %>
10
+
2
11
  <% stylesheet 'foreman_remote_execution/template_invocation' %>
3
12
  <% javascript 'foreman_remote_execution/template_invocation' %>
4
13
 
data/config/routes.rb CHANGED
@@ -47,6 +47,7 @@ Rails.application.routes.draw do
47
47
  member do
48
48
  post 'cancel'
49
49
  post 'rerun'
50
+ get 'template_invocations', :to => 'template_invocations#template_invocations'
50
51
  end
51
52
  end
52
53
 
@@ -1,8 +1,12 @@
1
+ organizations = Organization.unscoped.all
2
+ locations = Location.unscoped.all
1
3
  User.as_anonymous_admin do
2
4
  JobTemplate.without_auditing do
3
5
  Dir[File.join("#{ForemanRemoteExecution::Engine.root}/app/views/templates/**/*.erb")].each do |template|
4
6
  sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
5
- JobTemplate.import_raw!(File.read(template), :default => true, :locked => true, :update => sync)
7
+ template = JobTemplate.import_raw!(File.read(template), :default => true, :locked => true, :update => sync)
8
+ template.organizations = organizations if SETTINGS[:organizations_enabled] && template.present?
9
+ template.locations = locations if SETTINGS[:locations_enabled] && template.present?
6
10
  end
7
11
  end
8
12
  end
@@ -4,6 +4,7 @@ require 'date'
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'foreman_remote_execution'
6
6
  s.version = ForemanRemoteExecution::VERSION
7
+ s.license = 'GPL-3.0'
7
8
  s.date = Date.today.to_s
8
9
  s.authors = ['Foreman Remote Execution team']
9
10
  s.email = ['foreman-dev@googlegroups.com']
@@ -59,6 +59,8 @@ module ForemanRemoteExecution
59
59
  'api/v2/job_invocations' => [:create, :rerun] }, :resource_type => 'JobInvocation'
60
60
  permission :view_job_invocations, { :job_invocations => [:index, :chart, :show, :auto_complete_search], :template_invocations => [:show],
61
61
  'api/v2/job_invocations' => [:index, :show, :output] }, :resource_type => 'JobInvocation'
62
+ permission :view_template_invocations, { :template_invocations => [:show],
63
+ 'api/v2/template_invocations' => [:template_invocations] }, :resource_type => 'TemplateInvocation'
62
64
  permission :create_template_invocations, {}, :resource_type => 'TemplateInvocation'
63
65
  permission :cancel_job_invocations, { :job_invocations => [:cancel], 'api/v2/job_invocations' => [:cancel] }, :resource_type => 'JobInvocation'
64
66
  # this permissions grants user to get auto completion hints when setting up filters
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '1.5.2'.freeze
2
+ VERSION = '1.5.3'.freeze
3
3
  end