Class: Bosh::Director::DeploymentPlan::PlacementPlanner::BruteForceIpAllocation::PreviousAssignment
- Inherits:
-
Object
- Object
- Bosh::Director::DeploymentPlan::PlacementPlanner::BruteForceIpAllocation::PreviousAssignment
- Defined in:
- lib/bosh/director/deployment_plan/placement_planner/bruteforce_ip_allocation.rb
Instance Method Summary collapse
- #has_same_distribution?(static_ips_to_azs) ⇒ Boolean
-
#initialize(network_to_static_ips) ⇒ PreviousAssignment
constructor
A new instance of PreviousAssignment.
Constructor Details
#initialize(network_to_static_ips) ⇒ PreviousAssignment
Returns a new instance of PreviousAssignment.
101 102 103 104 105 106 |
# File 'lib/bosh/director/deployment_plan/placement_planner/bruteforce_ip_allocation.rb', line 101 def initialize(network_to_static_ips) @previous_assignment = Hash.new {|h,k| h[k] = 0 } network_to_static_ips.each do |previous_assignment_ip| @previous_assignment[previous_assignment_ip.az_names.first] += 1 end end |
Instance Method Details
#has_same_distribution?(static_ips_to_azs) ⇒ Boolean
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/bosh/director/deployment_plan/placement_planner/bruteforce_ip_allocation.rb', line 108 def has_same_distribution?(static_ips_to_azs) @previous_assignment.each do |az_name, required_number_of_ips_in_az| ips_in_az = static_ips_to_azs.select { |static_ip_to_azs| static_ip_to_azs.az_names.include?(az_name) } if ips_in_az.size < required_number_of_ips_in_az return false end end return true end |