Class: Bosh::Agent::Infrastructure::Aws::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh_agent/infrastructure/aws/settings.rb

Constant Summary collapse

VIP_NETWORK_TYPE =
"vip"
DHCP_NETWORK_TYPE =
"dynamic"
MANUAL_NETWORK_TYPE =
"manual"
SUPPORTED_NETWORK_TYPES =
[
  VIP_NETWORK_TYPE, DHCP_NETWORK_TYPE, MANUAL_NETWORK_TYPE
]
AUTHORIZED_KEYS =
File.join("/home/", BOSH_APP_USER, ".ssh/authorized_keys")

Instance Method Summary collapse

Instance Method Details

#authorized_keysObject



20
21
22
# File 'lib/bosh_agent/infrastructure/aws/settings.rb', line 20

def authorized_keys
  AUTHORIZED_KEYS
end

#get_network_settings(network_name, properties) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bosh_agent/infrastructure/aws/settings.rb', line 44

def get_network_settings(network_name, properties)
  type = properties["type"] || "manual"
  unless type && SUPPORTED_NETWORK_TYPES.include?(type)
    raise Bosh::Agent::StateError,
          "Unsupported network type '%s', valid types are: %s" %
              [type, SUPPORTED_NETWORK_TYPES.join(', ')]
  end

  # Nothing to do for "vip" and "manual" networks
  return nil if [VIP_NETWORK_TYPE, MANUAL_NETWORK_TYPE].include? type

  Bosh::Agent::Util.get_network_info
end

#load_settingsObject



39
40
41
42
# File 'lib/bosh_agent/infrastructure/aws/settings.rb', line 39

def load_settings
  setup_openssh_key
  Infrastructure::Aws::Registry.get_settings
end

#loggerObject



16
17
18
# File 'lib/bosh_agent/infrastructure/aws/settings.rb', line 16

def logger
  Bosh::Agent::Config.logger
end

#setup_openssh_keyObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bosh_agent/infrastructure/aws/settings.rb', line 24

def setup_openssh_key
  public_key = Infrastructure::Aws::Registry.get_openssh_key
  if public_key.nil? || public_key.empty?
    return
  end
  FileUtils.mkdir_p(File.dirname(authorized_keys))
  FileUtils.chmod(0700, File.dirname(authorized_keys))
  FileUtils.chown(Bosh::Agent::BOSH_APP_USER, Bosh::Agent::BOSH_APP_GROUP,
                  File.dirname(authorized_keys))
  File.open(authorized_keys, "w") { |f| f.write(public_key) }
  FileUtils.chown(Bosh::Agent::BOSH_APP_USER, Bosh::Agent::BOSH_APP_GROUP,
                  authorized_keys)
  FileUtils.chmod(0644, authorized_keys)
end