foreman_remote_execution 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 692272aa7e7c8d5bc38a8bcf9373d387dcdff4afa82709909bf77d389b29edee
4
- data.tar.gz: 0c3e0531fb299378345f13bc4d7b4bc870cf7d659ba84e0363c283ca974b32b7
2
+ SHA1:
3
+ metadata.gz: 25f04758b068647b6124cb3285bcb3f98ab130f5
4
+ data.tar.gz: 29f20e013ea7b9f19afe485faf1fafdb0f51fc56
5
5
  SHA512:
6
- metadata.gz: 724ac1dd282ba907819d8adde27ad8ba8eab5aa1aceb5ecaaeaeba7fedf9c05087b4fa42522ec669db28e398f18d397d45c05c005f9c2a40bfe6a090d2ed790e
7
- data.tar.gz: f3a9a2b127a21c8bebb0e3955d314ea57b829b4588347bbc93c3ffb51e90579eed00990143799243a9958c5339428f884f6258ed687e12bf5f12f6f70097698a
6
+ metadata.gz: ca420660d4db7e9af501f77b6ec8083b2b1014eaf0316bb887179cc491076b3eb6cbe13b255d4e868664e290c7cda18dda1d035d53d577c4f86c2ce4daf844cd
7
+ data.tar.gz: fa0e3c67c6a03f9afb9084b78c8c4c5666c9d217b1be33c6944fcde3eee2a86d278433c5c8f1d3d72563b389e651ecb60453facbcae4d7302ca5057a672fbce0
@@ -1,4 +1,7 @@
1
1
  class RemoteExecutionProvider
2
+
3
+ EFFECTIVE_USER_METHODS = %w[sudo su].freeze
4
+
2
5
  class << self
3
6
  def provider_for(type)
4
7
  providers[type.to_s] || providers[:SSH]
@@ -27,5 +30,47 @@ class RemoteExecutionProvider
27
30
  def supports_effective_user?
28
31
  false
29
32
  end
33
+
34
+ def effective_user(template_invocation)
35
+ template_invocation.effective_user
36
+ end
37
+
38
+ def effective_user_method(host)
39
+ method = host_setting(host, :remote_execution_effective_user_method)
40
+ unless EFFECTIVE_USER_METHODS.include?(method)
41
+ raise _('Effective user method "%{current_value}" is not one of %{valid_methods}') %
42
+ { :current_value => method, :valid_methods => EFFECTIVE_USER_METHODS}
43
+ end
44
+ method
45
+ end
46
+
47
+ def effective_interfaces(host)
48
+ interfaces = []
49
+ %w(execution primary provision).map do |flag|
50
+ interfaces << host.send(flag + '_interface')
51
+ end
52
+ interfaces.compact.uniq
53
+ end
54
+
55
+ def find_ip_or_hostname(host)
56
+ interfaces = effective_interfaces(host)
57
+ if host_setting(host, :remote_execution_connect_by_ip)
58
+ ip_interface = interfaces.find { |i| i.ip.present? }
59
+ end
60
+ if ip_interface
61
+ ip_interface.ip
62
+ else
63
+ fqdn_interface = interfaces.find { |i| i.fqdn.present? }
64
+ if fqdn_interface
65
+ fqdn_interface.fqdn
66
+ else
67
+ raise _('Could not find any suitable interface for execution')
68
+ end
69
+ end
70
+ end
71
+
72
+ def host_setting(host, setting)
73
+ host.params[setting.to_s] || Setting[setting]
74
+ end
30
75
  end
31
76
  end
@@ -1,7 +1,4 @@
1
1
  class SSHExecutionProvider < RemoteExecutionProvider
2
-
3
- EFFECTIVE_USER_METHODS = %w[sudo su].freeze
4
-
5
2
  class << self
6
3
  def proxy_command_options(template_invocation, host)
7
4
  super.merge(:ssh_user => ssh_user(host),
@@ -18,23 +15,6 @@ class SSHExecutionProvider < RemoteExecutionProvider
18
15
  true
19
16
  end
20
17
 
21
- def find_ip_or_hostname(host)
22
- interfaces = effective_interfaces(host)
23
- if host_setting(host, :remote_execution_connect_by_ip)
24
- ip_interface = interfaces.find { |i| i.ip.present? }
25
- end
26
- if ip_interface
27
- ip_interface.ip
28
- else
29
- fqdn_interface = interfaces.find { |i| i.fqdn.present? }
30
- if fqdn_interface
31
- fqdn_interface.fqdn
32
- else
33
- raise _('Could not find any suitable interface for execution')
34
- end
35
- end
36
- end
37
-
38
18
  private
39
19
 
40
20
  def ssh_user(host)
@@ -44,30 +24,5 @@ class SSHExecutionProvider < RemoteExecutionProvider
44
24
  def ssh_port(host)
45
25
  Integer(host_setting(host, :remote_execution_ssh_port))
46
26
  end
47
-
48
- def effective_user(template_invocation)
49
- template_invocation.effective_user
50
- end
51
-
52
- def effective_user_method(host)
53
- method = host_setting(host, :remote_execution_effective_user_method)
54
- unless EFFECTIVE_USER_METHODS.include?(method)
55
- raise _('Effective user method "%{current_value}" is not one of %{valid_methods}') %
56
- { :current_value => method, :valid_methods => EFFECTIVE_USER_METHODS}
57
- end
58
- method
59
- end
60
-
61
- def effective_interfaces(host)
62
- interfaces = []
63
- %w(execution primary provision).map do |flag|
64
- interfaces << host.send(flag + '_interface')
65
- end
66
- interfaces.compact.uniq
67
- end
68
-
69
- def host_setting(host, setting)
70
- host.params[setting.to_s] || Setting[setting]
71
- end
72
27
  end
73
28
  end
@@ -1,19 +1,9 @@
1
1
  class AddExecutionToInterface < ActiveRecord::Migration[4.2]
2
- class FakeNic < ApplicationRecord
3
- self.table_name = 'nics'
4
-
5
- def type
6
- Nic::Managed
7
- end
8
- end
9
-
10
2
  def up
11
3
  add_column :nics, :execution, :boolean, :default => false
12
4
 
13
- FakeNic.reset_column_information
14
- FakeNic.all.each do |nic|
15
- nic.update_column(:execution, true) if nic.primary
16
- end
5
+ Nic::Managed.reset_column_information
6
+ Nic::Managed.where(primary: true).update_all(execution: true)
17
7
  end
18
8
 
19
9
  def down
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '1.4.2'.freeze
2
+ VERSION = '1.4.3'.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.4.2
4
+ version: 1.4.3
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: 2018-01-22 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -373,7 +373,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
373
373
  version: '0'
374
374
  requirements: []
375
375
  rubyforge_project:
376
- rubygems_version: 2.7.3
376
+ rubygems_version: 2.6.8
377
377
  signing_key:
378
378
  specification_version: 4
379
379
  summary: A plugin bringing remote execution to the Foreman, completing the config