Class: Bosh::Director::DeploymentPlan::PlacementPlanner::StaticIpsAvailabilityZonePicker

Inherits:
Object
  • Object
show all
Includes:
IpUtil
Defined in:
lib/bosh/director/deployment_plan/placement_planner/static_ips_availability_zone_picker.rb

Instance Method Summary collapse

Methods included from IpUtil

#each_ip, #format_ip, #ip_to_i, #ip_to_netaddr

Constructor Details

#initialize(instance_plan_factory, network_planner, job_networks, job_name, desired_azs, logger) ⇒ StaticIpsAvailabilityZonePicker

Returns a new instance of StaticIpsAvailabilityZonePicker.



8
9
10
11
12
13
14
15
16
# File 'lib/bosh/director/deployment_plan/placement_planner/static_ips_availability_zone_picker.rb', line 8

def initialize(instance_plan_factory, network_planner, job_networks, job_name, desired_azs, logger)
  @instance_plan_factory = instance_plan_factory
  @network_planner = network_planner
  @job_networks = job_networks
  @job_name = job_name
  @networks_to_static_ips = NetworksToStaticIps.create(@job_networks, desired_azs, job_name)
  @desired_azs = desired_azs
  @logger = logger
end

Instance Method Details

#place_and_match_in(desired_instances, existing_instance_models) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bosh/director/deployment_plan/placement_planner/static_ips_availability_zone_picker.rb', line 18

def place_and_match_in(desired_instances, existing_instance_models)
  @networks_to_static_ips.validate_azs_are_declared_in_job_and_subnets(@desired_azs)
  @networks_to_static_ips.validate_ips_are_in_desired_azs(@desired_azs)
  validate_ignored_instances_networks(existing_instance_models)

  desired_instances = desired_instances.dup

  instance_plans = place_existing_instance_plans(desired_instances, existing_instance_models)
  instance_plans = place_new_instance_plans(desired_instances, instance_plans)

  if ignored_instances_are_obsolete?(instance_plans)
    raise DeploymentIgnoredInstancesModification, "In instance group '#{@job_name}', an attempt was made to remove a static ip"+
        ' that is used by an ignored instance. This operation is not allowed.'
  end

  instance_plans
end