Class: Bosh::Director::ProblemScanner::DiskScanStage

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/problem_scanner/disk_scan_stage.rb

Instance Method Summary collapse

Constructor Details

#initialize(disk_owners, problem_register, cloud, deployment_id, event_logger, logger) ⇒ DiskScanStage

Returns a new instance of DiskScanStage.



3
4
5
6
7
8
9
10
# File 'lib/bosh/director/problem_scanner/disk_scan_stage.rb', line 3

def initialize(disk_owners, problem_register, cloud, deployment_id, event_logger, logger)
  @disk_owners = disk_owners
  @problem_register = problem_register
  @cloud = cloud
  @deployment_id = deployment_id
  @event_logger = event_logger
  @logger = logger
end

Instance Method Details

#scanObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bosh/director/problem_scanner/disk_scan_stage.rb', line 12

def scan
  disks = Bosh::Director::Models::PersistentDisk.eager(:instance).all.select do |disk|
    disk.instance && disk.instance.deployment_id == @deployment_id && !disk.instance.ignore
  end

  results = Hash.new(0)

  @event_logger.begin_stage("Scanning #{disks.size} persistent disks", 2)

  @event_logger.track_and_log('Looking for inactive disks') do
    disks.each do |disk|
      scan_result = scan_disk(disk)
      results[scan_result] += 1
    end
  end

  @event_logger.track_and_log("#{results[:ok]} OK, " +
    "#{results[:missing]} missing, " +
    "#{results[:inactive]} inactive, " +
    "#{results[:mount_info_mismatch]} mount-info mismatch")
end