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, #dns_manager, #event_manager, #logger, perform, #result_file, schedule_message, #single_step_stage, #task_cancelled?, #task_checkpoint, #track_and_log, #username

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
42
43
44
45
46
47
48
# File 'lib/bosh/director/jobs/cloud_check/apply_resolutions.rb', line 36

def perform
  with_deployment_lock(@deployment) do
    count, error_message = @problem_resolver.apply_resolutions(@resolutions)

    if error_message
      raise Bosh::Director::ProblemHandlerError, error_message
    end

    Bosh::Director::PostDeploymentScriptRunner.run_post_deploys_after_resurrection(@deployment)

    "#{count} resolved"
  end
end