Class: Bosh::Director::Jobs::UpdateDeployment

Inherits:
BaseJob show all
Includes:
LockHelper
Defined in:
lib/bosh/director/jobs/update_deployment.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(manifest_file_path, cloud_config_id, options = {}) ⇒ UpdateDeployment

Returns a new instance of UpdateDeployment.



12
13
14
15
16
17
# File 'lib/bosh/director/jobs/update_deployment.rb', line 12

def initialize(manifest_file_path, cloud_config_id, options = {})
  @blobstore = App.instance.blobstores.blobstore
  @manifest_file_path = manifest_file_path
  @options = options
  @cloud_config_id = cloud_config_id
end

Class Method Details

.job_typeObject



8
9
10
# File 'lib/bosh/director/jobs/update_deployment.rb', line 8

def self.job_type
  :update_deployment
end

Instance Method Details

#performObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/bosh/director/jobs/update_deployment.rb', line 19

def perform
  logger.info('Reading deployment manifest')
  manifest_text = File.read(@manifest_file_path)
  logger.debug("Manifest:\n#{manifest_text}")
  deployment_manifest_hash = Psych.load(manifest_text)
  deployment_name = deployment_manifest_hash['name']
  with_deployment_lock(deployment_name) do
    @notifier = DeploymentPlan::Notifier.new(deployment_name, Config.nats_rpc, logger)
    @notifier.send_start_event

    cloud_config_model = Bosh::Director::Models::CloudConfig[@cloud_config_id]
    planner_factory = DeploymentPlan::PlannerFactory.create(event_log, logger)
    deployment_plan = planner_factory.planner(deployment_manifest_hash, cloud_config_model, @options)

    update_step(deployment_plan).perform
    @notifier.send_end_event
    logger.info('Finished updating deployment')

    "/deployments/#{deployment_plan.name}"
  end
rescue Exception => e
  begin
    @notifier.send_error_event e
  rescue Exception => e2
    # log the second error
  ensure
    raise e
  end
ensure
  FileUtils.rm_rf(@manifest_file_path)
end