class Bosh::Director::DeploymentPlan::PlacementPlanner::PlacedDesiredInstances

Attributes

absent[R]
existing[R]

Public Class Methods

new(azs) click to toggle source
# File lib/bosh/director/deployment_plan/placement_planner/placed_desired_instances.rb, line 8
def initialize(azs)
  @placed = {}
  (azs || []).each do |az|
    @placed[az] = []
  end

  @absent = []
  @existing = []
end

Public Instance Methods

azs_with_fewest_instances() click to toggle source
# File lib/bosh/director/deployment_plan/placement_planner/placed_desired_instances.rb, line 32
def azs_with_fewest_instances
  az_with_fewest = @placed.keys.min_by { |az|@placed[az].size }
  @placed.keys.select { |az| (@placed[az].size == @placed[az_with_fewest].size) && az }
end
record_placement(az, desired_instance, existing_instance_model) click to toggle source
# File lib/bosh/director/deployment_plan/placement_planner/placed_desired_instances.rb, line 18
def record_placement(az, desired_instance, existing_instance_model)
  desired_instance.az = az
  @placed[az] = @placed.fetch(az, []) << desired_instance

  if existing_instance_model
    existing << {
      desired_instance: desired_instance,
      existing_instance_model: existing_instance_model
    }
  else
    absent << desired_instance
  end
end