foreman-tasks-core 0.1.8 → 0.2.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
  SHA1:
3
- metadata.gz: f8dd7e1a045b304faf9b0d322a06aaa7b41f9c64
4
- data.tar.gz: 3a3052310c69eaaa79bdf09ff1ea8fd19ae2e810
3
+ metadata.gz: 82c45ce63472dd3fa8bdc0d67753e06c71493fa9
4
+ data.tar.gz: b45d72c387ea36571f352838cf56b356928f6aeb
5
5
  SHA512:
6
- metadata.gz: 615b75e6c9397f65d57beae92f0d46377933295f1f70eae0705684dee53124f4c9ce7081a92b042dcd092ea5c3434355fd949ca85a41f589b7bde4f47bf23fd7
7
- data.tar.gz: f757085186d4d1330f4e743876b0f5eb7793cbe4f4c6e2e8d59e26a8e727e27099c05fd9b82b1a31951a98dcbdf742671a0678e998e748b08112d76981a7e16b
6
+ metadata.gz: 7ca8912319a39eb83bbb1d278b0248ba4d285c7c930abfc2f7a203bc4e3485d2d770a228b41bb9e391b2df220a1eb979ad578b2968732766542daa0bde6338ff
7
+ data.tar.gz: e6f3570c0d8aaa850c0d7a2c7e60f6168622e06c8ed5679dfc35f18c7f33ca821a9ccb3fe1e7840b2c85d98a5ef6e2cbf3f70cebd84e8859db7213d7b772000d
@@ -1,10 +1,7 @@
1
1
  # The goal of ForemanTasksCore is to collect parts of foreman-tasks
2
2
  # that can be shared by the Foreman server and Foreman proxy
3
3
 
4
- require 'dynflow'
5
4
  require 'foreman_tasks_core/settings_loader'
6
- require 'foreman_tasks_core/otp_manager'
7
- require 'foreman_tasks_core/ticker'
8
5
 
9
6
  module ForemanTasksCore
10
7
  def self.dynflow_world
@@ -19,8 +16,4 @@ module ForemanTasksCore
19
16
  def self.dynflow_setup(dynflow_world)
20
17
  @dynflow_world = dynflow_world
21
18
  end
22
-
23
- def self.silent_dead_letter_matchers
24
- [::Dynflow::DeadLetterSilencer::Matcher.new(ForemanTasksCore::Ticker)]
25
- end
26
19
  end
@@ -10,8 +10,6 @@ module ForemanTasksCore
10
10
  init_run
11
11
  when Runner::Update
12
12
  process_update(event)
13
- when Runner::ExternalEvent
14
- process_external_event(event)
15
13
  when ::Dynflow::Action::Cancellable::Cancel
16
14
  kill_run
17
15
  else
@@ -54,11 +52,6 @@ module ForemanTasksCore
54
52
  output[:exit_status] = update.exit_status
55
53
  end
56
54
 
57
- def process_external_event(event)
58
- runner_dispatcher.external_event(output[:runner_id], event)
59
- suspend
60
- end
61
-
62
55
  def process_update(update)
63
56
  output[:result].concat(update.continuous_output.raw_outputs)
64
57
  if update.exit_status
@@ -10,7 +10,7 @@ module ForemanTasksCore
10
10
  end
11
11
 
12
12
  class RunnerActor < ::Dynflow::Actor
13
- def initialize(dispatcher, suspended_action, runner, clock, logger, _options = {})
13
+ def initialize(dispatcher, suspended_action, runner, clock, logger, options = {})
14
14
  @dispatcher = dispatcher
15
15
  @clock = clock
16
16
  @ticker = dispatcher.ticker
@@ -18,6 +18,7 @@ module ForemanTasksCore
18
18
  @suspended_action = suspended_action
19
19
  @runner = runner
20
20
  @finishing = false
21
+ @refresh_interval = options[:refresh_interval] || 1
21
22
  end
22
23
 
23
24
  def on_envelope(*args)
@@ -73,10 +74,6 @@ module ForemanTasksCore
73
74
  finish_termination
74
75
  end
75
76
 
76
- def external_event(_event)
77
- refresh_runner
78
- end
79
-
80
77
  private
81
78
 
82
79
  def set_timeout
@@ -103,7 +100,7 @@ module ForemanTasksCore
103
100
  @mutex = Mutex.new
104
101
  @clock = clock
105
102
  @logger = logger
106
- @ticker = ::ForemanTasksCore::Ticker.spawn('dispatcher-ticker', @clock, @logger, refresh_interval)
103
+ @ticker = ::ForemanTasksCore::Ticker.spawn('dispatcher-ticker', @clock, @logger)
107
104
  @runner_actors = {}
108
105
  @runner_suspended_actions = {}
109
106
  end
@@ -150,21 +147,10 @@ module ForemanTasksCore
150
147
  end
151
148
  end
152
149
 
153
- def external_event(runner_id, external_event)
154
- synchronize do
155
- runner_actor = @runner_actors[runner_id]
156
- runner_actor.tell([:external_event, external_event]) if runner_actor
157
- end
158
- end
159
-
160
150
  def handle_command_exception(*args)
161
151
  synchronize { _handle_command_exception(*args) }
162
152
  end
163
153
 
164
- def refresh_interval
165
- 1
166
- end
167
-
168
154
  private
169
155
 
170
156
  def _finish(runner_id)
@@ -17,12 +17,5 @@ module ForemanTasksCore
17
17
  new(continuous_output, fatal ? 'EXCEPTION' : nil)
18
18
  end
19
19
  end
20
-
21
- class ExternalEvent
22
- attr_reader :data
23
- def initialize(data = {})
24
- @data = data
25
- end
26
- end
27
20
  end
28
21
  end
@@ -2,11 +2,11 @@ module ForemanTasksCore
2
2
  class Ticker < ::Dynflow::Actor
3
3
  attr_reader :clock
4
4
 
5
- def initialize(clock, logger, refresh_interval)
5
+ def initialize(clock, logger)
6
6
  @clock = clock
7
7
  @logger = logger
8
8
  @events = []
9
- @refresh_interval = refresh_interval
9
+ @refresh_interval = 1
10
10
  plan_next_tick
11
11
  end
12
12
 
@@ -1,3 +1,3 @@
1
1
  module ForemanTasksCore
2
- VERSION = '0.1.8'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.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: 2017-09-22 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Common code used both at Forman and Foreman proxy regarding tasks
@@ -21,7 +21,6 @@ files:
21
21
  - LICENSE
22
22
  - lib/foreman_tasks_core.rb
23
23
  - lib/foreman_tasks_core/continuous_output.rb
24
- - lib/foreman_tasks_core/otp_manager.rb
25
24
  - lib/foreman_tasks_core/runner.rb
26
25
  - lib/foreman_tasks_core/runner/action.rb
27
26
  - lib/foreman_tasks_core/runner/base.rb
@@ -51,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
50
  version: '0'
52
51
  requirements: []
53
52
  rubyforge_project:
54
- rubygems_version: 2.6.12
53
+ rubygems_version: 2.4.5
55
54
  signing_key:
56
55
  specification_version: 4
57
56
  summary: Common code used both at Forman and Foreman proxy regarding tasks
@@ -1,31 +0,0 @@
1
- require 'base64'
2
- require 'securerandom'
3
-
4
- module ForemanTasksCore
5
- class OtpManager
6
- class << self
7
- def generate_otp(username)
8
- otp = SecureRandom.hex
9
- passwords[username] = otp.to_s
10
- end
11
-
12
- def drop_otp(username, password)
13
- passwords.delete(username) if passwords[username] == password
14
- end
15
-
16
- def passwords
17
- @password ||= {}
18
- end
19
-
20
- def authenticate(hash)
21
- plain = Base64.decode64(hash)
22
- username, otp = plain.split(':', 2)
23
- drop_otp(username, otp)
24
- end
25
-
26
- def tokenize(username, password)
27
- Base64.strict_encode64("#{username}:#{password}")
28
- end
29
- end
30
- end
31
- end