smart_proxy_discovery_image 1.0.7 → 1.3.0
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: 249769da7939f13c7cf220e3b347613d5999a4f06ee68f81d0c930ed1494ce59
|
4
|
+
data.tar.gz: b746dcd6207df3f11c666d55dd215a1d14da5d8ae6b7bf710ad65f6438a971a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a85568d2bb0b3ef030f413c197a7d3c04f6c168e15890c968250fc04b79a47024e2e8c3ff4c4b4f213f0b2684313301bd580eeb1b53d9ac9fa03f506ab2642e
|
7
|
+
data.tar.gz: 8d0e231d24fc81b5df213585b67c5ded6b64ee4f9af3cbd1e72b4fdf65ffc15c8f6375414ab83ca14fcf081aacda4b4d00f11cf35b54abca3ce1640aabfdd8fc
|
@@ -15,6 +15,10 @@ module Proxy::DiscoveryImage
|
|
15
15
|
|
16
16
|
put "/kexec" do
|
17
17
|
body_data = request.body.read
|
18
|
+
# change virtual terminal out of newt screen
|
19
|
+
system("chvt", "2")
|
20
|
+
is_secureboot = system('mokutil --sb-state|grep enabled')
|
21
|
+
logger.debug "Secure boot is #{is_secureboot}"
|
18
22
|
logger.debug "Initiated kexec provisioning with #{body_data}"
|
19
23
|
log_halt(500, "kexec binary was not found") unless (kexec = which('kexec'))
|
20
24
|
begin
|
@@ -22,15 +26,13 @@ module Proxy::DiscoveryImage
|
|
22
26
|
rescue JSON::ParserError
|
23
27
|
log_halt 500, "Unable to parse kexec JSON input: #{body_data}"
|
24
28
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
run_after_response 2, kexec, "--force", "--reset-vga", "--append=#{data['append']}", "--initrd=/tmp/initrd.img", "/tmp/vmlinuz", *data['extra']
|
29
|
+
args = ["--debug", "--force", "--reset-vga"]
|
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
|
+
|
34
36
|
{ :result => true }.to_json
|
35
37
|
end
|
36
38
|
|
@@ -38,9 +40,9 @@ module Proxy::DiscoveryImage
|
|
38
40
|
# Execute command in a separate thread after 5 seconds to give the server some
|
39
41
|
# time to finish the request. Does *not* execute via a shell.
|
40
42
|
def run_after_response(seconds, *command)
|
41
|
-
logger.debug "Power API scheduling in #{seconds} seconds: #{command.inspect}"
|
42
43
|
Thread.start do
|
43
44
|
begin
|
45
|
+
logger.debug "Power API scheduling in #{seconds} seconds: #{command.inspect}"
|
44
46
|
sleep seconds
|
45
47
|
logger.debug "Power API executing: #{command.inspect}"
|
46
48
|
if (sudo = which('sudo'))
|
@@ -55,5 +57,32 @@ module Proxy::DiscoveryImage
|
|
55
57
|
end
|
56
58
|
end
|
57
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
|
58
87
|
end
|
59
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.0
|
4
|
+
version: 1.3.0
|
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-09-07 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
|