foreman_remote_execution 1.3.4 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0511db7a2c04a4ddd08d45ebfe0d21e03bd8a919
4
- data.tar.gz: 121d18818212309d66f9c20f347c6436b4773c0a
3
+ metadata.gz: f6489b51f165437b41df19831b17dec95a621c62
4
+ data.tar.gz: b77739a1af35d9b92d0a8127496dae9c28139d06
5
5
  SHA512:
6
- metadata.gz: 947a9c319b0cfe8082cd6fc69da05a5d4ffae40b2e5501f5c5aaf8ab2bc4f9b2b354473d4bff53b7599fffeb182395ed4af5b2d39b2934866bccae9b5edc8f79
7
- data.tar.gz: 3168906a4cc1bebf31465ef7b0a786ab093cfa29ef2f1fa6902564c1cfc273856663a6bcbacf3974317abb92f5bbfe574b95fb7d02a2a75f8050c0472c76ccae
6
+ metadata.gz: 0e51d1a704f41a217fb3e55422f371c05ef0e9d1669a8dc07d1bca2f5230a37ed7064f9fa1858b393ad9ccfd1f779e88d97151aa35d5070594536a2c5cc7695e
7
+ data.tar.gz: 26de9c88504a94dcbac54e4b3b5195500568efd8997f5ee751fe0ca040a7a24fcc76ab7759bc78ed18e4eb2bc3865cc8019a3df660fb6ecd1ba2e72707a3bba3
@@ -1,7 +1,14 @@
1
1
  module ForemanRemoteExecution
2
2
  module HostsHelperExtensions
3
- def multiple_actions
4
- super + [ [_('Schedule Remote Job'), new_job_invocation_path, false] ]
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ alias_method_chain(:host_title_actions, :run_button)
7
+ alias_method_chain :multiple_actions, :remote_execution
8
+ end
9
+
10
+ def multiple_actions_with_remote_execution
11
+ multiple_actions_without_remote_execution + [ [_('Schedule Remote Job'), new_job_invocation_path, false] ]
5
12
  end
6
13
 
7
14
  def schedule_job_multi_button(*args)
@@ -20,9 +27,9 @@ module ForemanRemoteExecution
20
27
  link_to(_('Schedule Remote Job'), new_job_invocation_path(:host_ids => [args.first.id]), :id => :run_button, :class => 'btn btn-default')
21
28
  end
22
29
 
23
- def host_title_actions(*args)
30
+ def host_title_actions_with_run_button(*args)
24
31
  title_actions(button_group(schedule_job_multi_button(*args)))
25
- super(*args)
32
+ host_title_actions_without_run_button(*args)
26
33
  end
27
34
  end
28
35
  end
@@ -1,7 +1,13 @@
1
1
  module ForemanRemoteExecution
2
2
  module JobTemplatesExtensions
3
- def permitted_actions(template)
4
- original = super(template)
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ alias_method_chain :permitted_actions, :run_button
7
+ end
8
+
9
+ def permitted_actions_with_run_button(template)
10
+ original = permitted_actions_without_run_button(template)
5
11
 
6
12
  if template.is_a?(JobTemplate)
7
13
  original.unshift(display_link_if_authorized(_('Run'), hash_for_new_job_invocation_path(:template_id => template.id).merge(:authorizer => authorizer))) unless template.snippet
@@ -1,39 +1,44 @@
1
1
  module ForemanRemoteExecution
2
2
  module HostExtensions
3
+ extend ActiveSupport::Concern
4
+
3
5
  # rubocop:disable Metrics/BlockLength
4
- def self.prepended(base)
5
- base.instance_eval do
6
- has_many :targeting_hosts, :dependent => :destroy, :foreign_key => 'host_id'
7
- has_many :template_invocations, :dependent => :destroy, :foreign_key => 'host_id'
8
- has_one :execution_status_object, :class_name => 'HostStatus::ExecutionStatus', :foreign_key => 'host_id'
9
- has_many :run_host_job_tasks, :through => :template_invocations
10
-
11
- scoped_search :relation => :run_host_job_tasks, :on => :result, :rename => 'job_invocation.result',
12
- :ext_method => :search_by_job_invocation,
13
- :only_explicit => true,
14
- :complete_value => TemplateInvocation::TaskResultMap::REVERSE_MAP
15
-
16
- scoped_search :relation => :template_invocations, :on => :job_invocation_id,
17
- :rename => 'job_invocation.id', :only_explicit => true, :ext_method => :search_by_job_invocation
18
-
19
- scoped_search :relation => :execution_status_object, :on => :status, :rename => :execution_status,
20
- :complete_value => { :ok => HostStatus::ExecutionStatus::OK, :error => HostStatus::ExecutionStatus::ERROR }
21
-
22
- def search_by_job_invocation(key, operator, value)
23
- if key == 'job_invocation.result'
24
- operator = operator == '=' ? 'IN' : 'NOT IN'
25
- value = TemplateInvocation::TaskResultMap.status_to_task_result(value)
26
- end
27
-
28
- mapping = {
29
- 'job_invocation.id' => %(#{TemplateInvocation.table_name}.job_invocation_id #{operator} ?),
30
- 'job_invocation.result' => %(#{ForemanTasks::Task.table_name}.result #{operator} (?))
31
- }
32
- {
33
- :conditions => sanitize_sql_for_conditions([mapping[key], value_to_sql(operator, value)]),
34
- :joins => { :template_invocations => [:run_host_job_task] }
35
- }
6
+ included do
7
+ alias_method_chain :build_required_interfaces, :remote_execution
8
+ alias_method_chain :reload, :remote_execution
9
+ alias_method_chain :becomes, :remote_execution
10
+ alias_method_chain :host_params, :remote_execution
11
+
12
+ has_many :targeting_hosts, :dependent => :destroy, :foreign_key => 'host_id'
13
+ has_many :template_invocations, :dependent => :destroy, :foreign_key => 'host_id'
14
+ has_one :execution_status_object, :class_name => 'HostStatus::ExecutionStatus', :foreign_key => 'host_id'
15
+ has_many :run_host_job_tasks, :through => :template_invocations
16
+
17
+ scoped_search :relation => :run_host_job_tasks, :on => :result, :rename => 'job_invocation.result',
18
+ :ext_method => :search_by_job_invocation,
19
+ :only_explicit => true,
20
+ :complete_value => TemplateInvocation::TaskResultMap::REVERSE_MAP
21
+
22
+ scoped_search :relation => :template_invocations, :on => :job_invocation_id,
23
+ :rename => 'job_invocation.id', :only_explicit => true, :ext_method => :search_by_job_invocation
24
+
25
+ scoped_search :relation => :execution_status_object, :on => :status, :rename => :execution_status,
26
+ :complete_value => { :ok => HostStatus::ExecutionStatus::OK, :error => HostStatus::ExecutionStatus::ERROR }
27
+
28
+ def self.search_by_job_invocation(key, operator, value)
29
+ if key == 'job_invocation.result'
30
+ operator = operator == '=' ? 'IN' : 'NOT IN'
31
+ value = TemplateInvocation::TaskResultMap.status_to_task_result(value)
36
32
  end
33
+
34
+ mapping = {
35
+ 'job_invocation.id' => %(#{TemplateInvocation.table_name}.job_invocation_id #{operator} ?),
36
+ 'job_invocation.result' => %(#{ForemanTasks::Task.table_name}.result #{operator} (?))
37
+ }
38
+ {
39
+ :conditions => sanitize_sql_for_conditions([mapping[key], value_to_sql(operator, value)]),
40
+ :joins => { :template_invocations => [:run_host_job_task] }
41
+ }
37
42
  end
38
43
  end
39
44
 
@@ -45,8 +50,8 @@ module ForemanRemoteExecution
45
50
  @execution_status_label ||= get_status(HostStatus::ExecutionStatus).to_label(options)
46
51
  end
47
52
 
48
- def host_params
49
- params = super
53
+ def host_params_with_remote_execution
54
+ params = host_params_without_remote_execution
50
55
  keys = remote_execution_ssh_keys
51
56
  params['remote_execution_ssh_keys'] = keys if keys.present?
52
57
  [:remote_execution_ssh_user, :remote_execution_effective_user_method,
@@ -88,21 +93,21 @@ module ForemanRemoteExecution
88
93
  @execution_interface = nil
89
94
  end
90
95
 
91
- def becomes(*args)
92
- became = super(*args)
96
+ def becomes_with_remote_execution(*args)
97
+ became = becomes_without_remote_execution(*args)
93
98
  became.drop_execution_interface_cache if became.respond_to? :drop_execution_interface_cache
94
99
  became
95
100
  end
96
101
 
97
- def reload(*args)
102
+ def reload_with_remote_execution(*args)
98
103
  drop_execution_interface_cache
99
- super(*args)
104
+ reload_without_remote_execution(*args)
100
105
  end
101
106
 
102
107
  private
103
108
 
104
- def build_required_interfaces(attrs = {})
105
- super(attrs)
109
+ def build_required_interfaces_with_remote_execution(attrs = {})
110
+ build_required_interfaces_without_remote_execution(attrs)
106
111
  self.primary_interface.execution = true if self.execution_interface.nil?
107
112
  end
108
113
  end
@@ -1,5 +1,11 @@
1
1
  module ForemanRemoteExecution
2
2
  module SmartProxyExtensions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ alias_method_chain :refresh, :remote_execution
7
+ end
8
+
3
9
  def pubkey
4
10
  self[:pubkey] || update_pubkey
5
11
  end
@@ -11,8 +17,8 @@ module ForemanRemoteExecution
11
17
  key
12
18
  end
13
19
 
14
- def refresh
15
- errors = super
20
+ def refresh_with_remote_execution
21
+ errors = refresh_without_remote_execution
16
22
  update_pubkey
17
23
  errors
18
24
  end
@@ -148,7 +148,7 @@ module ForemanRemoteExecution
148
148
 
149
149
  User.send(:include, ForemanRemoteExecution::UserExtensions)
150
150
 
151
- Host::Managed.send(:prepend, ForemanRemoteExecution::HostExtensions)
151
+ Host::Managed.send(:include, ForemanRemoteExecution::HostExtensions)
152
152
  Host::Managed.send(:include, ForemanTasks::Concerns::HostActionSubject)
153
153
 
154
154
  (Nic::Base.descendants + [Nic::Base]).each do |klass|
@@ -156,10 +156,10 @@ module ForemanRemoteExecution
156
156
  end
157
157
 
158
158
  Bookmark.send(:include, ForemanRemoteExecution::BookmarkExtensions)
159
- HostsHelper.send(:prepend, ForemanRemoteExecution::HostsHelperExtensions)
160
- ProvisioningTemplatesHelper.send(:prepend, ForemanRemoteExecution::JobTemplatesExtensions)
159
+ HostsHelper.send(:include, ForemanRemoteExecution::HostsHelperExtensions)
160
+ ProvisioningTemplatesHelper.send(:include, ForemanRemoteExecution::JobTemplatesExtensions)
161
161
 
162
- SmartProxy.send(:prepend, ForemanRemoteExecution::SmartProxyExtensions)
162
+ SmartProxy.send(:include, ForemanRemoteExecution::SmartProxyExtensions)
163
163
  Subnet.send(:include, ForemanRemoteExecution::SubnetExtensions)
164
164
 
165
165
  # We need to explicitly force to load the Task model due to Rails loader
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '1.3.4'.freeze
2
+ VERSION = '1.3.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-06 00:00:00.000000000 Z
11
+ date: 2017-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface