smart_proxy_dynflow_core 0.2.1 → 0.2.2
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 +5 -5
- data/lib/smart_proxy_dynflow_core/api.rb +22 -2
- data/lib/smart_proxy_dynflow_core/bundler_helper.rb +2 -0
- data/lib/smart_proxy_dynflow_core/callback.rb +37 -39
- data/lib/smart_proxy_dynflow_core/core.rb +3 -3
- data/lib/smart_proxy_dynflow_core/helpers.rb +2 -2
- data/lib/smart_proxy_dynflow_core/launcher.rb +8 -5
- data/lib/smart_proxy_dynflow_core/log.rb +26 -7
- data/lib/smart_proxy_dynflow_core/settings.rb +30 -31
- data/lib/smart_proxy_dynflow_core/task_launcher_registry.rb +32 -0
- data/lib/smart_proxy_dynflow_core/testing.rb +1 -1
- data/lib/smart_proxy_dynflow_core/version.rb +1 -1
- data/lib/smart_proxy_dynflow_core/webrick-patch.rb +7 -5
- data/lib/smart_proxy_dynflow_core.rb +6 -3
- data/smart_proxy_dynflow_core.gemspec +8 -7
- metadata +30 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2aa6a1c4c6ccf4382d03834690a695627f66d10
|
|
4
|
+
data.tar.gz: 6aedf16460fbc6924fac95e1dd4be0ead1b4fc37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5aac4b464edb1a3171bb52a6599823e336f532d0dec0dff6a9ffda3343bfea7900ae23e45eba36070f16a34f8fbffd6be97fd53e7af1c81a360a3bcc50a23714
|
|
7
|
+
data.tar.gz: fcee792dcf9c2494a1437799f4c57bf67cbe5dd6de6debb41ce406edc48cff00948158fe74d70fb180f72c0ae2e08476512f82a38461d303cac1bea1b54a7c7b
|
data/Gemfile
CHANGED
|
@@ -7,16 +7,16 @@ group :development do
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
group :test do
|
|
10
|
-
gem 'smart_proxy_dynflow', :path => '.'
|
|
11
10
|
gem 'smart_proxy', :git => "https://github.com/theforeman/smart-proxy", :branch => "develop"
|
|
11
|
+
gem 'smart_proxy_dynflow', :path => '.'
|
|
12
12
|
|
|
13
13
|
if RUBY_VERSION < '2.1'
|
|
14
14
|
gem 'public_suffix', '< 3'
|
|
15
|
-
gem 'rubocop', '< 0.51.0'
|
|
16
15
|
gem 'rainbow', '< 3'
|
|
16
|
+
gem 'rubocop', '< 0.51.0'
|
|
17
17
|
else
|
|
18
|
-
gem 'rubocop', '~> 0.52.1'
|
|
19
18
|
gem 'public_suffix'
|
|
19
|
+
gem 'rubocop', '~> 0.52.1'
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
if RUBY_VERSION < '2.2'
|
|
@@ -27,11 +27,11 @@ group :test do
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
if RUBY_VERSION < '2.2'
|
|
30
|
-
gem 'sinatra', '< 2'
|
|
31
30
|
gem 'rack', '>= 1.1', '< 2.0.0'
|
|
31
|
+
gem 'sinatra', '< 2'
|
|
32
32
|
else
|
|
33
|
-
gem 'sinatra'
|
|
34
33
|
gem 'rack', '>= 1.1'
|
|
34
|
+
gem 'sinatra'
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# load bundler.d
|
|
@@ -6,7 +6,6 @@ module SmartProxyDynflowCore
|
|
|
6
6
|
helpers Helpers
|
|
7
7
|
|
|
8
8
|
before do
|
|
9
|
-
logger = Log.instance
|
|
10
9
|
authorize_with_token || authorize_with_ssl_client
|
|
11
10
|
content_type :json
|
|
12
11
|
end
|
|
@@ -21,6 +20,13 @@ module SmartProxyDynflowCore
|
|
|
21
20
|
MultiJson.dump(result)
|
|
22
21
|
end
|
|
23
22
|
|
|
23
|
+
post "/tasks/launch/?" do
|
|
24
|
+
params = MultiJson.load(request.body.read)
|
|
25
|
+
launcher = launcher_class(params).new(world, callback_host(params, request), params.fetch('options', {}))
|
|
26
|
+
launcher.launch!(params['input'])
|
|
27
|
+
launcher.results.to_json
|
|
28
|
+
end
|
|
29
|
+
|
|
24
30
|
post "/tasks/?" do
|
|
25
31
|
params = MultiJson.load(request.body.read)
|
|
26
32
|
trigger_task(::Dynflow::Utils.constantize(params['action_name']),
|
|
@@ -44,10 +50,24 @@ module SmartProxyDynflowCore
|
|
|
44
50
|
complete_task(task_id, data)
|
|
45
51
|
end
|
|
46
52
|
|
|
53
|
+
get "/tasks/operations" do
|
|
54
|
+
TaskLauncherRegistry.operations.to_json
|
|
55
|
+
end
|
|
56
|
+
|
|
47
57
|
private
|
|
48
58
|
|
|
49
59
|
def callback_host(params, request)
|
|
50
|
-
params.fetch('action_input', {})['proxy_url'] ||
|
|
60
|
+
params.fetch('action_input', {})['proxy_url'] ||
|
|
61
|
+
request.env.values_at('HTTP_X_FORWARDED_FOR', 'HTTP_HOST').compact.first
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def launcher_class(params)
|
|
65
|
+
operation = params.fetch('operation')
|
|
66
|
+
if TaskLauncherRegistry.key?(operation)
|
|
67
|
+
TaskLauncherRegistry.fetch(operation)
|
|
68
|
+
else
|
|
69
|
+
halt 404, MultiJson.dump(:error => "Unknown operation '#{operation}' requested.")
|
|
70
|
+
end
|
|
51
71
|
end
|
|
52
72
|
end
|
|
53
73
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module SmartProxyDynflowCore
|
|
2
2
|
class BundlerHelper
|
|
3
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
|
3
4
|
def self.require_groups(*groups)
|
|
4
5
|
if File.exist?(File.expand_path('../../../Gemfile.in', __FILE__))
|
|
5
6
|
# If there is a Gemfile.in file, we will not use Bundler but BundlerExt
|
|
@@ -25,5 +26,6 @@ module SmartProxyDynflowCore
|
|
|
25
26
|
Bundler.require(*groups)
|
|
26
27
|
end
|
|
27
28
|
end
|
|
29
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
|
28
30
|
end
|
|
29
31
|
end
|
|
@@ -1,23 +1,52 @@
|
|
|
1
1
|
require 'rest-client'
|
|
2
2
|
|
|
3
|
+
# rubocop:disable Lint/HandleExceptions
|
|
3
4
|
begin
|
|
4
5
|
require 'smart_proxy_dynflow/callback'
|
|
5
6
|
rescue LoadError
|
|
6
7
|
end
|
|
8
|
+
# rubocop:enable Lint/HandleExceptions
|
|
7
9
|
|
|
8
10
|
module SmartProxyDynflowCore
|
|
9
11
|
module Callback
|
|
10
|
-
class
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
class Request
|
|
13
|
+
class << self
|
|
14
|
+
def send_to_foreman_tasks(callback_info, data)
|
|
15
|
+
self.new.callback(prepare_payload(callback_info, data))
|
|
16
|
+
end
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
|
19
|
+
def ssl_options
|
|
20
|
+
return @ssl_options if defined? @ssl_options
|
|
21
|
+
@ssl_options = {}
|
|
22
|
+
settings = Settings.instance
|
|
23
|
+
return @ssl_options unless URI.parse(settings.foreman_url).scheme == 'https'
|
|
24
|
+
|
|
25
|
+
@ssl_options[:verify_ssl] = OpenSSL::SSL::VERIFY_PEER
|
|
26
|
+
|
|
27
|
+
private_key_file = settings.foreman_ssl_key || settings.ssl_private_key
|
|
28
|
+
if private_key_file
|
|
29
|
+
private_key = File.read(private_key_file)
|
|
30
|
+
@ssl_options[:ssl_client_key] = OpenSSL::PKey::RSA.new(private_key)
|
|
31
|
+
end
|
|
32
|
+
certificate_file = settings.foreman_ssl_cert || settings.ssl_certificate
|
|
33
|
+
if certificate_file
|
|
34
|
+
certificate = File.read(certificate_file)
|
|
35
|
+
@ssl_options[:ssl_client_cert] = OpenSSL::X509::Certificate.new(certificate)
|
|
36
|
+
end
|
|
37
|
+
ca_file = settings.foreman_ssl_ca || settings.ssl_ca_file
|
|
38
|
+
@ssl_options[:ssl_ca_file] = ca_file if ca_file
|
|
39
|
+
@ssl_options
|
|
40
|
+
end
|
|
41
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def prepare_payload(callback, data)
|
|
46
|
+
{ :callback => callback, :data => data }.to_json
|
|
47
|
+
end
|
|
17
48
|
end
|
|
18
|
-
end
|
|
19
49
|
|
|
20
|
-
class Request
|
|
21
50
|
def callback(payload)
|
|
22
51
|
response = callback_resource.post(payload, :content_type => :json)
|
|
23
52
|
if response.code.to_s != "200"
|
|
@@ -26,43 +55,12 @@ module SmartProxyDynflowCore
|
|
|
26
55
|
response
|
|
27
56
|
end
|
|
28
57
|
|
|
29
|
-
def self.send_to_foreman_tasks(callback_info, data)
|
|
30
|
-
self.new.callback(self.prepare_payload(callback_info, data))
|
|
31
|
-
end
|
|
32
|
-
|
|
33
58
|
private
|
|
34
59
|
|
|
35
|
-
def self.prepare_payload(callback, data)
|
|
36
|
-
{ :callback => callback, :data => data }.to_json
|
|
37
|
-
end
|
|
38
|
-
|
|
39
60
|
def callback_resource
|
|
40
61
|
@resource ||= RestClient::Resource.new(Settings.instance.foreman_url + '/foreman_tasks/api/tasks/callback',
|
|
41
62
|
self.class.ssl_options)
|
|
42
63
|
end
|
|
43
|
-
|
|
44
|
-
def self.ssl_options
|
|
45
|
-
return @ssl_options if defined? @ssl_options
|
|
46
|
-
@ssl_options = {}
|
|
47
|
-
settings = Settings.instance
|
|
48
|
-
return @ssl_options unless URI.parse(settings.foreman_url).scheme == 'https'
|
|
49
|
-
|
|
50
|
-
@ssl_options[:verify_ssl] = OpenSSL::SSL::VERIFY_PEER
|
|
51
|
-
|
|
52
|
-
private_key_file = settings.foreman_ssl_key || settings.ssl_private_key
|
|
53
|
-
if private_key_file
|
|
54
|
-
private_key = File.read(private_key_file)
|
|
55
|
-
@ssl_options[:ssl_client_key] = OpenSSL::PKey::RSA.new(private_key)
|
|
56
|
-
end
|
|
57
|
-
certificate_file = settings.foreman_ssl_cert || settings.ssl_certificate
|
|
58
|
-
if certificate_file
|
|
59
|
-
certificate = File.read(certificate_file)
|
|
60
|
-
@ssl_options[:ssl_client_cert] = OpenSSL::X509::Certificate.new(certificate)
|
|
61
|
-
end
|
|
62
|
-
ca_file = settings.foreman_ssl_ca || settings.ssl_ca_file
|
|
63
|
-
@ssl_options[:ssl_ca_file] = ca_file if ca_file
|
|
64
|
-
@ssl_options
|
|
65
|
-
end
|
|
66
64
|
end
|
|
67
65
|
|
|
68
66
|
class Action < ::Dynflow::Action
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
module SmartProxyDynflowCore
|
|
2
2
|
class Core
|
|
3
|
-
|
|
4
3
|
attr_accessor :world, :accepted_cert_serial
|
|
5
4
|
|
|
6
5
|
def initialize
|
|
@@ -25,7 +24,8 @@ module SmartProxyDynflowCore
|
|
|
25
24
|
|
|
26
25
|
db_file = Settings.instance.database
|
|
27
26
|
if db_file.nil? || db_file.empty?
|
|
28
|
-
Log.instance.warn "Could not open DB for dynflow at '#{db_file}',
|
|
27
|
+
Log.instance.warn "Could not open DB for dynflow at '#{db_file}', " \
|
|
28
|
+
"will keep data in memory. Restart will drop all dynflow data."
|
|
29
29
|
else
|
|
30
30
|
db_conn_string += "/#{db_file}"
|
|
31
31
|
end
|
|
@@ -44,7 +44,7 @@ module SmartProxyDynflowCore
|
|
|
44
44
|
config.persistence_adapter = persistence_adapter
|
|
45
45
|
config.execution_plan_cleaner = execution_plan_cleaner
|
|
46
46
|
# TODO: There has to be a better way
|
|
47
|
-
matchers = config.silent_dead_letter_matchers.call
|
|
47
|
+
matchers = config.silent_dead_letter_matchers.call.concat(self.class.silencer_matchers)
|
|
48
48
|
config.silent_dead_letter_matchers = matchers
|
|
49
49
|
yield config if block_given?
|
|
50
50
|
end
|
|
@@ -10,7 +10,7 @@ module SmartProxyDynflowCore
|
|
|
10
10
|
auth = request.env['HTTP_AUTHORIZATION']
|
|
11
11
|
basic_prefix = /\ABasic /
|
|
12
12
|
if !auth.to_s.empty? && auth =~ basic_prefix &&
|
|
13
|
-
|
|
13
|
+
ForemanTasksCore::OtpManager.authenticate(auth.gsub(basic_prefix, ''))
|
|
14
14
|
Log.instance.debug('authorized with token')
|
|
15
15
|
return true
|
|
16
16
|
end
|
|
@@ -21,7 +21,7 @@ module SmartProxyDynflowCore
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def authorize_with_ssl_client
|
|
24
|
-
if %w
|
|
24
|
+
if %w[yes on 1].include? request.env['HTTPS'].to_s
|
|
25
25
|
if request.env['SSL_CLIENT_CERT'].to_s.empty?
|
|
26
26
|
Log.instance.error "No client SSL certificate supplied"
|
|
27
27
|
halt 403, MultiJson.dump(:error => "No client SSL certificate supplied")
|
|
@@ -4,7 +4,6 @@ require 'smart_proxy_dynflow_core/settings'
|
|
|
4
4
|
require 'smart_proxy_dynflow_core/webrick-patch'
|
|
5
5
|
module SmartProxyDynflowCore
|
|
6
6
|
class Launcher
|
|
7
|
-
|
|
8
7
|
def self.launch!(options)
|
|
9
8
|
self.new.start options
|
|
10
9
|
end
|
|
@@ -84,6 +83,7 @@ module SmartProxyDynflowCore
|
|
|
84
83
|
}
|
|
85
84
|
end
|
|
86
85
|
|
|
86
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
|
87
87
|
def https_app
|
|
88
88
|
ssl_options = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options]
|
|
89
89
|
ssl_options |= OpenSSL::SSL::OP_CIPHER_SERVER_PREFERENCE if defined?(OpenSSL::SSL::OP_CIPHER_SERVER_PREFERENCE)
|
|
@@ -94,7 +94,7 @@ module SmartProxyDynflowCore
|
|
|
94
94
|
|
|
95
95
|
if Settings.instance.tls_disabled_versions
|
|
96
96
|
Settings.instance.tls_disabled_versions.each do |version|
|
|
97
|
-
constant = OpenSSL::SSL.const_get("OP_NO_TLSv#{version.to_s.
|
|
97
|
+
constant = OpenSSL::SSL.const_get("OP_NO_TLSv#{version.to_s.tr('.', '_')}") rescue nil
|
|
98
98
|
|
|
99
99
|
if constant
|
|
100
100
|
Log.instance.info "TLSv#{version} will be disabled."
|
|
@@ -114,6 +114,7 @@ module SmartProxyDynflowCore
|
|
|
114
114
|
:SSLOptions => ssl_options
|
|
115
115
|
}
|
|
116
116
|
end
|
|
117
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
|
117
118
|
|
|
118
119
|
def https_enabled?
|
|
119
120
|
Settings.instance.use_https
|
|
@@ -122,14 +123,16 @@ module SmartProxyDynflowCore
|
|
|
122
123
|
def ssl_private_key
|
|
123
124
|
OpenSSL::PKey::RSA.new(File.read(Settings.instance.ssl_private_key))
|
|
124
125
|
rescue Exception => e
|
|
125
|
-
Log.instance.fatal "Unable to load private SSL key. Are the values
|
|
126
|
+
Log.instance.fatal "Unable to load private SSL key. Are the values "\
|
|
127
|
+
"correct in settings.yml and do permissions allow reading?: #{e}"
|
|
126
128
|
raise e
|
|
127
129
|
end
|
|
128
130
|
|
|
129
131
|
def ssl_certificate
|
|
130
132
|
OpenSSL::X509::Certificate.new(File.read(Settings.instance.ssl_certificate))
|
|
131
133
|
rescue Exception => e
|
|
132
|
-
Log.instance.fatal "Unable to load SSL certificate. Are the values
|
|
134
|
+
Log.instance.fatal "Unable to load SSL certificate. Are the values " \
|
|
135
|
+
"correct in settings.yml and do permissions allow reading?: #{e}"
|
|
133
136
|
raise e
|
|
134
137
|
end
|
|
135
138
|
|
|
@@ -141,7 +144,7 @@ module SmartProxyDynflowCore
|
|
|
141
144
|
Dir[File.join(dir, 'settings.d', '*.yml')].each { |path| Settings.load_plugin_settings(path) }
|
|
142
145
|
true
|
|
143
146
|
end
|
|
144
|
-
ForemanTasksCore::SettingsLoader.settings_registry.
|
|
147
|
+
ForemanTasksCore::SettingsLoader.settings_registry.each_key do |settings_keys|
|
|
145
148
|
settings = settings_keys.inject({}) do |h, settings_key|
|
|
146
149
|
if SETTINGS.plugins.key?(settings_key.to_s)
|
|
147
150
|
h.merge(SETTINGS.plugins[settings_key.to_s].to_h)
|
|
@@ -2,7 +2,6 @@ require 'logger'
|
|
|
2
2
|
|
|
3
3
|
module SmartProxyDynflowCore
|
|
4
4
|
class Log < ::Logger
|
|
5
|
-
|
|
6
5
|
alias_method :write, :debug
|
|
7
6
|
|
|
8
7
|
class << self
|
|
@@ -42,25 +41,45 @@ module SmartProxyDynflowCore
|
|
|
42
41
|
|
|
43
42
|
def initialize(file, *rest)
|
|
44
43
|
@file = file
|
|
45
|
-
@fd = @file.
|
|
44
|
+
@fd = @file.is_a?(IO) ? @file : File.open(@file, 'a')
|
|
46
45
|
@fd.sync = true
|
|
47
46
|
super(@fd, rest)
|
|
48
47
|
end
|
|
49
48
|
|
|
50
49
|
def roll_log
|
|
51
|
-
unless @file.
|
|
50
|
+
unless @file.is_a? IO
|
|
52
51
|
@fd.reopen @file, 'a'
|
|
53
52
|
@fd.sync = true
|
|
54
53
|
end
|
|
55
54
|
end
|
|
56
55
|
|
|
56
|
+
class ProxyStructuredFormater < ::Dynflow::LoggerAdapters::Formatters::Abstract
|
|
57
|
+
def call(_severity, _datetime, _prog_name, message)
|
|
58
|
+
if ::Exception === message
|
|
59
|
+
subject = "#{message.message} (#{message.class})"
|
|
60
|
+
if @base.respond_to?(:exception)
|
|
61
|
+
@base.exception("Error details", message)
|
|
62
|
+
subject
|
|
63
|
+
else
|
|
64
|
+
"#{subject}\n#{message.backtrace.join("\n")}"
|
|
65
|
+
end
|
|
66
|
+
else
|
|
67
|
+
message
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def format(message)
|
|
72
|
+
call(nil, nil, nil, message)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
57
76
|
class ProxyAdapter < ::Dynflow::LoggerAdapters::Simple
|
|
58
|
-
def initialize(logger, level = Logger::DEBUG, formatters = [
|
|
77
|
+
def initialize(logger, level = Logger::DEBUG, formatters = [])
|
|
59
78
|
@logger = logger
|
|
60
79
|
@logger.level = level
|
|
61
|
-
@logger.formatter =
|
|
62
|
-
@action_logger = apply_formatters
|
|
63
|
-
@dynflow_logger = apply_formatters
|
|
80
|
+
@logger.formatter = ProxyStructuredFormater.new(@logger)
|
|
81
|
+
@action_logger = apply_formatters(ProgNameWrapper.new(@logger, ' action'), [ProxyStructuredFormater])
|
|
82
|
+
@dynflow_logger = apply_formatters(ProgNameWrapper.new(@logger, 'dynflow'), [ProxyStructuredFormater])
|
|
64
83
|
end
|
|
65
84
|
end
|
|
66
85
|
end
|
|
@@ -19,37 +19,36 @@ end
|
|
|
19
19
|
|
|
20
20
|
module SmartProxyDynflowCore
|
|
21
21
|
class Settings < OpenStruct
|
|
22
|
-
|
|
23
22
|
DEFAULT_SETTINGS = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
23
|
+
:database => '/var/lib/foreman-proxy/dynflow/dynflow.sqlite',
|
|
24
|
+
:foreman_url => 'https://127.0.0.1:3000',
|
|
25
|
+
:console_auth => true,
|
|
26
|
+
:listen => '127.0.0.1',
|
|
27
|
+
:port => '8008',
|
|
28
|
+
:use_https => false,
|
|
29
|
+
:ssl_ca_file => nil,
|
|
30
|
+
:ssl_private_key => nil,
|
|
31
|
+
:ssl_certificate => nil,
|
|
32
|
+
:ssl_disabled_ciphers => [],
|
|
33
|
+
:tls_disabled_versions => [],
|
|
34
|
+
:foreman_ssl_ca => nil,
|
|
35
|
+
:foreman_ssl_key => nil,
|
|
36
|
+
:foreman_ssl_cert => nil,
|
|
37
|
+
:standalone => false,
|
|
38
|
+
:log_file => '/var/log/foreman-proxy/smart_proxy_dynflow_core.log',
|
|
39
|
+
:log_level => :ERROR,
|
|
40
|
+
:plugins => {},
|
|
41
|
+
:pid_file => '/var/run/foreman-proxy/smart_proxy_dynflow_core.pid',
|
|
42
|
+
:daemonize => false,
|
|
43
|
+
:execution_plan_cleaner_age => 60 * 60 * 24,
|
|
44
|
+
:loaded => false
|
|
45
|
+
}.freeze
|
|
47
46
|
|
|
48
|
-
PROXY_SETTINGS = [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
PLUGIN_SETTINGS = [
|
|
52
|
-
|
|
47
|
+
PROXY_SETTINGS = %i[ssl_ca_file ssl_certificate ssl_private_key foreman_url
|
|
48
|
+
foreman_ssl_ca foreman_ssl_cert foreman_ssl_key
|
|
49
|
+
log_file log_level ssl_disabled_ciphers].freeze
|
|
50
|
+
PLUGIN_SETTINGS = %i[database core_url console_auth
|
|
51
|
+
execution_plan_cleaner_age].freeze
|
|
53
52
|
|
|
54
53
|
def initialize(settings = {})
|
|
55
54
|
super(DEFAULT_SETTINGS.merge(settings))
|
|
@@ -60,7 +59,7 @@ module SmartProxyDynflowCore
|
|
|
60
59
|
end
|
|
61
60
|
|
|
62
61
|
def self.load_global_settings(path)
|
|
63
|
-
if File.
|
|
62
|
+
if File.exist? File.join(path)
|
|
64
63
|
YAML.load_file(path).each do |key, value|
|
|
65
64
|
SETTINGS[key] = value
|
|
66
65
|
end
|
|
@@ -87,7 +86,7 @@ module SmartProxyDynflowCore
|
|
|
87
86
|
PLUGIN_SETTINGS.each do |key|
|
|
88
87
|
SETTINGS[key] = settings[key] if settings.key?(key)
|
|
89
88
|
end
|
|
90
|
-
SETTINGS.plugins.values.each
|
|
89
|
+
SETTINGS.plugins.values.each(&:load_settings_from_proxy)
|
|
91
90
|
Settings.loaded!
|
|
92
91
|
end
|
|
93
92
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module SmartProxyDynflowCore
|
|
2
|
+
class TaskLauncherRegistry
|
|
3
|
+
class << self
|
|
4
|
+
|
|
5
|
+
def register(name, launcher)
|
|
6
|
+
registry[name] = launcher
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def fetch(name, default = nil)
|
|
10
|
+
if default.nil?
|
|
11
|
+
registry.fetch(name)
|
|
12
|
+
else
|
|
13
|
+
registry.fetch(name, default)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def key?(name)
|
|
18
|
+
registry.key?(name)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def operations
|
|
22
|
+
registry.keys
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def registry
|
|
28
|
+
@registry ||= {}
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -17,7 +17,7 @@ module SmartProxyDynflowCore
|
|
|
17
17
|
config.auto_terminate = false
|
|
18
18
|
config.logger_adapter = ::Dynflow::LoggerAdapters::Simple.new $stderr, DYNFLOW_TESTING_LOG_LEVEL
|
|
19
19
|
config.execution_plan_cleaner = nil
|
|
20
|
-
|
|
20
|
+
yield(config) if block
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
require 'webrick/https'
|
|
2
2
|
|
|
3
|
-
CIPHERS = ['ECDHE-RSA-AES128-GCM-SHA256','ECDHE-RSA-AES256-GCM-SHA384',
|
|
4
|
-
'ECDHE-RSA-AES128-CBC-SHA','ECDHE-RSA-AES256-CBC-SHA',
|
|
5
|
-
'AES128-GCM-SHA256','AES256-GCM-SHA384','AES128-SHA256',
|
|
6
|
-
'AES256-SHA256','AES128-SHA','AES256-SHA']
|
|
3
|
+
CIPHERS = ['ECDHE-RSA-AES128-GCM-SHA256', 'ECDHE-RSA-AES256-GCM-SHA384',
|
|
4
|
+
'ECDHE-RSA-AES128-CBC-SHA', 'ECDHE-RSA-AES256-CBC-SHA',
|
|
5
|
+
'AES128-GCM-SHA256', 'AES256-GCM-SHA384', 'AES128-SHA256',
|
|
6
|
+
'AES256-SHA256', 'AES128-SHA', 'AES256-SHA'].freeze
|
|
7
7
|
|
|
8
8
|
module WEBrick
|
|
9
9
|
class GenericServer
|
|
10
|
+
# rubocop:disable Metrics/AbcSize
|
|
10
11
|
def setup_ssl_context(config) # :nodoc:
|
|
11
12
|
unless config[:SSLCertificate]
|
|
12
13
|
cn = config[:SSLCertName]
|
|
13
14
|
comment = config[:SSLCertComment]
|
|
14
|
-
cert, key = Utils
|
|
15
|
+
cert, key = Utils.create_self_signed_cert(1024, cn, comment)
|
|
15
16
|
config[:SSLCertificate] = cert
|
|
16
17
|
config[:SSLPrivateKey] = key
|
|
17
18
|
end
|
|
@@ -33,5 +34,6 @@ module WEBrick
|
|
|
33
34
|
ctx.options |= config[:SSLOptions] unless config[:SSLOptions].nil?
|
|
34
35
|
ctx
|
|
35
36
|
end
|
|
37
|
+
# rubocop:enable Metrics/AbcSize
|
|
36
38
|
end
|
|
37
39
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'dynflow'
|
|
2
|
+
require 'smart_proxy_dynflow_core/task_launcher_registry'
|
|
2
3
|
require 'foreman_tasks_core'
|
|
3
4
|
require 'smart_proxy_dynflow_core/log'
|
|
4
5
|
require 'smart_proxy_dynflow_core/settings'
|
|
@@ -7,7 +8,9 @@ require 'smart_proxy_dynflow_core/helpers'
|
|
|
7
8
|
require 'smart_proxy_dynflow_core/callback'
|
|
8
9
|
require 'smart_proxy_dynflow_core/api'
|
|
9
10
|
|
|
10
|
-
SmartProxyDynflowCore
|
|
11
|
-
|
|
11
|
+
module SmartProxyDynflowCore
|
|
12
|
+
Core.after_initialize do |dynflow_core|
|
|
13
|
+
ForemanTasksCore.dynflow_setup(dynflow_core.world)
|
|
14
|
+
end
|
|
15
|
+
Core.register_silencer_matchers ForemanTasksCore.silent_dead_letter_matchers
|
|
12
16
|
end
|
|
13
|
-
SmartProxyDynflowCore::Core.register_silencer_matchers ForemanTasksCore.silent_dead_letter_matchers
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
require 'smart_proxy_dynflow_core/version'
|
|
5
4
|
|
|
5
|
+
# rubocop:disable Metrics/BlockLength
|
|
6
6
|
Gem::Specification.new do |gem|
|
|
7
7
|
gem.name = "smart_proxy_dynflow_core"
|
|
8
8
|
gem.version = SmartProxyDynflowCore::VERSION
|
|
@@ -23,18 +23,19 @@ Gem::Specification.new do |gem|
|
|
|
23
23
|
gem.license = 'GPL-3.0'
|
|
24
24
|
|
|
25
25
|
gem.add_development_dependency "bundler", "~> 1.7"
|
|
26
|
-
gem.add_development_dependency "rake", "~> 10.0"
|
|
27
26
|
gem.add_development_dependency('minitest')
|
|
28
27
|
gem.add_development_dependency('mocha', '~> 1')
|
|
29
|
-
gem.add_development_dependency('webmock', '~> 1')
|
|
30
28
|
gem.add_development_dependency('rack-test', '~> 0')
|
|
29
|
+
gem.add_development_dependency "rake", "~> 10.0"
|
|
31
30
|
gem.add_development_dependency('rubocop', '~> 0.52.1')
|
|
31
|
+
gem.add_development_dependency('webmock', '~> 1')
|
|
32
32
|
|
|
33
|
-
gem.add_runtime_dependency('dynflow', "~> 1.
|
|
33
|
+
gem.add_runtime_dependency('dynflow', "~> 1.1")
|
|
34
34
|
gem.add_runtime_dependency('foreman-tasks-core', '>= 0.1.7')
|
|
35
|
-
gem.add_runtime_dependency('sequel')
|
|
36
|
-
gem.add_runtime_dependency('sqlite3')
|
|
37
|
-
gem.add_runtime_dependency('sinatra')
|
|
38
35
|
gem.add_runtime_dependency('rack')
|
|
39
36
|
gem.add_runtime_dependency('rest-client')
|
|
37
|
+
gem.add_runtime_dependency('sequel')
|
|
38
|
+
gem.add_runtime_dependency('sinatra')
|
|
39
|
+
gem.add_runtime_dependency('sqlite3')
|
|
40
40
|
end
|
|
41
|
+
# rubocop:enable Metrics/BlockLength
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smart_proxy_dynflow_core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
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:
|
|
11
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -24,20 +24,6 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.7'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '10.0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '10.0'
|
|
41
27
|
- !ruby/object:Gem::Dependency
|
|
42
28
|
name: minitest
|
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -67,33 +53,33 @@ dependencies:
|
|
|
67
53
|
- !ruby/object:Gem::Version
|
|
68
54
|
version: '1'
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
56
|
+
name: rack-test
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
72
58
|
requirements:
|
|
73
59
|
- - "~>"
|
|
74
60
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
61
|
+
version: '0'
|
|
76
62
|
type: :development
|
|
77
63
|
prerelease: false
|
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
65
|
requirements:
|
|
80
66
|
- - "~>"
|
|
81
67
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
68
|
+
version: '0'
|
|
83
69
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
70
|
+
name: rake
|
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
|
86
72
|
requirements:
|
|
87
73
|
- - "~>"
|
|
88
74
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '0'
|
|
75
|
+
version: '10.0'
|
|
90
76
|
type: :development
|
|
91
77
|
prerelease: false
|
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
79
|
requirements:
|
|
94
80
|
- - "~>"
|
|
95
81
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '0'
|
|
82
|
+
version: '10.0'
|
|
97
83
|
- !ruby/object:Gem::Dependency
|
|
98
84
|
name: rubocop
|
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -108,20 +94,34 @@ dependencies:
|
|
|
108
94
|
- - "~>"
|
|
109
95
|
- !ruby/object:Gem::Version
|
|
110
96
|
version: 0.52.1
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: webmock
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '1'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '1'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: dynflow
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - "~>"
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: '1.
|
|
117
|
+
version: '1.1'
|
|
118
118
|
type: :runtime
|
|
119
119
|
prerelease: false
|
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
|
122
122
|
- - "~>"
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: '1.
|
|
124
|
+
version: '1.1'
|
|
125
125
|
- !ruby/object:Gem::Dependency
|
|
126
126
|
name: foreman-tasks-core
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -137,7 +137,7 @@ dependencies:
|
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
138
|
version: 0.1.7
|
|
139
139
|
- !ruby/object:Gem::Dependency
|
|
140
|
-
name:
|
|
140
|
+
name: rack
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
142
142
|
requirements:
|
|
143
143
|
- - ">="
|
|
@@ -151,7 +151,7 @@ dependencies:
|
|
|
151
151
|
- !ruby/object:Gem::Version
|
|
152
152
|
version: '0'
|
|
153
153
|
- !ruby/object:Gem::Dependency
|
|
154
|
-
name:
|
|
154
|
+
name: rest-client
|
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
|
156
156
|
requirements:
|
|
157
157
|
- - ">="
|
|
@@ -165,7 +165,7 @@ dependencies:
|
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
166
|
version: '0'
|
|
167
167
|
- !ruby/object:Gem::Dependency
|
|
168
|
-
name:
|
|
168
|
+
name: sequel
|
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
|
170
170
|
requirements:
|
|
171
171
|
- - ">="
|
|
@@ -179,7 +179,7 @@ dependencies:
|
|
|
179
179
|
- !ruby/object:Gem::Version
|
|
180
180
|
version: '0'
|
|
181
181
|
- !ruby/object:Gem::Dependency
|
|
182
|
-
name:
|
|
182
|
+
name: sinatra
|
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
|
184
184
|
requirements:
|
|
185
185
|
- - ">="
|
|
@@ -193,7 +193,7 @@ dependencies:
|
|
|
193
193
|
- !ruby/object:Gem::Version
|
|
194
194
|
version: '0'
|
|
195
195
|
- !ruby/object:Gem::Dependency
|
|
196
|
-
name:
|
|
196
|
+
name: sqlite3
|
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
|
198
198
|
requirements:
|
|
199
199
|
- - ">="
|
|
@@ -229,6 +229,7 @@ files:
|
|
|
229
229
|
- lib/smart_proxy_dynflow_core/launcher.rb
|
|
230
230
|
- lib/smart_proxy_dynflow_core/log.rb
|
|
231
231
|
- lib/smart_proxy_dynflow_core/settings.rb
|
|
232
|
+
- lib/smart_proxy_dynflow_core/task_launcher_registry.rb
|
|
232
233
|
- lib/smart_proxy_dynflow_core/testing.rb
|
|
233
234
|
- lib/smart_proxy_dynflow_core/version.rb
|
|
234
235
|
- lib/smart_proxy_dynflow_core/webrick-patch.rb
|