smart_proxy_dynflow 0.5.2 → 0.6.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
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b904806b1f4b0084f948d91f800d255ecf7bca92b1ed6d78fee49761a29affc9
|
4
|
+
data.tar.gz: 1eb7b63daaac6fbc3bdcb24d2938a93d2bd5728bcdb934f8384f41709a072cbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 887d7788a14a93d693c3ec2a7ddc110fc5fd6fe62619da946f6e0d68f2ec8542b69670769d0cf9e7eafccee3af04b9bf89fef3565346d69bfa1eb4f71492b119
|
7
|
+
data.tar.gz: e1c2f822a02805f2136ba363d13028699dea85e05ed41ba988853c5aadf3358d5f59f65006e5404321c087aea7a96699582ba8dd1fbc8f1a67a5e09943509d2d
|
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
|
|
@@ -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
|
@@ -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,14 +1,14 @@
|
|
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.0
|
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-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dynflow
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rest-client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,7 +195,7 @@ require_paths:
|
|
195
195
|
- lib
|
196
196
|
required_ruby_version: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
|
-
- - "
|
198
|
+
- - ">="
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: '2.5'
|
201
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|