Class: Bosh::Director::Jobs::DeleteDeploymentSnapshots
- Defined in:
- lib/bosh/director/jobs/delete_deployment_snapshots.rb
Instance Attribute Summary collapse
-
#deployment ⇒ Object
readonly
Returns the value of attribute deployment.
Attributes inherited from BaseJob
Class Method Summary collapse
Instance Method Summary collapse
- #deployment_manager ⇒ Object
-
#initialize(deployment_name) ⇒ DeleteDeploymentSnapshots
constructor
A new instance of DeleteDeploymentSnapshots.
- #perform ⇒ Object
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) ⇒ DeleteDeploymentSnapshots
Returns a new instance of DeleteDeploymentSnapshots.
12 13 14 |
# File 'lib/bosh/director/jobs/delete_deployment_snapshots.rb', line 12 def initialize(deployment_name) @deployment = deployment_manager.find_by_name(deployment_name) end |
Instance Attribute Details
#deployment ⇒ Object (readonly)
Returns the value of attribute deployment.
6 7 8 |
# File 'lib/bosh/director/jobs/delete_deployment_snapshots.rb', line 6 def deployment @deployment end |
Class Method Details
.job_type ⇒ Object
8 9 10 |
# File 'lib/bosh/director/jobs/delete_deployment_snapshots.rb', line 8 def self.job_type :delete_deployment_snapshots end |
Instance Method Details
#deployment_manager ⇒ Object
16 17 18 |
# File 'lib/bosh/director/jobs/delete_deployment_snapshots.rb', line 16 def deployment_manager @deployment_manager ||= Bosh::Director::Api::DeploymentManager.new end |
#perform ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bosh/director/jobs/delete_deployment_snapshots.rb', line 20 def perform logger.info("deleting snapshots of deployment: #{deployment.name}") deployment.job_instances.each do |instance| snapshots = instance.persistent_disks.map { |disk| disk.snapshots }.flatten if snapshots.any? logger.info("deleting snapshots of: #{instance.job}/#{instance.index} (#{instance.vm.cid})") Bosh::Director::Api::SnapshotManager.delete_snapshots(snapshots) end end "snapshots of deployment `#{deployment.name}' deleted" end |