Class: Bosh::Director::Jobs::CloudCheck::ApplyResolutions

Inherits:
BaseJob
  • Object
show all
Includes:
LockHelper
Defined in:
lib/bosh/director/jobs/cloud_check/apply_resolutions.rb

Instance Attribute Summary

Attributes inherited from BaseJob

#task_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LockHelper

#with_compile_lock, #with_deployment_lock, #with_release_lock, #with_release_locks, #with_stemcell_lock

Methods inherited from BaseJob

#begin_stage, #event_log, #logger, perform, #result_file, #single_step_stage, #task_cancelled?, #task_checkpoint, #track_and_log

Constructor Details

#initialize(deployment_name, resolutions) ⇒ ApplyResolutions

Returns a new instance of ApplyResolutions.

Parameters:

  • deployment_name (String)

    Deployment name

  • resolutions (Hash)

    Problem resolutions



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bosh/director/jobs/cloud_check/apply_resolutions.rb', line 17

def initialize(deployment_name, resolutions)
  @deployment_manager = Api::DeploymentManager.new
  @deployment = @deployment_manager.find_by_name(deployment_name)

  unless resolutions.kind_of?(Hash)
    raise CloudcheckInvalidResolutionFormat,
          "Invalid format for resolutions, Hash expected, #{resolutions.class} is given"
  end

  # Normalizing problem ids
  @resolutions =
    resolutions.inject({}) { |hash, (problem_id, solution_name)|
      hash[problem_id.to_s] = solution_name
      hash
    }

  @problem_resolver = ProblemResolver.new(@deployment)
end

Class Method Details

.job_typeObject



11
12
13
# File 'lib/bosh/director/jobs/cloud_check/apply_resolutions.rb', line 11

def self.job_type
  :cck_apply
end

Instance Method Details

#performObject



36
37
38
39
40
41
# File 'lib/bosh/director/jobs/cloud_check/apply_resolutions.rb', line 36

def perform
  with_deployment_lock(@deployment) do
    count = @problem_resolver.apply_resolutions(@resolutions)
    "#{count} resolved"
  end
end