foreman_remote_execution 2.0.4 → 2.0.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 +4 -4
- data/.rubocop.yml +8 -24
- data/README.md +8 -0
- data/app/views/job_invocations/_form.html.erb +1 -1
- data/extra/cockpit/foreman-cockpit-session +25 -31
- data/lib/foreman_remote_execution/engine.rb +12 -12
- data/lib/foreman_remote_execution/version.rb +1 -1
- data/locale/action_names.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aba9a7fccd6e4e3833bd7b102ea464e7266947d2b661ed23665588b969ce848
|
4
|
+
data.tar.gz: 037e1902f40fa780a090aca7f0141be58e0a10805afef0ca0ae5ebc3f7675e2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a79d209933c9b81a4f0276e20602241147e442f4060d62afd0eab6ccc1d22a65c5b8e95025abfcb0be013ac5d7857f4ccc3cddbea2abf7b67bc2174d6a572406
|
7
|
+
data.tar.gz: 19e249a6a63c909a36fb89e7f614d0db5224d4c14b6dbff92fc078a5259eba9f9cf8d6d9e852f81bb73e32cd9a773dff5b95c48b21223406a6040e4474639802
|
data/.rubocop.yml
CHANGED
@@ -3,22 +3,25 @@ inherit_from:
|
|
3
3
|
|
4
4
|
AllCops:
|
5
5
|
Exclude:
|
6
|
+
- 'config/routes.rb'
|
7
|
+
- 'node_modules/**'
|
8
|
+
- 'test/**/*'
|
6
9
|
- 'doc/plugins/**'
|
7
10
|
|
8
11
|
Rails:
|
9
12
|
Enabled: true
|
10
13
|
Exclude:
|
11
14
|
- 'lib/foreman_remote_execution_core/**'
|
15
|
+
- 'node_modules/**'
|
12
16
|
|
13
17
|
Rails/Date:
|
14
18
|
Enabled: false
|
15
19
|
|
16
|
-
|
17
|
-
Style/Documentation:
|
20
|
+
Metrics:
|
18
21
|
Enabled: false
|
19
22
|
|
20
|
-
|
21
|
-
|
23
|
+
Style/Documentation:
|
24
|
+
Enabled: false
|
22
25
|
|
23
26
|
Style/TrailingCommaInArrayLiteral:
|
24
27
|
Enabled: false
|
@@ -35,14 +38,10 @@ Naming/AccessorMethodName:
|
|
35
38
|
Style/RedundantSelf:
|
36
39
|
Enabled: false
|
37
40
|
|
38
|
-
Metrics/ClassLength:
|
39
|
-
Max: 500
|
40
|
-
Exclude:
|
41
|
-
- 'test/**/*'
|
42
|
-
|
43
41
|
Naming/FileName:
|
44
42
|
Exclude:
|
45
43
|
- 'db/seeds.d/*'
|
44
|
+
- 'node_modules/font-awesome-sass/lib/font-awesome-sass.rb'
|
46
45
|
|
47
46
|
Style/WordArray:
|
48
47
|
Enabled: false
|
@@ -62,15 +61,6 @@ Style/EachWithObject:
|
|
62
61
|
Style/GuardClause:
|
63
62
|
Enabled: false
|
64
63
|
|
65
|
-
Metrics/BlockLength:
|
66
|
-
Exclude:
|
67
|
-
- 'config/routes.rb'
|
68
|
-
- 'lib/foreman_remote_execution/engine.rb'
|
69
|
-
- 'test/**/*'
|
70
|
-
|
71
|
-
Metrics/ParameterLists:
|
72
|
-
Enabled: false
|
73
|
-
|
74
64
|
Naming/VariableNumber:
|
75
65
|
Enabled: false
|
76
66
|
|
@@ -102,12 +92,6 @@ Style/SafeNavigation:
|
|
102
92
|
Lint/BooleanSymbol:
|
103
93
|
Enabled: false
|
104
94
|
|
105
|
-
Metrics/PerceivedComplexity:
|
106
|
-
Max: 8
|
107
|
-
|
108
|
-
Metrics/AbcSize:
|
109
|
-
Max: 45
|
110
|
-
|
111
95
|
Style/FrozenStringLiteralComment:
|
112
96
|
Enabled: false
|
113
97
|
|
data/README.md
CHANGED
@@ -44,6 +44,14 @@ Because it doesn't really open the outgoing connections, it doesn't need hosts w
|
|
44
44
|
|
45
45
|
Fork and send a Pull Request. Thanks!
|
46
46
|
|
47
|
+
To run Rubocop use the rake task in foreman dir:
|
48
|
+
|
49
|
+
bundle exec rake foreman_remote_execution:rubocop
|
50
|
+
|
51
|
+
Auto correct can be executed directly too:
|
52
|
+
|
53
|
+
bundle exec rubocop ~/work/foreman_remote_execution -a
|
54
|
+
|
47
55
|
## Release Process
|
48
56
|
|
49
57
|
### Pull Translations from Transifex
|
@@ -33,7 +33,7 @@
|
|
33
33
|
<% end %>
|
34
34
|
</span>
|
35
35
|
<%= selectable_f targeting_fields, :bookmark_id, @composer.available_bookmarks.map { |b| [b.name, b.id] }, :selected => @composer.targeting.bookmark_id, :include_blank => true %>
|
36
|
-
<%=
|
36
|
+
<%= autocomplete_f targeting_fields, :search_query, :search_query => @composer.displayed_search_query, :full_path => auto_complete_search_hosts_path %>
|
37
37
|
|
38
38
|
<div class="form-group ">
|
39
39
|
<label class="col-md-2 control-label"><%= _('Resolves to') %></label>
|
@@ -8,7 +8,7 @@ require "yaml"
|
|
8
8
|
# Logging
|
9
9
|
|
10
10
|
LOG = Logger.new($stderr)
|
11
|
-
LOG.formatter = proc { |
|
11
|
+
LOG.formatter = proc { |severity, datetime, progname, msg| "#{severity}: #{msg}\n" }
|
12
12
|
|
13
13
|
def safe_log(format_string, data = nil)
|
14
14
|
if data.is_a? Hash
|
@@ -26,7 +26,7 @@ end
|
|
26
26
|
|
27
27
|
def read_settings
|
28
28
|
settings_path = ENV["FOREMAN_COCKPIT_SETTINGS"] || "/etc/foreman-cockpit/settings.yml"
|
29
|
-
settings = YAML.
|
29
|
+
settings = YAML.safe_load(File.read(settings_path))
|
30
30
|
LOG.level = Logger.const_get(settings.fetch(:log_level, "INFO"))
|
31
31
|
LOG.info("Running foreman-cockpit-session with settings from #{settings_path}:\n#{settings.inspect}")
|
32
32
|
settings
|
@@ -46,7 +46,7 @@ def read_control
|
|
46
46
|
raise ArgumentError, "Invalid frame: invalid size" if size.zero?
|
47
47
|
data = $stdin.read(size)
|
48
48
|
LOG.debug("Received control message #{data.lstrip}")
|
49
|
-
raise ArgumentError, "Invalid frame: too short" if data
|
49
|
+
raise ArgumentError, "Invalid frame: too short" if data.nil? || data.length < size
|
50
50
|
JSON.parse(data)
|
51
51
|
end
|
52
52
|
|
@@ -55,18 +55,16 @@ end
|
|
55
55
|
def send_auth_challenge(challenge)
|
56
56
|
send_control({ "command" => "authorize",
|
57
57
|
"cookie" => "1234", # must be present, but value doesn't matter
|
58
|
-
"challenge" => challenge
|
59
|
-
})
|
58
|
+
"challenge" => challenge})
|
60
59
|
end
|
61
60
|
|
62
61
|
def send_auth_response(response)
|
63
62
|
send_control({ "command" => "authorize",
|
64
|
-
"response" => response
|
65
|
-
})
|
63
|
+
"response" => response})
|
66
64
|
end
|
67
65
|
|
68
66
|
def read_auth_reply
|
69
|
-
cmd = read_control
|
67
|
+
cmd = read_control
|
70
68
|
response = cmd["response"]
|
71
69
|
raise ArgumentError, "Did not receive a valid authorize command" if cmd["command"] != "authorize" || !response
|
72
70
|
response
|
@@ -77,8 +75,7 @@ def exit_with_problem(problem, message, auth_methods)
|
|
77
75
|
send_control({ "command" => "init",
|
78
76
|
"problem" => problem,
|
79
77
|
"message" => message,
|
80
|
-
"auth-method-results" => auth_methods
|
81
|
-
})
|
78
|
+
"auth-method-results" => auth_methods})
|
82
79
|
exit 1
|
83
80
|
end
|
84
81
|
|
@@ -137,7 +134,7 @@ def ssh_read_and_handle_response_header(sock, url, params)
|
|
137
134
|
header = ""
|
138
135
|
loop do
|
139
136
|
line = sock.readline
|
140
|
-
break unless line
|
137
|
+
break unless line && (line != "\r\n")
|
141
138
|
header += line
|
142
139
|
end
|
143
140
|
|
@@ -145,11 +142,11 @@ def ssh_read_and_handle_response_header(sock, url, params)
|
|
145
142
|
status = status_line.split(" ")[1]
|
146
143
|
if status != "101"
|
147
144
|
m = /^Content-Length:[ \t]*([0-9]+)\r?$/i.match(headers_text)
|
148
|
-
if m
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
145
|
+
expected_len = if m
|
146
|
+
m[1].to_i
|
147
|
+
else
|
148
|
+
-1
|
149
|
+
end
|
153
150
|
response = ""
|
154
151
|
while expected_len < 0 || response.length < expected_len
|
155
152
|
begin
|
@@ -162,7 +159,7 @@ def ssh_read_and_handle_response_header(sock, url, params)
|
|
162
159
|
exit_with_problem("access-denied", "The proxy #{url.hostname} does not support web console sessions", nil)
|
163
160
|
elsif status[0] == "4"
|
164
161
|
if response.include? "cockpit-bridge: command not found"
|
165
|
-
exit_with_problem("access-denied", "#{params[
|
162
|
+
exit_with_problem("access-denied", "#{params['hostname']} has no web console", nil)
|
166
163
|
else
|
167
164
|
exit_with_problem("access-denied", response, nil)
|
168
165
|
end
|
@@ -191,16 +188,14 @@ def ssh_read_sock(sock)
|
|
191
188
|
end
|
192
189
|
|
193
190
|
def ssh_write_sock(sock, data)
|
194
|
-
begin
|
195
191
|
sock.write_nonblock(data)
|
196
|
-
|
192
|
+
rescue IO::WaitWritable
|
197
193
|
0
|
198
|
-
|
194
|
+
rescue IO::WaitReadable
|
199
195
|
# This might happen with SSL during a renegotiation. Block a
|
200
196
|
# bit to get it over with.
|
201
197
|
IO.select([sock])
|
202
198
|
retry
|
203
|
-
end
|
204
199
|
end
|
205
200
|
|
206
201
|
def ssh_with_proxy(proxy, params)
|
@@ -208,7 +203,7 @@ def ssh_with_proxy(proxy, params)
|
|
208
203
|
LOG.debug("Connecting to proxy at #{url}")
|
209
204
|
raw_sock = TCPSocket.open(url.hostname, url.port)
|
210
205
|
if url.scheme == 'https'
|
211
|
-
ssl_context = OpenSSL::SSL::SSLContext.new
|
206
|
+
ssl_context = OpenSSL::SSL::SSLContext.new
|
212
207
|
ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(SETTINGS[:ssl_certificate]))
|
213
208
|
ssl_context.key = OpenSSL::PKey.read(File.read(SETTINGS[:ssl_private_key]))
|
214
209
|
sock = OpenSSL::SSL::SSLSocket.new(raw_sock, ssl_context)
|
@@ -253,7 +248,7 @@ def ssh_with_proxy(proxy, params)
|
|
253
248
|
begin
|
254
249
|
n = ssh_write_sock(sock, inp_buf)
|
255
250
|
inp_buf = inp_buf[n..-1]
|
256
|
-
raw_sock.close_write
|
251
|
+
raw_sock.close_write if (inp_buf == "") && ws_eof
|
257
252
|
end
|
258
253
|
end
|
259
254
|
|
@@ -262,16 +257,15 @@ def ssh_with_proxy(proxy, params)
|
|
262
257
|
inp_buf += $stdin.readpartial(4096)
|
263
258
|
rescue EOFError
|
264
259
|
ws_eof = true
|
265
|
-
raw_sock.close_write
|
260
|
+
raw_sock.close_write if inp_buf == ""
|
266
261
|
end
|
267
262
|
end
|
268
263
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
end
|
264
|
+
next unless w.include?($stdout)
|
265
|
+
n = $stdout.write(out_buf)
|
266
|
+
$stdout.flush
|
267
|
+
out_buf = out_buf[n..-1]
|
268
|
+
break if (out_buf == "") && bridge_eof
|
275
269
|
|
276
270
|
end
|
277
271
|
end
|
@@ -283,7 +277,7 @@ SETTINGS = read_settings
|
|
283
277
|
host = ARGV[0]
|
284
278
|
|
285
279
|
send_auth_challenge("*")
|
286
|
-
token = get_token_from_auth_data(read_auth_reply
|
280
|
+
token = get_token_from_auth_data(read_auth_reply)
|
287
281
|
|
288
282
|
params = foreman_call("cockpit/host_ssh_params/#{host}", token)
|
289
283
|
exit_with_problem("access-denied", "Host #{host} is not known", nil) unless params
|
@@ -157,32 +157,32 @@ module ForemanRemoteExecution
|
|
157
157
|
# ProvisioningTemplate.reflect_on_association :template_inputs # => nil
|
158
158
|
require_dependency 'job_template'
|
159
159
|
(Template.descendants + [Template]).each { |klass| klass.send(:include, ForemanRemoteExecution::TemplateExtensions) }
|
160
|
-
Template.
|
160
|
+
Template.prepend ForemanRemoteExecution::TemplateOverrides
|
161
161
|
|
162
162
|
(Taxonomy.descendants + [Taxonomy]).each { |klass| klass.send(:include, ForemanRemoteExecution::TaxonomyExtensions) }
|
163
163
|
|
164
|
-
User.
|
164
|
+
User.include ForemanRemoteExecution::UserExtensions
|
165
165
|
|
166
|
-
Host::Managed.
|
167
|
-
Host::Managed.
|
166
|
+
Host::Managed.prepend ForemanRemoteExecution::HostExtensions
|
167
|
+
Host::Managed.include ForemanTasks::Concerns::HostActionSubject
|
168
168
|
|
169
169
|
(Nic::Base.descendants + [Nic::Base]).each do |klass|
|
170
170
|
klass.send(:include, ForemanRemoteExecution::NicExtensions)
|
171
171
|
end
|
172
172
|
|
173
|
-
Bookmark.
|
174
|
-
HostsHelper.
|
175
|
-
ProvisioningTemplatesHelper.
|
176
|
-
TemplateInput.
|
173
|
+
Bookmark.include ForemanRemoteExecution::BookmarkExtensions
|
174
|
+
HostsHelper.prepend ForemanRemoteExecution::HostsHelperExtensions
|
175
|
+
ProvisioningTemplatesHelper.prepend ForemanRemoteExecution::JobTemplatesExtensions
|
176
|
+
TemplateInput.include ForemanRemoteExecution::TemplateInputExtensions
|
177
177
|
|
178
|
-
SmartProxy.
|
179
|
-
Subnet.
|
178
|
+
SmartProxy.prepend ForemanRemoteExecution::SmartProxyExtensions
|
179
|
+
Subnet.include ForemanRemoteExecution::SubnetExtensions
|
180
180
|
|
181
181
|
# We need to explicitly force to load the Task model due to Rails loader
|
182
182
|
# having issues with resolving it to Rake::Task otherwise
|
183
183
|
require_dependency 'foreman_tasks/task'
|
184
|
-
ForemanTasks::Task.
|
185
|
-
ForemanTasks::Cleaner.
|
184
|
+
ForemanTasks::Task.include ForemanRemoteExecution::ForemanTasksTaskExtensions
|
185
|
+
ForemanTasks::Cleaner.include ForemanRemoteExecution::ForemanTasksCleanerExtensions
|
186
186
|
RemoteExecutionProvider.register(:SSH, SSHExecutionProvider)
|
187
187
|
|
188
188
|
ForemanRemoteExecution.register_rex_feature
|
data/locale/action_names.rb
CHANGED
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: 2.0.
|
4
|
+
version: 2.0.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: 2019-
|
11
|
+
date: 2019-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|