Class: Bosh::Director::DeploymentPlan::TemplateSpec

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

Instance Method Summary collapse

Constructor Details

#initialize(full_spec) ⇒ TemplateSpec

Returns a new instance of TemplateSpec.



96
97
98
99
# File 'lib/bosh/director/deployment_plan/instance_spec.rb', line 96

def initialize(full_spec)
  @full_spec = full_spec
  @dns_manager = DnsManagerProvider.create
end

Instance Method Details

#specObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/bosh/director/deployment_plan/instance_spec.rb', line 101

def spec
  keys = [
    'deployment',
    'job',
    'index',
    'bootstrap',
    'id',
    'az',
    'networks',
    'packages',
    'properties',
    'dns_domain_name',
    'links',
    'persistent_disk'
  ]
  template_hash = @full_spec.select {|k,v| keys.include?(k) }

  networks_hash = template_hash['networks']
  networks_hash_with_dns = networks_hash.each_pair do |network_name, network_settings|
    settings_with_dns = network_settings.merge({'dns_record_name' => @dns_manager.dns_record_name(@full_spec['index'], @full_spec['job']['name'], network_name, @full_spec['deployment'])})
    networks_hash[network_name] = settings_with_dns
  end

  template_hash.merge({
  'resource_pool' => @full_spec['vm_type']['name'],
  'networks' => networks_hash_with_dns
  })
end