Class: Bosh::Director::DeploymentPlan::Link

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

Overview

tested in links_resolver_spec

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, source, template, network_name = nil) ⇒ Link

Returns a new instance of Link.



8
9
10
11
12
13
# File 'lib/bosh/director/deployment_plan/links/link.rb', line 8

def initialize(name, source, template, network_name = nil)
  @name = name
  @source = source
  @network_name = network_name
  @template = template
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/bosh/director/deployment_plan/links/link.rb', line 6

def name
  @name
end

Instance Method Details

#specObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bosh/director/deployment_plan/links/link.rb', line 15

def spec
  {
    'networks' => @source.networks.map { |network| network.name },
    'properties' => @template.provides_link_info(@source.name, @name)['mapped_properties'],
    'instances' => @source.needed_instance_plans.map do |instance_plan|
      instance = instance_plan.instance
      availability_zone = instance.availability_zone.name if instance.availability_zone
      {
        'name' => @source.name,
        'index' => instance.index,
        'bootstrap' => instance.bootstrap?,
        'id' => instance.uuid,
        'az' => availability_zone,
        'address' => instance_plan.network_address(@network_name),
        'addresses' => instance_plan.network_addresses,
      }
    end
  }
end