smart_proxy_dynflow_core 0.1.7 → 0.1.8
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/config/settings.yml.example +4 -0
- data/lib/smart_proxy_dynflow_core.rb +1 -0
- data/lib/smart_proxy_dynflow_core/api.rb +14 -2
- data/lib/smart_proxy_dynflow_core/core.rb +20 -0
- data/lib/smart_proxy_dynflow_core/helpers.rb +22 -0
- data/lib/smart_proxy_dynflow_core/settings.rb +3 -1
- data/lib/smart_proxy_dynflow_core/testing.rb +1 -0
- data/lib/smart_proxy_dynflow_core/version.rb +1 -1
- data/smart_proxy_dynflow_core.gemspec +2 -2
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9fe367597def9db9fbd344fb30b4dd9c5d19435
|
4
|
+
data.tar.gz: 9db49d78b52c33ae93481ffa39ba66cd8bacb1c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa39c7be9ff794204f60c6ace3a8e307d67316bd65c0f8a5da88423a4632b6358d9a8f405c3b94bf53c4448b415b6682e68de73330a435518448bf5f722920e9
|
7
|
+
data.tar.gz: 80e21a265765399083b5636fb1231471c67306ad6a0006af59caa50d80b1312c3c9ee650bcc07bc0337f86cb36c8609fb6d9f9a05561861a76db3a0cbe779cdc
|
data/config/settings.yml.example
CHANGED
@@ -39,3 +39,7 @@
|
|
39
39
|
|
40
40
|
# Log level, one of UNKNOWN, FATAL, ERROR, WARN, INFO, DEBUG
|
41
41
|
# :log_level: ERROR
|
42
|
+
|
43
|
+
# Maximum age of execution plans to keep before having them cleaned
|
44
|
+
# by the execution plan cleaner (in seconds), defaults to 24 hours
|
45
|
+
# :execution_plan_cleaner_age: 86400
|
@@ -7,13 +7,14 @@ module SmartProxyDynflowCore
|
|
7
7
|
|
8
8
|
before do
|
9
9
|
logger = Log.instance
|
10
|
-
authorize_with_ssl_client
|
10
|
+
authorize_with_token || authorize_with_ssl_client
|
11
11
|
content_type :json
|
12
12
|
end
|
13
13
|
|
14
14
|
post "/tasks/?" do
|
15
15
|
params = MultiJson.load(request.body.read)
|
16
|
-
trigger_task(::Dynflow::Utils.constantize(params['action_name']),
|
16
|
+
trigger_task(::Dynflow::Utils.constantize(params['action_name']),
|
17
|
+
params['action_input'].merge(:callback_host => callback_host(params, request))).to_json
|
17
18
|
end
|
18
19
|
|
19
20
|
post "/tasks/:task_id/cancel" do |task_id|
|
@@ -27,5 +28,16 @@ module SmartProxyDynflowCore
|
|
27
28
|
get "/tasks/count" do
|
28
29
|
tasks_count(params['state']).to_json
|
29
30
|
end
|
31
|
+
|
32
|
+
post "/tasks/:task_id/done" do |task_id|
|
33
|
+
data = MultiJson.load(request.body.read)
|
34
|
+
complete_task(task_id, data)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def callback_host(params, request)
|
40
|
+
params.fetch('action_input', {})['proxy_url'] || request.env.values_at('HTTP_X_FORWARDED_FOR', 'HTTP_HOST').compact.first
|
41
|
+
end
|
30
42
|
end
|
31
43
|
end
|
@@ -42,6 +42,10 @@ module SmartProxyDynflowCore
|
|
42
42
|
config.auto_rescue = true
|
43
43
|
config.logger_adapter = logger_adapter
|
44
44
|
config.persistence_adapter = persistence_adapter
|
45
|
+
config.execution_plan_cleaner = execution_plan_cleaner
|
46
|
+
# TODO: There has to be a better way
|
47
|
+
matchers = config.silent_dead_letter_matchers.call().concat(self.class.silencer_matchers)
|
48
|
+
config.silent_dead_letter_matchers = matchers
|
45
49
|
yield config if block_given?
|
46
50
|
end
|
47
51
|
end
|
@@ -54,6 +58,14 @@ module SmartProxyDynflowCore
|
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
61
|
+
def execution_plan_cleaner
|
62
|
+
proc do |world|
|
63
|
+
age = Settings.instance.execution_plan_cleaner_age
|
64
|
+
options = { :poll_interval => age, :max_age => age }
|
65
|
+
::Dynflow::Actors::ExecutionPlanCleaner.new(world, options)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
57
69
|
class << self
|
58
70
|
attr_reader :instance
|
59
71
|
|
@@ -64,6 +76,14 @@ module SmartProxyDynflowCore
|
|
64
76
|
@instance
|
65
77
|
end
|
66
78
|
|
79
|
+
def silencer_matchers
|
80
|
+
@matchers ||= []
|
81
|
+
end
|
82
|
+
|
83
|
+
def register_silencer_matchers(matchers)
|
84
|
+
silencer_matchers.concat matchers
|
85
|
+
end
|
86
|
+
|
67
87
|
def web_console
|
68
88
|
require 'dynflow/web'
|
69
89
|
dynflow_console = ::Dynflow::Web.setup do
|
@@ -4,6 +4,22 @@ module SmartProxyDynflowCore
|
|
4
4
|
SmartProxyDynflowCore::Core.world
|
5
5
|
end
|
6
6
|
|
7
|
+
def authorize_with_token
|
8
|
+
if request.env.key? 'HTTP_AUTHORIZATION'
|
9
|
+
if defined?(::ForemanTasksCore)
|
10
|
+
auth = request.env['HTTP_AUTHORIZATION']
|
11
|
+
basic_prefix = /\ABasic /
|
12
|
+
if !auth.to_s.empty? && auth =~ basic_prefix &&
|
13
|
+
ForemanTasksCore::OtpManager.authenticate(auth.gsub(basic_prefix, ''))
|
14
|
+
Log.instance.debug('authorized with token')
|
15
|
+
return true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
halt 403, MultiJson.dump(:error => 'Invalid username or password supplied')
|
19
|
+
end
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
7
23
|
def authorize_with_ssl_client
|
8
24
|
if %w(yes on 1).include? request.env['HTTPS'].to_s
|
9
25
|
if request.env['SSL_CLIENT_CERT'].to_s.empty?
|
@@ -46,5 +62,11 @@ module SmartProxyDynflowCore
|
|
46
62
|
tasks = world.persistence.find_execution_plans(filter)
|
47
63
|
{ :count => tasks.count, :state => state }
|
48
64
|
end
|
65
|
+
|
66
|
+
def complete_task(task_id, params)
|
67
|
+
world.event(task_id,
|
68
|
+
params['step_id'].to_i,
|
69
|
+
::ForemanTasksCore::Runner::ExternalEvent.new(params))
|
70
|
+
end
|
49
71
|
end
|
50
72
|
end
|
@@ -40,13 +40,15 @@ module SmartProxyDynflowCore
|
|
40
40
|
:plugins => {},
|
41
41
|
:pid_file => '/var/run/foreman-proxy/smart_proxy_dynflow_core.pid',
|
42
42
|
:daemonize => false,
|
43
|
+
:execution_plan_cleaner_age => 60 * 60 * 24,
|
43
44
|
:loaded => false
|
44
45
|
}
|
45
46
|
|
46
47
|
PROXY_SETTINGS = [:ssl_ca_file, :ssl_certificate, :ssl_private_key, :foreman_url,
|
47
48
|
:foreman_ssl_ca, :foreman_ssl_cert, :foreman_ssl_key,
|
48
49
|
:log_file, :log_level, :ssl_disabled_ciphers]
|
49
|
-
PLUGIN_SETTINGS = [:database, :core_url, :console_auth
|
50
|
+
PLUGIN_SETTINGS = [:database, :core_url, :console_auth,
|
51
|
+
:execution_plan_cleaner_age]
|
50
52
|
|
51
53
|
def initialize(settings = {})
|
52
54
|
super(DEFAULT_SETTINGS.merge(settings))
|
@@ -16,6 +16,7 @@ module SmartProxyDynflowCore
|
|
16
16
|
config.exit_on_terminate = false
|
17
17
|
config.auto_terminate = false
|
18
18
|
config.logger_adapter = ::Dynflow::LoggerAdapters::Simple.new $stderr, DYNFLOW_TESTING_LOG_LEVEL
|
19
|
+
config.execution_plan_cleaner = nil
|
19
20
|
block.call(config) if block
|
20
21
|
end
|
21
22
|
end
|
@@ -30,8 +30,8 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.add_development_dependency('rack-test', '~> 0')
|
31
31
|
gem.add_development_dependency('rubocop', '0.32.1')
|
32
32
|
|
33
|
-
gem.add_runtime_dependency('
|
34
|
-
gem.add_runtime_dependency('
|
33
|
+
gem.add_runtime_dependency('dynflow', "~> 0.8.29")
|
34
|
+
gem.add_runtime_dependency('foreman-tasks-core', '>= 0.1.7')
|
35
35
|
gem.add_runtime_dependency('sequel')
|
36
36
|
gem.add_runtime_dependency('sqlite3')
|
37
37
|
gem.add_runtime_dependency('sinatra', '~> 1.4')
|
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.1.
|
4
|
+
version: 0.1.8
|
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: 2017-
|
11
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,33 +109,33 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.32.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: dynflow
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.8.29
|
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:
|
124
|
+
version: 0.8.29
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: foreman-tasks-core
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - "
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.
|
131
|
+
version: 0.1.7
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - "
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
138
|
+
version: 0.1.7
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: sequel
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
254
|
version: '0'
|
255
255
|
requirements: []
|
256
256
|
rubyforge_project:
|
257
|
-
rubygems_version: 2.
|
257
|
+
rubygems_version: 2.6.12
|
258
258
|
signing_key:
|
259
259
|
specification_version: 4
|
260
260
|
summary: Dynflow runtime for Foreman smart proxy
|