smart_proxy_discovery_image 1.0.9 → 1.3.1
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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 43314999e259f9fc1687fc4eb31dce1293010ed14a59d77e343ac0b7491cf503
|
4
|
+
data.tar.gz: 91f710c0e4698dc382ea2a5eda4732796b8cb2002de389d4ad0ca189179296bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eca1ddeaefcabec8bbd22005b264bea797976c5cce1e660d04d54d48dae255d9fad0129a51f2d32b999766cde12514770d31b6b431432c687820e45b665e7afc
|
7
|
+
data.tar.gz: b7f5dcddcbe845fd055df2e7fb540b03691906c52f66b6d80298b84fd85055cccbcee0b029dbfa17dfbe71bc3f72116798229ee0da9baaea9dadad834c2c3097
|
@@ -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,13 @@ 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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
run_after_response 2, kexec, "--debug", "--force", "--reset-vga", "--append=#{data['append']}", "--initrd=/tmp/initrd.img", "/tmp/vmlinuz", *data['extra']
|
29
|
+
args = ["--debug", "--force"]
|
30
|
+
args << data['extra'] if data['extra']
|
31
|
+
args << "--kexec-file-syscall" if is_secureboot
|
32
|
+
args << "--append=#{data['append']}"
|
33
|
+
args << "--initrd=/tmp/initrd.img"
|
34
|
+
download_and_run_after_response data, 2, kexec, *args, "/tmp/vmlinuz"
|
35
|
+
|
36
36
|
{ :result => true }.to_json
|
37
37
|
end
|
38
38
|
|
@@ -40,9 +40,9 @@ module Proxy::DiscoveryImage
|
|
40
40
|
# Execute command in a separate thread after 5 seconds to give the server some
|
41
41
|
# time to finish the request. Does *not* execute via a shell.
|
42
42
|
def run_after_response(seconds, *command)
|
43
|
-
logger.debug "Power API scheduling in #{seconds} seconds: #{command.inspect}"
|
44
43
|
Thread.start do
|
45
44
|
begin
|
45
|
+
logger.debug "Power API scheduling in #{seconds} seconds: #{command.inspect}"
|
46
46
|
sleep seconds
|
47
47
|
logger.debug "Power API executing: #{command.inspect}"
|
48
48
|
if (sudo = which('sudo'))
|
@@ -57,5 +57,32 @@ module Proxy::DiscoveryImage
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
# Variant which also downloads kernel and initramdisk
|
62
|
+
def download_and_run_after_response(data, seconds, *command)
|
63
|
+
Thread.start do
|
64
|
+
begin
|
65
|
+
# download kernel and initramdisk
|
66
|
+
downloaded = download_file(data, 'kernel', 'vmlinuz', '/tmp') &&
|
67
|
+
download_file(data, 'initram', 'initrd.img', '/tmp')
|
68
|
+
# wait few seconds just in case the download was fast and perform kexec
|
69
|
+
# only perform kexec when both locks were available to prevent subsequent request while downloading
|
70
|
+
run_after_response(seconds, *command) if downloaded
|
71
|
+
rescue Exception => e
|
72
|
+
logger.error "Error during command execution: #{e}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def download_file(data, kind, name, prefix)
|
78
|
+
return unless data && (url = data[kind])
|
79
|
+
|
80
|
+
logger.debug "Downloading: #{url}"
|
81
|
+
download_thread = ::Proxy::HttpDownload.new(url, File.join(prefix, name)).start
|
82
|
+
logger.error("#{name} is still downloading, ignored") unless download_thread
|
83
|
+
download_success = download_thread.join.zero?
|
84
|
+
logger.error("cannot download #{name} for kexec") unless download_success
|
85
|
+
download_success
|
86
|
+
end
|
60
87
|
end
|
61
88
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Zapletal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-23 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
|
@@ -30,7 +30,7 @@ files:
|
|
30
30
|
- lib/smart_proxy_discovery_image/power_api.rb
|
31
31
|
- lib/smart_proxy_discovery_image/version.rb
|
32
32
|
- settings.d/discovery_image.yml.example
|
33
|
-
homepage:
|
33
|
+
homepage: https://github.com/theforeman/smart_proxy_discovery_image
|
34
34
|
licenses:
|
35
35
|
- GPL-3.0
|
36
36
|
metadata: {}
|
@@ -49,8 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
|
-
|
53
|
-
rubygems_version: 2.6.11
|
52
|
+
rubygems_version: 3.1.2
|
54
53
|
signing_key:
|
55
54
|
specification_version: 4
|
56
55
|
summary: FDI API for Foreman Smart-Proxy
|