smart_proxy_dynflow_core 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aedf4520542db023767dec95a15abf5f101e5ed4
4
- data.tar.gz: 3c84a4333058d2190f1bacbf8c8613137f671614
3
+ metadata.gz: fe1b9027d6be956e15fb935a09a4c605af906509
4
+ data.tar.gz: 541d1bded54dc876f331dabcf44e89ae35996e15
5
5
  SHA512:
6
- metadata.gz: 60b2d80e2f9db98f2e551685f2a3231539776f28f2b077a61b49c9ae19a63d2cc932d0486a4b7a6c3116a78d65fe66097b8615528eb1eef9332893908712ed6e
7
- data.tar.gz: e44223fec0d48f399dd1dbc885334dea311c83797457a1d36e799cc2cb1852ef2aaab8c524a03427d32c4d832af9f00e7b2606786c0340ad8c9fda22187369f7
6
+ metadata.gz: 2f51f45104e278ce3c23f566018cd80bfb972cb6c62c58606d5c8926c7f738381e11f170b888339b582ad0274c6551de5e643bb749d29cd3b86c90940ef7f9cc
7
+ data.tar.gz: c860021c0d3a466a5dd630edfeedb1b1ed3e17844f591ad471426ee703e473a0adf2b93aaea0199f23e976f01fe5325fb83ddfb48607e8ab20eb67158169578e
@@ -1,6 +1,5 @@
1
1
  require 'sinatra/base'
2
2
  require 'multi_json'
3
- require 'dynflow'
4
3
 
5
4
  module SmartProxyDynflowCore
6
5
  class Api < ::Sinatra::Base
@@ -1,5 +1,4 @@
1
1
  require 'rest-client'
2
- require 'dynflow'
3
2
 
4
3
  begin
5
4
  require 'smart_proxy_dynflow/callback'
@@ -8,6 +7,16 @@ end
8
7
 
9
8
  module SmartProxyDynflowCore
10
9
  module Callback
10
+ class Action < Dynflow::Action
11
+ def plan(callback, data)
12
+ plan_self(:callback => callback, :data => data)
13
+ end
14
+
15
+ def run
16
+ Request.send_to_foreman_tasks(input[:callback], input[:data])
17
+ end
18
+ end
19
+
11
20
  class Request
12
21
  def callback(payload)
13
22
  response = callback_resource.post(payload, :content_type => :json)
@@ -60,7 +60,7 @@ module SmartProxyDynflowCore
60
60
  def ensure_initialized
61
61
  return @instance if @instance
62
62
  @instance = Core.new
63
- after_initialize_blocks.each(&:call)
63
+ after_initialize_blocks.each { |block| block.call(@instance) }
64
64
  @instance
65
65
  end
66
66
 
@@ -7,15 +7,13 @@ module SmartProxyDynflowCore
7
7
  def authorize_with_ssl_client
8
8
  if %w(yes on 1).include? request.env['HTTPS'].to_s
9
9
  if request.env['SSL_CLIENT_CERT'].to_s.empty?
10
- status 403
11
10
  Log.instance.error "No client SSL certificate supplied"
12
- halt MultiJson.dump(:error => "No client SSL certificate supplied")
11
+ halt 403, MultiJson.dump(:error => "No client SSL certificate supplied")
13
12
  else
14
13
  client_cert = OpenSSL::X509::Certificate.new(request.env['SSL_CLIENT_CERT'])
15
14
  unless SmartProxyDynflowCore::Core.instance.accepted_cert_serial == client_cert.serial
16
15
  Log.instance.error "SSL certificate with unexpected serial supplied"
17
- halt MultiJson.dump(:error => "SSL certificate with unexpected serial supplied")
18
- status 403
16
+ halt 403, MultiJson.dump(:error => "SSL certificate with unexpected serial supplied")
19
17
  end
20
18
  end
21
19
  else
@@ -117,6 +117,16 @@ module SmartProxyDynflowCore
117
117
  Dir[File.join(dir, 'settings.d', '*.yml')].each { |path| Settings.load_plugin_settings(path) }
118
118
  true
119
119
  end
120
+ ForemanTasksCore::SettingsLoader.settings_registry.keys.each do |settings_keys|
121
+ settings = settings_keys.inject({}) do |h, settings_key|
122
+ if SETTINGS.plugins.key?(settings_key.to_s)
123
+ h.merge(SETTINGS.plugins[settings_key.to_s].to_h)
124
+ else
125
+ h
126
+ end
127
+ end
128
+ ForemanTasksCore::SettingsLoader.setup_settings(settings_keys.first, settings)
129
+ end
120
130
  end
121
131
  end
122
132
  end
@@ -1,5 +1,4 @@
1
1
  require 'logger'
2
- require 'dynflow'
3
2
 
4
3
  module SmartProxyDynflowCore
5
4
  class Log < ::Logger
@@ -69,12 +69,13 @@ module SmartProxyDynflowCore
69
69
  Log.reload!
70
70
  end
71
71
 
72
- def self.load_from_proxy(settings)
72
+ def self.load_from_proxy(plugin)
73
+ settings = plugin[:class].settings.to_h
73
74
  PROXY_SETTINGS.each do |key|
74
75
  SETTINGS[key] = Proxy::SETTINGS[key]
75
76
  end
76
77
  PLUGIN_SETTINGS.each do |key|
77
- SETTINGS[key] = settings[key]
78
+ SETTINGS[key] = settings[key] if settings.key?(key)
78
79
  end
79
80
  SETTINGS.plugins.values.each { |plugin| plugin.load_settings_from_proxy }
80
81
  Settings.loaded!
@@ -1,3 +1,3 @@
1
1
  module SmartProxyDynflowCore
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -1,6 +1,12 @@
1
+ require 'dynflow'
2
+ require 'foreman_tasks_core'
1
3
  require 'smart_proxy_dynflow_core/log'
2
4
  require 'smart_proxy_dynflow_core/settings'
3
5
  require 'smart_proxy_dynflow_core/core'
4
6
  require 'smart_proxy_dynflow_core/helpers'
5
7
  require 'smart_proxy_dynflow_core/callback'
6
8
  require 'smart_proxy_dynflow_core/api'
9
+
10
+ SmartProxyDynflowCore::Core.after_initialize do |dynflow_core|
11
+ ForemanTasksCore.dynflow_setup(dynflow_core.world)
12
+ end
@@ -30,6 +30,7 @@ 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('foreman-tasks-core', '~> 0.1.0')
33
34
  gem.add_runtime_dependency('dynflow', "~> 0.8.4")
34
35
  gem.add_runtime_dependency('sequel')
35
36
  gem.add_runtime_dependency('sqlite3')
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
4
+ version: 0.1.5
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: 2016-08-18 00:00:00.000000000 Z
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.32.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: foreman-tasks-core
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.1.0
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: dynflow
113
127
  requirement: !ruby/object:Gem::Requirement