Class: Bosh::Director::ProblemResolver
- Defined in:
- lib/bosh/director/problem_resolver.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #apply_resolutions(resolutions) ⇒ Object
- #begin_stage(stage_name, n_steps) ⇒ Object
-
#initialize(deployment) ⇒ ProblemResolver
constructor
A new instance of ProblemResolver.
- #track_and_log(task, log = true) ⇒ Object
Constructor Details
#initialize(deployment) ⇒ ProblemResolver
Returns a new instance of ProblemResolver.
6 7 8 9 10 11 12 13 14 |
# File 'lib/bosh/director/problem_resolver.rb', line 6 def initialize(deployment) @deployment = deployment @resolved_count = 0 @resolution_error_logs = StringIO.new #temp @event_log_stage = nil @logger = Config.logger end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/bosh/director/problem_resolver.rb', line 4 def logger @logger end |
Instance Method Details
#apply_resolutions(resolutions) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bosh/director/problem_resolver.rb', line 28 def apply_resolutions(resolutions) @resolutions = resolutions problems = Models::DeploymentProblem.where(id: resolutions.keys) begin_stage('Applying problem resolutions', problems.count) problems.each do |problem| if problem.state != 'open' reason = "state is '#{problem.state}'" track_and_log("Ignoring problem #{problem.id} (#{reason})") elsif problem.deployment_id != @deployment.id reason = 'not a part of this deployment' track_and_log("Ignoring problem #{problem.id} (#{reason})") else apply_resolution(problem) end end = @resolution_error_logs.string.empty? ? nil : @resolution_error_logs.string.chomp [@resolved_count, ] end |
#begin_stage(stage_name, n_steps) ⇒ Object
16 17 18 19 |
# File 'lib/bosh/director/problem_resolver.rb', line 16 def begin_stage(stage_name, n_steps) @event_log_stage = Config.event_log.begin_stage(stage_name, n_steps) logger.info(stage_name) end |
#track_and_log(task, log = true) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/bosh/director/problem_resolver.rb', line 21 def track_and_log(task, log = true) @event_log_stage.advance_and_track(task) do |ticker| logger.info(task) if log yield ticker if block_given? end end |