Class: Bosh::Deployer::InstanceManager::Aws

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

Instance Method Summary collapse

Constructor Details

#initialize(instance_manager, config, logger) ⇒ Aws

Returns a new instance of Aws.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 8

def initialize(instance_manager, config, logger)
  @instance_manager = instance_manager
  @logger = logger
  @config = config
  properties = config.cloud_options['properties']

  @registry = Registry.new(
    properties['registry']['endpoint'],
    'aws',
    properties['aws'],
    instance_manager,
    logger,
  )

  ssh_key, ssh_port, ssh_user, ssh_wait = ssh_properties(properties)

  ssh_server = SshServer.new(ssh_user, ssh_key, ssh_port, logger)
  @remote_tunnel = RemoteTunnel.new(ssh_server, ssh_wait, logger)
end

Instance Method Details

#agent_services_ipObject



66
67
68
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 66

def agent_services_ip
  discover_client_services_ip
end

#check_dependenciesObject



49
50
51
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 49

def check_dependencies
  # nothing to check, move on...
end

#client_services_ipObject



62
63
64
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 62

def client_services_ip
  discover_client_services_ip
end

#disk_size(cid) ⇒ Integer

Returns size in MiB.

Returns:

  • (Integer)

    size in MiB



75
76
77
78
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 75

def disk_size(cid)
  # AWS stores disk size in GiB but the CPI uses MiB
  instance_manager.cloud.ec2.volumes[cid].size * 1024
end

#internal_services_ipObject



70
71
72
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 70

def internal_services_ip
  config.internal_services_ip
end

#persistent_disk_changed?Boolean

Returns:

  • (Boolean)


80
81
82
83
84
85
86
87
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 80

def persistent_disk_changed?
  # since AWS stores disk size in GiB and the CPI uses MiB there
  # is a risk of conversion errors which lead to an unnecessary
  # disk migration, so we need to do a double conversion
  # here to avoid that
  requested = (config.resources['persistent_disk'] / 1024.0).ceil * 1024
  requested != disk_size(instance_manager.state.disk_cid)
end

#remote_tunnelObject



28
29
30
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 28

def remote_tunnel
  @remote_tunnel.create(instance_manager.client_services_ip, registry.port)
end

#startObject



53
54
55
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 53

def start
  registry.start
end

#stopObject



57
58
59
60
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 57

def stop
  registry.stop
  instance_manager.save_state
end

#update_spec(spec) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/bosh/deployer/instance_manager/aws.rb', line 32

def update_spec(spec)
  properties = spec.properties

  # pick from micro_bosh.yml the aws settings in
  # `apply_spec` section (apply_spec.properties.aws),
  # and if it doesn't exist, use the bosh deployer
  # aws properties (cloud.properties.aws)
  properties['aws'] =
    config.spec_properties['aws'] ||
      config.cloud_options['properties']['aws'].dup

  properties['aws']['registry'] = config.cloud_options['properties']['registry']
  properties['aws']['stemcell'] = config.cloud_options['properties']['stemcell']

  spec.delete('networks')
end