Class: Bosh::Director::Jobs::UpdateDeployment
- Includes:
- LockHelper
- Defined in:
- lib/bosh/director/jobs/update_deployment.rb
Instance Attribute Summary
Attributes inherited from BaseJob
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(manifest_file_path, cloud_config_id, runtime_config_id, options = {}) ⇒ UpdateDeployment
constructor
A new instance of UpdateDeployment.
- #perform ⇒ Object
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(manifest_file_path, cloud_config_id, runtime_config_id, options = {}) ⇒ UpdateDeployment
Returns a new instance of UpdateDeployment.
12 13 14 15 16 17 18 |
# File 'lib/bosh/director/jobs/update_deployment.rb', line 12 def initialize(manifest_file_path, cloud_config_id, runtime_config_id, = {}) @blobstore = App.instance.blobstores.blobstore @manifest_file_path = manifest_file_path @cloud_config_id = cloud_config_id @runtime_config_id = runtime_config_id @options = end |
Class Method Details
.job_type ⇒ Object
8 9 10 |
# File 'lib/bosh/director/jobs/update_deployment.rb', line 8 def self.job_type :update_deployment end |
Instance Method Details
#perform ⇒ Object
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/bosh/director/jobs/update_deployment.rb', line 20 def perform logger.info('Reading deployment manifest') manifest_text = File.read(@manifest_file_path) logger.debug("Manifest:\n#{manifest_text}") cloud_config_model = Bosh::Director::Models::CloudConfig[@cloud_config_id] if cloud_config_model.nil? logger.debug("No cloud config uploaded yet.") else logger.debug("Cloud config:\n#{cloud_config_model.manifest}") end runtime_config_model = Bosh::Director::Models::RuntimeConfig[@runtime_config_id] if runtime_config_model.nil? logger.debug("No runtime config uploaded yet.") else logger.debug("Runtime config:\n#{runtime_config_model.manifest}") end deployment_manifest = Manifest.load_from_text(manifest_text, cloud_config_model, runtime_config_model) @deployment_name = deployment_manifest.to_hash['name'] parent_id = add_event with_deployment_lock(@deployment_name) do @notifier = DeploymentPlan::Notifier.new(@deployment_name, Config.nats_rpc, logger) @notifier.send_start_event deployment_plan = nil event_log_stage = Config.event_log.begin_stage('Preparing deployment', 1) event_log_stage.advance_and_track('Preparing deployment') do planner_factory = DeploymentPlan::PlannerFactory.create(logger) deployment_plan = planner_factory.create_from_manifest(deployment_manifest, cloud_config_model, runtime_config_model, @options) deployment_plan.bind_models end render_job_templates(deployment_plan.jobs_starting_on_deploy) deployment_plan.compile_packages update_step(deployment_plan).perform if check_for_changes(deployment_plan) PostDeploymentScriptRunner.run_post_deploys_after_deployment(deployment_plan) end @notifier.send_end_event logger.info('Finished updating deployment') add_event(parent_id) "/deployments/#{deployment_plan.name}" end rescue Exception => e begin @notifier.send_error_event e rescue Exception => e2 # log the second error ensure add_event(parent_id, e) raise e end ensure FileUtils.rm_rf(@manifest_file_path) end |