Class: Bosh::Director::DeploymentPlan::DnsBinder

Inherits:
Object
  • Object
show all
Includes:
Bosh::Director::DnsHelper
Defined in:
lib/bosh/director/deployment_plan/dns_binder.rb

Constant Summary

Constants included from Bosh::Director::DnsHelper

Bosh::Director::DnsHelper::SOA, Bosh::Director::DnsHelper::TTL_4H, Bosh::Director::DnsHelper::TTL_5M

Instance Method Summary collapse

Methods included from Bosh::Director::DnsHelper

#add_default_dns_server, #canonical, #default_dns_server, #delete_dns_records, #delete_empty_domain, #dns_domain_name, #dns_ns_record, #dns_servers, #invalid_dns, #reverse_domain, #reverse_host, #update_dns_a_record, #update_dns_ptr_record

Constructor Details

#initialize(deployment) ⇒ DnsBinder

Returns a new instance of DnsBinder.



5
6
7
8
# File 'lib/bosh/director/deployment_plan/dns_binder.rb', line 5

def initialize(deployment)
  @deployment = deployment
  @config = Config
end

Instance Method Details

#bind_deploymentObject



10
11
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
# File 'lib/bosh/director/deployment_plan/dns_binder.rb', line 10

def bind_deployment
  return unless @config.dns_enabled?

  domain = Models::Dns::Domain.find_or_create(
    :name => dns_domain_name,
    :type => 'NATIVE',
  )
  @deployment.dns_domain = domain

  soa_record = Models::Dns::Record.find_or_create(
    :domain_id => domain.id,
    :name => dns_domain_name,
    :type => 'SOA',
  )
  soa_record.content = SOA
  soa_record.ttl = 300
  soa_record.save

  # add NS record
  Models::Dns::Record.find_or_create(
    :domain_id => domain.id,
    :name => dns_domain_name,
    :type =>'NS', :ttl => TTL_4H,
    :content => dns_ns_record,
  )

  # add A record for name server
  Models::Dns::Record.find_or_create(
    :domain_id => domain.id,
    :name => dns_ns_record,
    :type =>'A', :ttl => TTL_4H,
    :content => @config.dns['address'],
  )
end