Class: Bosh::Director::ProblemScanner::VmScanStage
- Defined in:
- lib/bosh/director/problem_scanner/vm_scan_stage.rb
Constant Summary collapse
- AGENT_TIMEOUT_IN_SECONDS =
10
Instance Attribute Summary collapse
-
#agent_disks ⇒ Object
readonly
Returns the value of attribute agent_disks.
Instance Method Summary collapse
-
#initialize(instance_manager, problem_register, cloud, deployment, event_logger, logger) ⇒ VmScanStage
constructor
A new instance of VmScanStage.
- #scan(vms = nil) ⇒ Object
Constructor Details
#initialize(instance_manager, problem_register, cloud, deployment, event_logger, logger) ⇒ VmScanStage
Returns a new instance of VmScanStage.
8 9 10 11 12 13 14 15 16 |
# File 'lib/bosh/director/problem_scanner/vm_scan_stage.rb', line 8 def initialize(instance_manager, problem_register, cloud, deployment, event_logger, logger) @instance_manager = instance_manager @problem_register = problem_register @cloud = cloud @deployment = deployment @event_logger = event_logger @logger = logger @agent_disks = {} end |
Instance Attribute Details
#agent_disks ⇒ Object (readonly)
Returns the value of attribute agent_disks.
6 7 8 |
# File 'lib/bosh/director/problem_scanner/vm_scan_stage.rb', line 6 def agent_disks @agent_disks end |
Instance Method Details
#scan(vms = nil) ⇒ Object
18 19 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 |
# File 'lib/bosh/director/problem_scanner/vm_scan_stage.rb', line 18 def scan(vms=nil) if vms instances = vms.map do |job, index| @instance_manager.find_by_name(@deployment, job, index) end else instances = Models::Instance.filter(deployment: @deployment).exclude(vm_cid: nil).all end @event_logger.begin_stage("Scanning #{instances.size} VMs", 2) results = Hash.new(0) lock = Mutex.new @event_logger.track_and_log('Checking VM states') do ThreadPool.new(max_threads: Config.max_threads).wrap do |pool| instances.each do |instance| next if instance.ignore pool.process do scan_result = scan_vm(instance) lock.synchronize { results[scan_result] += 1 } end end end end ignored_instances_count = instances.count(&:ignore) @event_logger.track_and_log("#{results[:ok]} OK, " + "#{results[:unresponsive]} unresponsive, " + "#{results[:missing]} missing, " + "#{results[:unbound]} unbound" + (ignored_instances_count>0 ? ", #{ignored_instances_count} ignored" : '')) end |