smart_proxy_discovery_image 1.1.0 → 1.3.2
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
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06fb066da89eca96661970388bb0588b3076f00689879ff7ece68105b30fcc85
|
4
|
+
data.tar.gz: 187d75b1483efebe1bdae04712313feb6f3476d881c6e090274f676ad930e55d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b34e23f7f4feef89fa9ddbd02614e3bab7c1e14fc54a5ea204ac0b430b27855e1ac4bda0bbf1b94fcf55c8599c74a2103e4b48644f58be97cc8564b8c0a481ed
|
7
|
+
data.tar.gz: f07f7622707f201e003f65f3e98b0cbb94aa380115d05ca08561b44d16820570dc47409a3db12e4dda6a7509601de200666ad91713d598720f29640ae2e65398
|
@@ -17,6 +17,8 @@ module Proxy::DiscoveryImage
|
|
17
17
|
body_data = request.body.read
|
18
18
|
# change virtual terminal out of newt screen
|
19
19
|
system("chvt", "2")
|
20
|
+
is_secureboot = system('mokutil --sb-state|grep enabled')
|
21
|
+
logger.debug "Secure boot is #{is_secureboot}"
|
20
22
|
logger.debug "Initiated kexec provisioning with #{body_data}"
|
21
23
|
log_halt(500, "kexec binary was not found") unless (kexec = which('kexec'))
|
22
24
|
begin
|
@@ -24,15 +26,18 @@ module Proxy::DiscoveryImage
|
|
24
26
|
rescue JSON::ParserError
|
25
27
|
log_halt 500, "Unable to parse kexec JSON input: #{body_data}"
|
26
28
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
args = ["--debug", "--force"]
|
30
|
+
extra = data['extra']
|
31
|
+
if extra && extra.is_a?(String)
|
32
|
+
args << extra
|
33
|
+
elsif extra && extra.is_a?(Array)
|
34
|
+
args.concat(extra)
|
30
35
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
args << "--kexec-file-syscall" if is_secureboot
|
37
|
+
args << "--append=#{data['append']}"
|
38
|
+
args << "--initrd=/tmp/initrd.img"
|
39
|
+
download_and_run_after_response data, 2, kexec, *args, "/tmp/vmlinuz"
|
40
|
+
|
36
41
|
{ :result => true }.to_json
|
37
42
|
end
|
38
43
|
|
@@ -40,9 +45,9 @@ module Proxy::DiscoveryImage
|
|
40
45
|
# Execute command in a separate thread after 5 seconds to give the server some
|
41
46
|
# time to finish the request. Does *not* execute via a shell.
|
42
47
|
def run_after_response(seconds, *command)
|
43
|
-
logger.debug "Power API scheduling in #{seconds} seconds: #{command.inspect}"
|
44
48
|
Thread.start do
|
45
49
|
begin
|
50
|
+
logger.debug "Power API scheduling in #{seconds} seconds: #{command.inspect}"
|
46
51
|
sleep seconds
|
47
52
|
logger.debug "Power API executing: #{command.inspect}"
|
48
53
|
if (sudo = which('sudo'))
|
@@ -57,5 +62,32 @@ module Proxy::DiscoveryImage
|
|
57
62
|
end
|
58
63
|
end
|
59
64
|
end
|
65
|
+
|
66
|
+
# Variant which also downloads kernel and initramdisk
|
67
|
+
def download_and_run_after_response(data, seconds, *command)
|
68
|
+
Thread.start do
|
69
|
+
begin
|
70
|
+
# download kernel and initramdisk
|
71
|
+
downloaded = download_file(data, 'kernel', 'vmlinuz', '/tmp') &&
|
72
|
+
download_file(data, 'initram', 'initrd.img', '/tmp')
|
73
|
+
# wait few seconds just in case the download was fast and perform kexec
|
74
|
+
# only perform kexec when both locks were available to prevent subsequent request while downloading
|
75
|
+
run_after_response(seconds, *command) if downloaded
|
76
|
+
rescue Exception => e
|
77
|
+
logger.error "Error during command execution: #{e}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def download_file(data, kind, name, prefix)
|
83
|
+
return unless data && (url = data[kind])
|
84
|
+
|
85
|
+
logger.debug "Downloading: #{url}"
|
86
|
+
download_thread = ::Proxy::HttpDownload.new(url, File.join(prefix, name)).start
|
87
|
+
logger.error("#{name} is still downloading, ignored") unless download_thread
|
88
|
+
download_success = download_thread.join.zero?
|
89
|
+
logger.error("cannot download #{name} for kexec") unless download_success
|
90
|
+
download_success
|
91
|
+
end
|
60
92
|
end
|
61
93
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_discovery_image
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Zapletal
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Smart Proxy plugin providing Image API on discovered nodes. This plugin is only
|
@@ -34,7 +34,7 @@ homepage: https://github.com/theforeman/smart_proxy_discovery_image
|
|
34
34
|
licenses:
|
35
35
|
- GPL-3.0
|
36
36
|
metadata: {}
|
37
|
-
post_install_message:
|
37
|
+
post_install_message:
|
38
38
|
rdoc_options: []
|
39
39
|
require_paths:
|
40
40
|
- lib
|
@@ -49,8 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
|
-
rubygems_version: 3.
|
53
|
-
signing_key:
|
52
|
+
rubygems_version: 3.1.2
|
53
|
+
signing_key:
|
54
54
|
specification_version: 4
|
55
55
|
summary: FDI API for Foreman Smart-Proxy
|
56
56
|
test_files: []
|