Class: Bosh::Deployer::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/deployer/specification.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ Specification



18
19
20
21
# File 'lib/bosh/deployer/specification.rb', line 18

def initialize(spec)
  @spec = spec
  @properties = @spec['properties']
end

Instance Attribute Details

#propertiesObject

Returns the value of attribute properties.



16
17
18
# File 'lib/bosh/deployer/specification.rb', line 16

def properties
  @properties
end

#specObject

Returns the value of attribute spec.



15
16
17
# File 'lib/bosh/deployer/specification.rb', line 15

def spec
  @spec
end

Class Method Details

.load_apply_spec(dir) ⇒ Object



8
9
10
11
12
13
# File 'lib/bosh/deployer/specification.rb', line 8

def self.load_apply_spec(dir)
  file = 'apply_spec.yml'
  apply_spec = File.join(dir, file)
  err "this isn't a micro bosh stemcell - #{file} missing" unless File.exist?(apply_spec)
  Psych.load_file(apply_spec)
end

.load_from_stemcell(dir) ⇒ Object



3
4
5
6
# File 'lib/bosh/deployer/specification.rb', line 3

def self.load_from_stemcell(dir)
  spec = load_apply_spec(dir)
  Specification.new(spec)
end

Instance Method Details

#delete(name) ⇒ Object



63
64
65
# File 'lib/bosh/deployer/specification.rb', line 63

def delete(name)
  @spec.delete(name)
end

#director_portString



68
69
70
# File 'lib/bosh/deployer/specification.rb', line 68

def director_port
  @properties['director']['port']
end

#update(bosh_ip, service_ip) ⇒ Object

Update the spec with the IP of the micro bosh instance.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/bosh/deployer/specification.rb', line 27

def update(bosh_ip, service_ip)
  # set the director name to what is specified in the micro_bosh.yml
  if Config.name
    @properties['director'] = {} unless @properties['director']
    @properties['director']['name'] = Config.name
  end

  # on AWS blobstore and nats need to use an elastic IP (if available),
  # as when the micro bosh instance is re-created during a deployment,
  # it might get a new private IP
  %w{blobstore nats}.each do |service|
    update_agent_service_address(service, bosh_ip)
  end

  services = %w{director redis blobstore nats registry dns}
  services.each do |service|
    update_service_address(service, service_ip)
  end

  # health monitor does not listen to any ports, so there is no
  # need to update the service address, but we still want to
  # be able to override values in the apply_spec
  override_property(@properties, 'hm', Config.spec_properties['hm'])
  override_property(@properties, 'director', Config.spec_properties['director'])
  set_property(@properties, 'ntp', Config.spec_properties['ntp'])

  set_property(
    @properties,
    'compiled_package_cache',
    Config.spec_properties['compiled_package_cache'],
  )

  @spec
end