smart_proxy_dynflow 0.5.1 → 0.6.2

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: e9d6cea06294915fa84d7b26d9ece58ee0ffd80f338edef46ca2125b8426aeb4
4
- data.tar.gz: 0e133744d22ec2d9e35a4663cbcbe7466cfe162aacbbd85aaf166727156a9f51
3
+ metadata.gz: 993736ce6d5ac64679839ee2b724956021f823904893863d13e22483e7ad5f48
4
+ data.tar.gz: 98299433eff4fb8c382c5cbb9cd74f5e0f062ff2c595ce14638e012329c3f560
5
5
  SHA512:
6
- metadata.gz: d9f6e160782a439619bb500a6844d1b9a6a3d3929295e1b19bf2c4ef4b9eebdc246c22a0f8f4fd863b10524bf08025798af0933b4023dfe3f6235b123eded2e4
7
- data.tar.gz: 12adb0be784f291d6493ece13b6d7fa7256968321eeca05bf5d21e5ab08c44be12de67c271a63f01196e23079734055b143e4b7a2d2c3eee9ce53ebf8519e8cc
6
+ metadata.gz: ef12614f425197f81ca6675b62194035a1f63a74e83865b1d1423b9e24ff7a1571b86634a5fd247756b3e035198909ce289455423a5be7f04918e7c6275b1032
7
+ data.tar.gz: f7d8da665d8e958cca84309cd887b50dc5fc2959e1b5df7302ce398d8da49a3eea5549793bfc1665b4369846da6a46e20048d265d371aafa586d3c301f24ad69
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec :name => 'smart_proxy_dynflow_core'
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
 
@@ -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
- SmartProxyDynflowCore::Callback::Request.new.callback({ :callbacks => payload }.to_json)
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 = SmartProxyDynflowCore::TaskLauncherRegistry.fetch(input[:operation])
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
@@ -0,0 +1,17 @@
1
+ module Proxy::Dynflow::Action
2
+ module WithExternalPolling
3
+ Poll = Algebrick.atom
4
+
5
+ def run(event = nil)
6
+ if event.is_a?(Poll)
7
+ poll
8
+ suspend
9
+ else
10
+ super
11
+ end
12
+ end
13
+
14
+ def poll
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  module Proxy::Dynflow::Action
2
- class OutputCollector < ::Proxy::Dynflow::Runner::Action
2
+ class OutputCollector < ::Proxy::Dynflow::Action::Runner
3
3
  def init_run
4
4
  output[:result] = []
5
5
  suspend
@@ -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
- output[:result].concat(update.continuous_output.raw_outputs)
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 + (@pending_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(SmartProxyDynflowCore::Callback::Action, callback, planned_action.output)
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
- defined?(SmartProxyDynflowCore::Callback)
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
- class << self
7
- def send_to_foreman_tasks(callback_info, data)
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
- response = callback_resource.post(payload, :content_type => :json)
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
- ep.to_hash.merge(:actions => ep.actions.map(&:to_hash))
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
@@ -0,0 +1,46 @@
1
+ # TypeProf 0.21.2
2
+
3
+ # Classes
4
+ module Proxy
5
+ module Dynflow
6
+ class IOBuffer
7
+ @callback: nil
8
+
9
+ attr_accessor io: nil
10
+ attr_reader buffer: String
11
+ def initialize: (nil io) -> void
12
+ def on_data: -> nil
13
+ def to_io: -> IO
14
+ def to_s: -> String
15
+ def empty?: -> bool
16
+ def closed?: -> untyped
17
+ def close: -> nil
18
+ def read_available!: -> nil
19
+ def write_available!: -> nil
20
+ def add_data: (untyped data) -> String
21
+
22
+ private
23
+ def with_callback: (String? data) -> String?
24
+ end
25
+
26
+ class ProcessManager
27
+ @command: untyped
28
+
29
+ attr_reader stdin: IOBuffer
30
+ attr_reader stdout: IOBuffer
31
+ attr_reader stderr: IOBuffer
32
+ attr_reader pid: Integer
33
+ attr_reader status: Integer?
34
+ def initialize: (untyped command) -> void
35
+ def run!: -> ProcessManager
36
+ def start!: -> String
37
+ def started?: -> bool
38
+ def done?: -> bool
39
+ def close: -> [IOBuffer, IOBuffer, IOBuffer]
40
+ def process: (?timeout: nil) -> Array[untyped]?
41
+ def finish: -> Integer?
42
+ def on_stdout: -> nil
43
+ def on_stderr: -> nil
44
+ end
45
+ end
46
+ end
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module Dynflow
3
- VERSION = '0.5.1'.freeze
3
+ VERSION = '0.6.2'.freeze
4
4
  end
5
5
  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.5.1
4
+ version: 0.6.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: 2021-06-15 00:00:00.000000000 Z
11
+ date: 2022-02-17 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.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.1'
26
+ version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rest-client
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -146,11 +146,14 @@ files:
146
146
  - Gemfile
147
147
  - LICENSE
148
148
  - bundler.d/dynflow.rb
149
+ - bundler.d/inspect_anything.rb
150
+ - bundler.d/x.local.rb
149
151
  - lib/smart_proxy_dynflow.rb
150
152
  - lib/smart_proxy_dynflow/action.rb
151
153
  - lib/smart_proxy_dynflow/action/batch.rb
152
154
  - lib/smart_proxy_dynflow/action/batch_callback.rb
153
155
  - lib/smart_proxy_dynflow/action/batch_runner.rb
156
+ - lib/smart_proxy_dynflow/action/external_polling.rb
154
157
  - lib/smart_proxy_dynflow/action/output_collector.rb
155
158
  - lib/smart_proxy_dynflow/action/runner.rb
156
159
  - lib/smart_proxy_dynflow/action/shareable.rb
@@ -165,6 +168,7 @@ files:
165
168
  - lib/smart_proxy_dynflow/middleware/keep_current_request_id.rb
166
169
  - lib/smart_proxy_dynflow/otp_manager.rb
167
170
  - lib/smart_proxy_dynflow/plugin.rb
171
+ - lib/smart_proxy_dynflow/process_manager.rbs
168
172
  - lib/smart_proxy_dynflow/proxy_adapter.rb
169
173
  - lib/smart_proxy_dynflow/runner.rb
170
174
  - lib/smart_proxy_dynflow/runner/base.rb
@@ -195,7 +199,7 @@ require_paths:
195
199
  - lib
196
200
  required_ruby_version: !ruby/object:Gem::Requirement
197
201
  requirements:
198
- - - "~>"
202
+ - - ">="
199
203
  - !ruby/object:Gem::Version
200
204
  version: '2.5'
201
205
  required_rubygems_version: !ruby/object:Gem::Requirement