smart_proxy_dynflow 0.5.0 → 0.6.1
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 +4 -4
- data/Gemfile +4 -7
- data/{bundler.plugins.d → bundler.d}/dynflow.rb +0 -0
- data/bundler.d/inspect_anything.rb +1 -0
- data/bundler.d/x.local.rb +1 -0
- data/lib/smart_proxy_dynflow/action/batch_callback.rb +1 -1
- data/lib/smart_proxy_dynflow/action/batch_runner.rb +1 -1
- data/lib/smart_proxy_dynflow/action/output_collector.rb +1 -1
- data/lib/smart_proxy_dynflow/action/runner.rb +6 -1
- data/lib/smart_proxy_dynflow/action/shareable.rb +2 -2
- data/lib/smart_proxy_dynflow/callback.rb +7 -43
- data/lib/smart_proxy_dynflow/helpers.rb +6 -1
- data/lib/smart_proxy_dynflow/plugin.rb +3 -0
- data/lib/smart_proxy_dynflow/version.rb +1 -1
- metadata +35 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f3493966a6909232bc66c339f43bbf92a5fe816a12fa2ecd3f2a619b6ada735
|
4
|
+
data.tar.gz: e5c8ef258353c72e1d453c1dce1f97e12e25c2e12a59b2fdb3a317067c179ab9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25b9acceec9b4ba73f1e93cb8f9e0ad24fdb04d1f404304fa417c3ad84d81904f9cca562350031fbbce964bee076d5451ccde9c4a132546cc3fb7f2c9621737b
|
7
|
+
data.tar.gz: 6f02401a1eb65179772b0592856acb125cb53197e067d6fcabdcad98581d221052390b0bdb42fa39f1dae1e14de4d8be5b9c6aab28272423756ffeb1f72a82ac
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gemspec :name => '
|
3
|
+
gemspec :name => 'smart_proxy_dynflow'
|
4
4
|
|
5
5
|
group :development do
|
6
6
|
gem 'pry'
|
@@ -8,10 +8,12 @@ end
|
|
8
8
|
|
9
9
|
group :test do
|
10
10
|
gem 'smart_proxy', :git => "https://github.com/theforeman/smart-proxy", :branch => "develop"
|
11
|
-
gem 'smart_proxy_dynflow', :path => '.'
|
12
11
|
|
12
|
+
gem 'minitest'
|
13
|
+
gem 'mocha'
|
13
14
|
gem 'public_suffix'
|
14
15
|
gem 'rack-test'
|
16
|
+
gem 'rake'
|
15
17
|
gem 'rubocop', '~> 0.52.1'
|
16
18
|
end
|
17
19
|
|
@@ -19,11 +21,6 @@ gem 'logging-journald', '~> 2.0', :platforms => [:ruby], :require => false
|
|
19
21
|
gem 'rack', '>= 1.1'
|
20
22
|
gem 'sinatra'
|
21
23
|
|
22
|
-
# load bundler.d
|
23
|
-
Dir["#{File.dirname(__FILE__)}/bundler.d/*.rb"].each do |bundle|
|
24
|
-
self.instance_eval(Bundler.read_file(bundle))
|
25
|
-
end
|
26
|
-
|
27
24
|
# load local gemfile
|
28
25
|
local_gemfile = File.join(File.dirname(__FILE__), 'Gemfile.local.rb')
|
29
26
|
self.instance_eval(Bundler.read_file(local_gemfile)) if File.exist?(local_gemfile)
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# gem 'inspect_anything'
|
@@ -0,0 +1 @@
|
|
1
|
+
# gem 'dynflow', :path => '../dynflow'
|
@@ -6,7 +6,7 @@ module Proxy::Dynflow::Action
|
|
6
6
|
|
7
7
|
def run
|
8
8
|
payload = format_payload(input['targets'], input['results'])
|
9
|
-
|
9
|
+
Proxy::Dynflow::Callback::Request.new.callback({ :callbacks => payload }.to_json)
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
@@ -7,7 +7,7 @@ module Proxy::Dynflow::Action
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def initiate_runner
|
10
|
-
launcher =
|
10
|
+
launcher = Proxy::Dynflow::TaskLauncherRegistry.fetch(input[:operation])
|
11
11
|
launcher.runner_class.new(input[:targets], suspended_action: suspended_action)
|
12
12
|
end
|
13
13
|
end
|
@@ -52,6 +52,7 @@ module Proxy::Dynflow
|
|
52
52
|
|
53
53
|
def finish_run(update)
|
54
54
|
output[:exit_status] = update.exit_status
|
55
|
+
output[:result] = output_result
|
55
56
|
end
|
56
57
|
|
57
58
|
def process_external_event(event)
|
@@ -60,7 +61,7 @@ module Proxy::Dynflow
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def process_update(update)
|
63
|
-
|
64
|
+
output_chunk(update.continuous_output.raw_outputs) unless update.continuous_output.raw_outputs.empty?
|
64
65
|
if update.exit_status
|
65
66
|
finish_run(update)
|
66
67
|
else
|
@@ -71,6 +72,10 @@ module Proxy::Dynflow
|
|
71
72
|
def failed_run?
|
72
73
|
output[:exit_status] != 0
|
73
74
|
end
|
75
|
+
|
76
|
+
def output_result
|
77
|
+
stored_output_chunks.map { |c| c[:chunk] }.reduce([], &:concat)
|
78
|
+
end
|
74
79
|
end
|
75
80
|
end
|
76
81
|
end
|
@@ -12,14 +12,14 @@ module Proxy::Dynflow::Action
|
|
12
12
|
planned_action = plan_self(input)
|
13
13
|
# code only applicable, when run with SmartProxyDynflowCore in place
|
14
14
|
if on_proxy? && callback
|
15
|
-
plan_action(
|
15
|
+
plan_action(Proxy::Dynflow::Callback::Action, callback, planned_action.output)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def on_proxy?
|
22
|
-
|
22
|
+
true
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -2,57 +2,21 @@ require 'rest-client'
|
|
2
2
|
|
3
3
|
module Proxy::Dynflow
|
4
4
|
module Callback
|
5
|
-
class Request
|
6
|
-
|
7
|
-
|
8
|
-
self.new.callback(prepare_payload(callback_info, data))
|
9
|
-
end
|
10
|
-
|
11
|
-
def ssl_options
|
12
|
-
return @ssl_options if defined? @ssl_options
|
13
|
-
@ssl_options = {}
|
14
|
-
settings = Proxy::SETTINGS
|
15
|
-
return @ssl_options unless URI.parse(settings.foreman_url).scheme == 'https'
|
16
|
-
|
17
|
-
@ssl_options[:verify_ssl] = OpenSSL::SSL::VERIFY_PEER
|
18
|
-
|
19
|
-
private_key_file = settings.foreman_ssl_key || settings.ssl_private_key
|
20
|
-
if private_key_file
|
21
|
-
private_key = File.read(private_key_file)
|
22
|
-
@ssl_options[:ssl_client_key] = OpenSSL::PKey::RSA.new(private_key)
|
23
|
-
end
|
24
|
-
certificate_file = settings.foreman_ssl_cert || settings.ssl_certificate
|
25
|
-
if certificate_file
|
26
|
-
certificate = File.read(certificate_file)
|
27
|
-
@ssl_options[:ssl_client_cert] = OpenSSL::X509::Certificate.new(certificate)
|
28
|
-
end
|
29
|
-
ca_file = settings.foreman_ssl_ca || settings.ssl_ca_file
|
30
|
-
@ssl_options[:ssl_ca_file] = ca_file if ca_file
|
31
|
-
@ssl_options
|
32
|
-
end
|
33
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def prepare_payload(callback, data)
|
38
|
-
{ :callback => callback, :data => data }.to_json
|
39
|
-
end
|
5
|
+
class Request < ::Proxy::HttpRequest::ForemanRequest
|
6
|
+
def self.send_to_foreman_tasks(callback_info, data)
|
7
|
+
self.new.callback({ :callback => callback_info, :data => data }.to_json)
|
40
8
|
end
|
41
9
|
|
42
10
|
def callback(payload)
|
43
|
-
|
11
|
+
request = request_factory.create_post '/foreman_tasks/api/tasks/callback',
|
12
|
+
payload
|
13
|
+
response = send_request(request)
|
14
|
+
|
44
15
|
if response.code.to_s != "200"
|
45
16
|
raise "Failed performing callback to Foreman server: #{response.code} #{response.body}"
|
46
17
|
end
|
47
18
|
response
|
48
19
|
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def callback_resource
|
53
|
-
@resource ||= RestClient::Resource.new(Proxy::SETTINGS.foreman_url + '/foreman_tasks/api/tasks/callback',
|
54
|
-
self.class.ssl_options)
|
55
|
-
end
|
56
20
|
end
|
57
21
|
|
58
22
|
class Action < ::Dynflow::Action
|
@@ -35,7 +35,12 @@ module Proxy
|
|
35
35
|
|
36
36
|
def task_status(task_id)
|
37
37
|
ep = world.persistence.load_execution_plan(task_id)
|
38
|
-
|
38
|
+
actions = ep.actions.map do |action|
|
39
|
+
hash = action.to_hash
|
40
|
+
hash[:output][:result] = action.output_result if action.is_a?(Proxy::Dynflow::Action::Runner)
|
41
|
+
hash
|
42
|
+
end
|
43
|
+
ep.to_hash.merge(:actions => actions)
|
39
44
|
rescue KeyError => _e
|
40
45
|
status 404
|
41
46
|
{}
|
@@ -20,6 +20,9 @@ module Proxy::Dynflow
|
|
20
20
|
require 'smart_proxy_dynflow/action'
|
21
21
|
require 'smart_proxy_dynflow/task_launcher'
|
22
22
|
|
23
|
+
Proxy::Dynflow::TaskLauncherRegistry.register('single',
|
24
|
+
Proxy::Dynflow::TaskLauncher::Single)
|
25
|
+
|
23
26
|
Proxy::Dynflow::Core.ensure_initialized
|
24
27
|
end
|
25
28
|
end
|
metadata
CHANGED
@@ -1,17 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dynflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: dynflow
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
16
44
|
requirements:
|
17
45
|
- - ">="
|
@@ -117,7 +145,9 @@ extra_rdoc_files: []
|
|
117
145
|
files:
|
118
146
|
- Gemfile
|
119
147
|
- LICENSE
|
120
|
-
- bundler.
|
148
|
+
- bundler.d/dynflow.rb
|
149
|
+
- bundler.d/inspect_anything.rb
|
150
|
+
- bundler.d/x.local.rb
|
121
151
|
- lib/smart_proxy_dynflow.rb
|
122
152
|
- lib/smart_proxy_dynflow/action.rb
|
123
153
|
- lib/smart_proxy_dynflow/action/batch.rb
|
@@ -167,7 +197,7 @@ require_paths:
|
|
167
197
|
- lib
|
168
198
|
required_ruby_version: !ruby/object:Gem::Requirement
|
169
199
|
requirements:
|
170
|
-
- - "
|
200
|
+
- - ">="
|
171
201
|
- !ruby/object:Gem::Version
|
172
202
|
version: '2.5'
|
173
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|