Class: Bosh::Director::DeploymentPlan::InstanceSpec

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

Direct Known Subclasses

EmptyInstanceSpec

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_spec, instance) ⇒ InstanceSpec

Returns a new instance of InstanceSpec.



50
51
52
53
# File 'lib/bosh/director/deployment_plan/instance_spec.rb', line 50

def initialize(full_spec, instance)
  @full_spec = full_spec
  @instance = instance
end

Class Method Details

.create_emptyObject



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

def self.create_empty
  EmptyInstanceSpec.new
end

.create_from_database(spec, instance) ⇒ Object



8
9
10
# File 'lib/bosh/director/deployment_plan/instance_spec.rb', line 8

def self.create_from_database(spec, instance)
  new(spec, instance)
end

.create_from_instance_plan(instance_plan) ⇒ Object



12
13
14
15
16
17
18
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
46
47
48
# File 'lib/bosh/director/deployment_plan/instance_spec.rb', line 12

def self.create_from_instance_plan(instance_plan)
  instance = instance_plan.instance
  deployment_name = instance.deployment_model.name
  job = instance_plan.desired_instance.job
  instance_plan = instance_plan
  dns_manager = DnsManagerProvider.create

  spec = {
    'deployment' => deployment_name,
    'job' => job.spec,
    'index' => instance.index,
    'bootstrap' => instance.bootstrap?,
    'id' => instance.uuid,
    'az' => instance.availability_zone_name,
    'networks' => instance_plan.network_settings_hash,
    'vm_type' => job.vm_type.spec,
    'stemcell' => job.stemcell.spec,
    'env' => job.env.spec,
    'packages' => job.package_spec,
    'properties' => job.properties,
    'dns_domain_name' => dns_manager.dns_domain_name,
    'links' => job.link_spec,
  }

  if job.persistent_disk_type
    # supply both for reverse compatibility with old agent
    spec['persistent_disk'] = job.persistent_disk_type.disk_size
    # old agents will ignore this pool
    # keep disk pool for backwards compatibility
    spec['persistent_disk_pool'] = job.persistent_disk_type.spec
    spec['persistent_disk_type'] = job.persistent_disk_type.spec
  else
    spec['persistent_disk'] = 0
  end

  new(spec, instance)
end

Instance Method Details

#as_apply_specObject



59
60
61
# File 'lib/bosh/director/deployment_plan/instance_spec.rb', line 59

def as_apply_spec
  ApplySpec.new(full_spec).spec
end

#as_template_specObject



55
56
57
# File 'lib/bosh/director/deployment_plan/instance_spec.rb', line 55

def as_template_spec
  TemplateSpec.new(full_spec).spec
end

#full_specObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/bosh/director/deployment_plan/instance_spec.rb', line 63

def full_spec
  # re-generate spec with rendered templates info
  # since job renderer sets it directly on instance
  spec = @full_spec

  if @instance.template_hashes
    spec['template_hashes'] = @instance.template_hashes
  end

  if @instance.rendered_templates_archive
    spec['rendered_templates_archive'] = @instance.rendered_templates_archive.spec
  end

  if @instance.configuration_hash
    spec['configuration_hash'] = @instance.configuration_hash
  end

  spec
end