smart_proxy_discovery_image 1.2.0 → 1.2.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
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5fc93e913ac9a70a9d099a12e4a7eba8139777de210569b44fb8e305e74299c
|
4
|
+
data.tar.gz: b41a1f2e085f2f7a04a33a88a6f670581d1d89ae34b6a59a497b135f12ad76ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e79b8fc34a0f3e04a99fd5f380bb9aa55699fe9d9db0b61e093173e41aa98e0340a8bc99a981b799ae669b5aec8fed82283d6c00ebd5000ced63c026cf6af94d
|
7
|
+
data.tar.gz: 6c2a81f40a1f6285a3e928cea8340a7c3ad633bd3cca2f87c1352b76f1c4599c49f94b15b5f6b8fbd4e66349c24dc9ceeba27bbfdb17d8bd85f8aa6c98f63de3
|
@@ -24,36 +24,23 @@ 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
|
-
|
27
|
+
download_and_run_after_response data, 2, kexec, "--debug", "--force", "--append=#{data['append']}", "--initrd=/tmp/initrd.img", "/tmp/vmlinuz", *data['extra']
|
28
28
|
{ :result => true }.to_json
|
29
29
|
end
|
30
30
|
|
31
31
|
|
32
32
|
# Execute command in a separate thread after 5 seconds to give the server some
|
33
33
|
# time to finish the request. Does *not* execute via a shell.
|
34
|
-
def run_after_response(
|
34
|
+
def run_after_response(seconds, *command)
|
35
35
|
Thread.start do
|
36
36
|
begin
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
37
|
+
logger.debug "Power API scheduling in #{seconds} seconds: #{command.inspect}"
|
38
|
+
sleep seconds
|
39
|
+
logger.debug "Power API executing: #{command.inspect}"
|
40
|
+
if (sudo = which('sudo'))
|
41
|
+
status = system(sudo, *command)
|
42
|
+
else
|
43
|
+
logger.warn "sudo binary was not found"
|
57
44
|
end
|
58
45
|
# only report errors
|
59
46
|
logger.warn "The attempted command failed with code #{$?.exitstatus}" unless status
|
@@ -62,5 +49,32 @@ module Proxy::DiscoveryImage
|
|
62
49
|
end
|
63
50
|
end
|
64
51
|
end
|
52
|
+
|
53
|
+
# Variant which also downloads kernel and initramdisk
|
54
|
+
def download_and_run_after_response(data, seconds, *command)
|
55
|
+
Thread.start do
|
56
|
+
begin
|
57
|
+
# download kernel and initramdisk
|
58
|
+
downloaded = download_file(data, 'kernel', 'vmlinuz', '/tmp') &&
|
59
|
+
download_file(data, 'initram', 'initrd.img', '/tmp')
|
60
|
+
# wait few seconds just in case the download was fast and perform kexec
|
61
|
+
# only perform kexec when both locks were available to prevent subsequent request while downloading
|
62
|
+
run_after_response(seconds, *command) if downloaded
|
63
|
+
rescue Exception => e
|
64
|
+
logger.error "Error during command execution: #{e}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def download_file(data, kind, name, prefix)
|
70
|
+
return unless data && (url = data[kind])
|
71
|
+
|
72
|
+
logger.debug "Downloading: #{url}"
|
73
|
+
download_thread = ::Proxy::HttpDownload.new(url, File.join(prefix, name)).start
|
74
|
+
logger.error("#{name} is still downloading, ignored") unless download_thread
|
75
|
+
download_success = download_thread.join.zero?
|
76
|
+
logger.error("cannot download #{name} for kexec") unless download_success
|
77
|
+
download_success
|
78
|
+
end
|
65
79
|
end
|
66
80
|
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.2.
|
4
|
+
version: 1.2.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: 2020-06
|
11
|
+
date: 2020-08-06 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
|
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
|
-
rubygems_version: 3.
|
52
|
+
rubygems_version: 3.1.2
|
53
53
|
signing_key:
|
54
54
|
specification_version: 4
|
55
55
|
summary: FDI API for Foreman Smart-Proxy
|