Class: Bosh::Director::Jobs::SnapshotSelf
- Defined in:
- lib/bosh/director/jobs/snapshot_self.rb
Instance Attribute Summary
Attributes inherited from BaseJob
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SnapshotSelf
constructor
A new instance of SnapshotSelf.
- #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(options = {}) ⇒ SnapshotSelf
Returns a new instance of SnapshotSelf.
10 11 12 13 14 15 |
# File 'lib/bosh/director/jobs/snapshot_self.rb', line 10 def initialize(={}) @cloud = .fetch(:cloud) { Config.cloud } @director_uuid = .fetch(:director_uuid) { Config.uuid } @director_name = .fetch(:director_name) { Config.name } @enable_snapshots = .fetch(:enable_snapshots) { Config.enable_snapshots } end |
Class Method Details
.job_type ⇒ Object
6 7 8 |
# File 'lib/bosh/director/jobs/snapshot_self.rb', line 6 def self.job_type :snapshot_self end |
Instance Method Details
#perform ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bosh/director/jobs/snapshot_self.rb', line 17 def perform unless @enable_snapshots logger.info('Snapshots are disabled; skipping') return end vm_id = @cloud.current_vm_id disks = @cloud.get_disks(vm_id) = { deployment: 'self', job: 'director', index: 0, director_name: @director_name, director_uuid: @director_uuid, agent_id: 'self', instance_id: vm_id } disks.each { |disk| @cloud.snapshot_disk(disk, ) } "Snapshot director disks [#{disks.join(', ')}]" rescue Bosh::Clouds::NotImplemented logger.info('CPI does not support disk snapshots; skipping') end |