Class: Bosh::Director::DeploymentPlan::DeploymentLinkSpecLookup

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

Overview

Used to find link source from link spec in deployment model (saved in DB)

Instance Method Summary collapse

Constructor Details

#initialize(consumed_link, link_path, deployment_link_spec, link_network) ⇒ DeploymentLinkSpecLookup

Returns a new instance of DeploymentLinkSpecLookup.



47
48
49
50
51
52
# File 'lib/bosh/director/deployment_plan/links/link_lookup.rb', line 47

def initialize(consumed_link, link_path, deployment_link_spec, link_network)
  @consumed_link = consumed_link
  @link_path = link_path
  @deployment_link_spec = deployment_link_spec
  @link_network = link_network
end

Instance Method Details



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/bosh/director/deployment_plan/links/link_lookup.rb', line 54

def find_link_spec
  job = @deployment_link_spec[@link_path.job]
  return nil unless job

  template = job[@link_path.template]
  return nil unless template

  link_spec = template.fetch(@link_path.name, {})[@consumed_link.type]
  return nil unless link_spec

  if @link_network
    link_spec['instances'].each do |instance|
      instance['address'] = instance['addresses'][@link_network]
    end
  end

  link_spec
end