Class: Bosh::Director::DeploymentPlan::InstanceVmBinder

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/deployment_plan/instance_vm_binder.rb

Instance Method Summary collapse

Constructor Details

#initialize(event_log) ⇒ InstanceVmBinder

Returns a new instance of InstanceVmBinder.



3
4
5
# File 'lib/bosh/director/deployment_plan/instance_vm_binder.rb', line 3

def initialize(event_log)
  @event_log = event_log
end

Instance Method Details

#bind_instance_vms(instances) ⇒ Object

Parameters:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bosh/director/deployment_plan/instance_vm_binder.rb', line 9

def bind_instance_vms(instances)
  unbound_instances = []

  instances.each do |instance|
    # Don't allocate resource pool VMs to instances in detached state
    next if instance.state == 'detached'

    # Skip bound instances
    next if instance.model.vm

    unbound_instances << instance
  end

  return if unbound_instances.empty?

  @event_log.begin_stage('Binding instance VMs', unbound_instances.size)

  ThreadPool.new(:max_threads => Config.max_threads).wrap do |pool|
    unbound_instances.each do |instance|
      pool.process do
        @event_log.track("#{instance.job.name}/#{instance.index}") do
          instance.apply_partial_vm_state
        end
      end
    end
  end
end