Class: Bosh::Director::DeploymentPlan::LinkPath

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deployment_plan, job_name, template_name) ⇒ LinkPath

Returns a new instance of LinkPath.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bosh/director/deployment_plan/links/link_path.rb', line 6

def initialize(deployment_plan, job_name, template_name)
  @deployment_plan = deployment_plan
  @consumes_job_name = job_name
  @consumes_template_name = template_name
  @deployment = nil
  @job = nil
  @template = nil
  @name = nil
  @path = nil
  @skip = false
  @manual_spec = nil
end

Instance Attribute Details

#deploymentObject (readonly)

Returns the value of attribute deployment.



4
5
6
# File 'lib/bosh/director/deployment_plan/links/link_path.rb', line 4

def deployment
  @deployment
end

#jobObject (readonly)

Returns the value of attribute job.



4
5
6
# File 'lib/bosh/director/deployment_plan/links/link_path.rb', line 4

def job
  @job
end

#manual_specObject (readonly)

Returns the value of attribute manual_spec.



4
5
6
# File 'lib/bosh/director/deployment_plan/links/link_path.rb', line 4

def manual_spec
  @manual_spec
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/bosh/director/deployment_plan/links/link_path.rb', line 4

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/bosh/director/deployment_plan/links/link_path.rb', line 4

def path
  @path
end

#skipObject (readonly)

Returns the value of attribute skip.



4
5
6
# File 'lib/bosh/director/deployment_plan/links/link_path.rb', line 4

def skip
  @skip
end

#templateObject (readonly)

Returns the value of attribute template.



4
5
6
# File 'lib/bosh/director/deployment_plan/links/link_path.rb', line 4

def template
  @template
end

Instance Method Details

#parse(link_info) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bosh/director/deployment_plan/links/link_path.rb', line 19

def parse(link_info)
  # in case the link was explicitly set to the string 'nil', do not add it
  # to the link paths, even if the link provider exist, since the user intent
  # was explicitly set to not consume any link

  if link_info["skip_link"] && link_info["skip_link"] == true
    @skip = true
    return
  end

  if link_info.has_key?("from")
    link_path = fulfill_explicit_link(link_info)
  elsif link_info.has_key?("instances") || link_info.has_key?('properties')
    @manual_spec = {}
    @manual_spec['instances'] = link_info['instances']
    @manual_spec['properties'] = link_info['properties']
    return
  else
    link_path = fulfill_implicit_link(link_info)
  end
  if link_path != nil
    @deployment, @job, @template, @name = link_path.values_at(:deployment, :job, :template, :name)
    @path = "#{link_path[:deployment]}.#{link_path[:job]}.#{link_path[:template]}.#{link_path[:name]}"
  else
    @skip = true
  end
end

#to_sObject



47
48
49
# File 'lib/bosh/director/deployment_plan/links/link_path.rb', line 47

def to_s
  "#{deployment}.#{job}.#{template}.#{name}"
end