Class: Bosh::Director::Jobs::SnapshotSelf

Inherits:
BaseJob show all
Defined in:
lib/bosh/director/jobs/snapshot_self.rb

Instance Attribute Summary

Attributes inherited from BaseJob

#task_id

Class Method Summary collapse

Instance Method Summary collapse

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(options={})
  @cloud = options.fetch(:cloud) { Config.cloud }
  @director_uuid = options.fetch(:director_uuid) { Config.uuid }
  @director_name = options.fetch(:director_name) { Config.name }
  @enable_snapshots = options.fetch(:enable_snapshots) { Config.enable_snapshots }
end

Class Method Details

.job_typeObject



6
7
8
# File 'lib/bosh/director/jobs/snapshot_self.rb', line 6

def self.job_type
  :snapshot_self
end

Instance Method Details

#performObject



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