Class: Bosh::Agent::Infrastructure::Openstack::Settings
- Defined in:
- lib/bosh_agent/infrastructure/openstack/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 ]
Instance Method Summary collapse
-
#authorized_keys ⇒ String
Returns the authorized keys filename for the Bosh user.
-
#get_network_settings(network_name, network_properties) ⇒ Hash
Gets the network settings for this agent.
-
#load_settings ⇒ Hash
Loads the the settings for this agent and set ups the public OpenSSH key.
-
#logger ⇒ Logger
Returns the logger.
-
#setup_openssh_key ⇒ void
Retrieves the public OpenSSH key and stores it at the authorized_keys file.
Instance Method Details
#authorized_keys ⇒ String
Returns the authorized keys filename for the Bosh user.
35 36 37 |
# File 'lib/bosh_agent/infrastructure/openstack/settings.rb', line 35 def File.join(File::SEPARATOR, "home", BOSH_APP_USER, ".ssh", "authorized_keys") end |
#get_network_settings(network_name, network_properties) ⇒ Hash
Gets the network settings for this agent.
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bosh_agent/infrastructure/openstack/settings.rb', line 62 def get_network_settings(network_name, network_properties) type = network_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_settings ⇒ Hash
Loads the the settings for this agent and set ups the public OpenSSH key.
26 27 28 29 |
# File 'lib/bosh_agent/infrastructure/openstack/settings.rb', line 26 def load_settings setup_openssh_key Infrastructure::Openstack::Registry.get_settings end |
#logger ⇒ Logger
Returns the logger
18 19 20 |
# File 'lib/bosh_agent/infrastructure/openstack/settings.rb', line 18 def logger Bosh::Agent::Config.logger end |
#setup_openssh_key ⇒ void
This method returns an undefined value.
Retrieves the public OpenSSH key and stores it at the authorized_keys file.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bosh_agent/infrastructure/openstack/settings.rb', line 43 def setup_openssh_key public_key = Infrastructure::Openstack::Registry.get_openssh_key return if public_key.nil? || public_key.empty? FileUtils.mkdir_p(File.dirname()) FileUtils.chmod(0700, File.dirname()) FileUtils.chown(Bosh::Agent::BOSH_APP_USER, Bosh::Agent::BOSH_APP_GROUP, File.dirname()) File.open(, "w") { |f| f.write(public_key) } FileUtils.chown(Bosh::Agent::BOSH_APP_USER, Bosh::Agent::BOSH_APP_GROUP, ) FileUtils.chmod(0644, ) end |