smart_proxy_discovery_image 1.1.0 → 1.2.0
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 01103d93b909fdfc22ba01c37dd7061affb9d0440e35e041c3333c2884edaf37
|
|
4
|
+
data.tar.gz: b827937012ce424a99fe4c0f1d3bb756f996971a8c496d46bbfdcf69a1deb6b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e30242f64d5d36ab550a2ded89f3d700a4ce324d296e4243486389c2319a9d30a8c81b1830f50e285b7894609d15de8edaf554d4e5108d39103b8eb01fe1874b
|
|
7
|
+
data.tar.gz: 4e2298339d4802460eb7f3f0fa08698bf76a034860d0944039aa690dad062c703d10cf4a4fdd60eed8242ceb9104ec011e0f1684d7c302a2acdfa179b373985f
|
|
@@ -24,31 +24,36 @@ module Proxy::DiscoveryImage
|
|
|
24
24
|
rescue JSON::ParserError
|
|
25
25
|
log_halt 500, "Unable to parse kexec JSON input: #{body_data}"
|
|
26
26
|
end
|
|
27
|
-
|
|
28
|
-
if ::Proxy::HttpDownload.new(data['kernel'], '/tmp/vmlinuz').start.join != 0
|
|
29
|
-
log_halt 500, "cannot download kernel for kexec!"
|
|
30
|
-
end
|
|
31
|
-
logger.debug "Downloading: #{data['initram']}"
|
|
32
|
-
if ::Proxy::HttpDownload.new(data['initram'], '/tmp/initrd.img').start.join != 0
|
|
33
|
-
log_halt 500, "cannot download initram for kexec!"
|
|
34
|
-
end
|
|
35
|
-
run_after_response 2, kexec, "--debug", "--force", "--append=#{data['append']}", "--initrd=/tmp/initrd.img", "/tmp/vmlinuz", *data['extra']
|
|
27
|
+
run_after_response data, 2, kexec, "--debug", "--force", "--append=#{data['append']}", "--initrd=/tmp/initrd.img", "/tmp/vmlinuz", *data['extra']
|
|
36
28
|
{ :result => true }.to_json
|
|
37
29
|
end
|
|
38
30
|
|
|
39
31
|
|
|
40
32
|
# Execute command in a separate thread after 5 seconds to give the server some
|
|
41
33
|
# time to finish the request. Does *not* execute via a shell.
|
|
42
|
-
def run_after_response(seconds, *command)
|
|
43
|
-
logger.debug "Power API scheduling in #{seconds} seconds: #{command.inspect}"
|
|
34
|
+
def run_after_response(data, seconds, *command)
|
|
44
35
|
Thread.start do
|
|
45
36
|
begin
|
|
46
|
-
|
|
47
|
-
logger.debug "
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
# download kernel and initramdisk
|
|
38
|
+
logger.debug "Downloading: #{data['kernel']}"
|
|
39
|
+
vmlinuz_thread = ::Proxy::HttpDownload.new(data['kernel'], '/tmp/vmlinuz').start
|
|
40
|
+
logger.error("vmlinuz is still downloading, ignored") unless vmlinuz_thread
|
|
41
|
+
logger.error("cannot download vmlinuz for kexec") unless vmlinuz_thread.join == 0
|
|
42
|
+
logger.debug "Downloading: #{data['initram']}"
|
|
43
|
+
initrd_thread = ::Proxy::HttpDownload.new(data['initram'], '/tmp/initrd.img').start
|
|
44
|
+
logger.error("initrd.img is still downloading, ignored") unless initrd_thread
|
|
45
|
+
logger.error("cannot download initrd.img for kexec") unless initrd_thread.join == 0
|
|
46
|
+
# wait few seconds just in case the download was fast and perform kexec
|
|
47
|
+
# only perform kexec when both locks were available to prevent subsequent request while downloading
|
|
48
|
+
if vmlinuz_thread && initrd_thread
|
|
49
|
+
logger.debug "Power API scheduling in #{seconds} seconds: #{command.inspect}"
|
|
50
|
+
sleep seconds
|
|
51
|
+
logger.debug "Power API executing: #{command.inspect}"
|
|
52
|
+
if (sudo = which('sudo'))
|
|
53
|
+
status = system(sudo, *command)
|
|
54
|
+
else
|
|
55
|
+
logger.warn "sudo binary was not found"
|
|
56
|
+
end
|
|
52
57
|
end
|
|
53
58
|
# only report errors
|
|
54
59
|
logger.warn "The attempted command failed with code #{$?.exitstatus}" unless status
|
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.2.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: 2020-06-
|
|
11
|
+
date: 2020-06-18 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
|