foreman-tasks-core 0.1.1 → 0.1.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
  SHA1:
3
- metadata.gz: 2d33e3c510526b078873ccdddbb5f164f9b6d0df
4
- data.tar.gz: 4d6693cf71fd52035ed119e0ae71bf3d2bbd6dfe
3
+ metadata.gz: 7182c93db320880e8ab630c2edcfef6baa2f6ce0
4
+ data.tar.gz: b578ed3de2672e41910921ad1b5cfe0cc1872f6b
5
5
  SHA512:
6
- metadata.gz: bd9a840a4ea81bdb19fd9f2538fd3ca943e21eeca329d08001ccbf99d01f8bc45ee2750eac1b10fb6c73dc0d56557d2309cf4458197327dacc3b9e44eef6710e
7
- data.tar.gz: a1c757b94c63caaea74ce464e52150c64e305909900ab87afae20b0deca18a834ac8c8dbdd5e4f006b1d2a915229b04c374b47691bcb6b7a2187766c17ebf92e
6
+ metadata.gz: 4f8d31d820535c4ed018bad60c64710579f31761f3c0cd16477ee776233a0b98498f57821e72899275c20f9b2de8d3a780d5b4dcfa4ccd4e5db2a51b801a2d54
7
+ data.tar.gz: 9c6c676b311f5d9507765409df16d1c49c72f3da1fea223d9c3496312a62048219cf89197f81aa5787a505b4f7204eb8f6ee6d0e8fd7631badddb08d6e7d346a
@@ -5,7 +5,7 @@ require 'foreman_tasks_core/settings_loader'
5
5
 
6
6
  module ForemanTasksCore
7
7
  def self.dynflow_world
8
- raise "Dynflow world not set. Call initialize first" unless @dynflow_world
8
+ raise 'Dynflow world not set. Call initialize first' unless @dynflow_world
9
9
  @dynflow_world
10
10
  end
11
11
 
@@ -8,7 +8,7 @@ module ForemanTasksCore
8
8
  end
9
9
 
10
10
  def add_raw_output(raw_output)
11
- missing_args = %w[output_type output timestamp] - raw_output.keys
11
+ missing_args = %w(output_type output timestamp) - raw_output.keys
12
12
  unless missing_args.empty?
13
13
  raise ArgumentError, "Missing args for raw output: #{missing_args.inspect}"
14
14
  end
@@ -17,12 +17,12 @@ module ForemanTasksCore
17
17
  end
18
18
  rescue => e
19
19
  action_logger.error(e)
20
- process_update(Runner::Update.encode_exception("Proxy error", e))
20
+ process_update(Runner::Update.encode_exception('Proxy error', e))
21
21
  end
22
22
 
23
23
  def finalize
24
24
  # To mark the task as a whole as failed
25
- error! "Script execution failed" if failed_run?
25
+ error! 'Script execution failed' if failed_run?
26
26
  end
27
27
 
28
28
  def rescue_strategy_for_self
@@ -6,7 +6,7 @@ module ForemanTasksCore
6
6
  attr_reader :id
7
7
  attr_accessor :logger
8
8
 
9
- def initialize(*args)
9
+ def initialize(*_args)
10
10
  @id = SecureRandom.uuid
11
11
  @continuous_output = ::ForemanTasksCore::ContinuousOutput.new
12
12
  end
@@ -16,7 +16,7 @@ module ForemanTasksCore
16
16
  end
17
17
 
18
18
  def run_refresh
19
- logger.debug("refreshing runner")
19
+ logger.debug('refreshing runner')
20
20
  refresh
21
21
  new_data = @continuous_output
22
22
  @continuous_output = ForemanTasksCore::ContinuousOutput.new
@@ -17,7 +17,7 @@ module ForemanTasksCore
17
17
  else
18
18
  close_io
19
19
  Process.wait(@command_pid)
20
- publish_exit_status($?.exitstatus)
20
+ publish_exit_status($CHILD_STATUS.exitstatus)
21
21
  end
22
22
  publish_data(lines, 'stdout') if lines && !lines.empty?
23
23
  end
@@ -3,8 +3,8 @@ module ForemanTasksCore
3
3
  class Dispatcher
4
4
  def self.instance
5
5
  return @instance if @instance
6
- @instance = self.new(ForemanTasksCore.dynflow_world.clock,
7
- ForemanTasksCore.dynflow_world.logger)
6
+ @instance = new(ForemanTasksCore.dynflow_world.clock,
7
+ ForemanTasksCore.dynflow_world.logger)
8
8
  end
9
9
 
10
10
  class RunnerActor < ::Dynflow::Actor
@@ -34,7 +34,7 @@ module ForemanTasksCore
34
34
 
35
35
  def refresh_runner
36
36
  @logger.debug("refresh runner #{@runner.id}")
37
- if update = @runner.run_refresh
37
+ if (update = @runner.run_refresh)
38
38
  @suspended_action << update
39
39
  finish if update.exit_status
40
40
  end
@@ -68,7 +68,7 @@ module ForemanTasksCore
68
68
  def plan_next_refresh
69
69
  if !@finishing && !@refresh_planned
70
70
  @logger.debug("planning to refresh #{@runner.id}")
71
- @clock.ping(reference, Time.now + @refresh_interval, :refresh_runner)
71
+ @clock.ping(reference, Time.now.getlocal + @refresh_interval, :refresh_runner)
72
72
  @refresh_planned = true
73
73
  end
74
74
  end
@@ -137,7 +137,7 @@ module ForemanTasksCore
137
137
  def _finish(runner_id)
138
138
  runner_actor = @runner_actors.delete(runner_id)
139
139
  return unless runner_actor
140
- @logger.debug("closing session for command [#{runner_id}]," +
140
+ @logger.debug("closing session for command [#{runner_id}]," \
141
141
  "#{@runner_actors.size} actors left ")
142
142
  runner_actor.tell([:start_termination, Concurrent.future])
143
143
  ensure
@@ -149,7 +149,7 @@ module ForemanTasksCore
149
149
  "#{exception.class} #{exception.message}:\n #{exception.backtrace.join("\n")}")
150
150
  suspended_action = @runner_suspended_actions[runner_id]
151
151
  if suspended_action
152
- suspended_action << Runner::Update.encode_exception("Runner error", exception, fatal)
152
+ suspended_action << Runner::Update.encode_exception('Runner error', exception, fatal)
153
153
  end
154
154
  _finish(runner_id) if fatal
155
155
  end
@@ -14,7 +14,7 @@ module ForemanTasksCore
14
14
  def self.encode_exception(context, exception, fatal = true)
15
15
  continuous_output = ::ForemanTasksCore::ContinuousOutput.new
16
16
  continuous_output.add_exception(context, exception)
17
- return self.new(continuous_output, fatal ? 'EXCEPTION' : nil)
17
+ new(continuous_output, fatal ? 'EXCEPTION' : nil)
18
18
  end
19
19
  end
20
20
  end
@@ -19,7 +19,7 @@ module ForemanTasksCore
19
19
  def self.register_settings(names, object)
20
20
  names = [names] unless names.is_a? Array
21
21
  names.each do |name|
22
- raise "settings name has to be a symbol" unless name.is_a? Symbol
22
+ raise 'settings name has to be a symbol' unless name.is_a? Symbol
23
23
  raise "settings #{name} already registered" if SettingsLoader.settings_registered?(name)
24
24
  name_to_settings[name] = object
25
25
  end
@@ -47,7 +47,7 @@ module ForemanTasksCore
47
47
  end
48
48
 
49
49
  def validate_settings!
50
- raise "Only symbols expected in keys" unless @settings.keys.all? { |key| key.is_a? Symbol }
50
+ raise 'Only symbols expected in keys' unless @settings.keys.all? { |key| key.is_a? Symbol }
51
51
  end
52
52
  end
53
53
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanTasksCore
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.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: 2016-09-12 00:00:00.000000000 Z
11
+ date: 2017-03-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |
14
- Common code used both at Forman and Foreman proxy regarding tasks
13
+ description: 'Common code used both at Forman and Foreman proxy regarding tasks
14
+
15
+ '
15
16
  email:
16
17
  - inecas@redhat.com
17
18
  executables: []
@@ -49,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
50
  version: '0'
50
51
  requirements: []
51
52
  rubyforge_project:
52
- rubygems_version: 2.4.5
53
+ rubygems_version: 2.5.1
53
54
  signing_key:
54
55
  specification_version: 4
55
56
  summary: Common code used both at Forman and Foreman proxy regarding tasks