Class: Bosh::Director::DeploymentPlan::PlacementPlanner::PlacedDesiredInstances
- Inherits:
-
Object
- Object
- Bosh::Director::DeploymentPlan::PlacementPlanner::PlacedDesiredInstances
- Defined in:
- lib/bosh/director/deployment_plan/placement_planner/placed_desired_instances.rb
Instance Attribute Summary collapse
-
#absent ⇒ Object
readonly
Returns the value of attribute absent.
-
#existing ⇒ Object
readonly
Returns the value of attribute existing.
Instance Method Summary collapse
- #azs_with_fewest_instances ⇒ Object
-
#initialize(azs) ⇒ PlacedDesiredInstances
constructor
A new instance of PlacedDesiredInstances.
- #record_placement(az, desired_instance, existing_instance_model) ⇒ Object
Constructor Details
#initialize(azs) ⇒ PlacedDesiredInstances
Returns a new instance of PlacedDesiredInstances.
8 9 10 11 12 13 14 15 16 |
# 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 |
Instance Attribute Details
#absent ⇒ Object (readonly)
Returns the value of attribute absent.
6 7 8 |
# File 'lib/bosh/director/deployment_plan/placement_planner/placed_desired_instances.rb', line 6 def absent @absent end |
#existing ⇒ Object (readonly)
Returns the value of attribute existing.
6 7 8 |
# File 'lib/bosh/director/deployment_plan/placement_planner/placed_desired_instances.rb', line 6 def existing @existing end |
Instance Method Details
#azs_with_fewest_instances ⇒ Object
32 33 34 35 |
# 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) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 |