Class: Bosh::Agent::Configuration
- Defined in:
- lib/bosh_agent/configuration.rb
Constant Summary collapse
- DEFAULT_BASE_DIR =
'/var/vcap'
- CONFIG_OPTIONS =
[ :base_dir, :logger, :mbus, :agent_id, :configure, :blobstore, :blobstore_provider, :blobstore_options, :system_root, :infrastructure_name, :platform_name, :nats, :process_alerts, :smtp_port, :smtp_user, :smtp_password, :heartbeat_interval, :settings_file, :settings, :state, :credentials ]
Instance Method Summary collapse
- #clear ⇒ Object
- #default_ip ⇒ Object
- #infrastructure ⇒ Object
- #platform ⇒ Object
- #random_password(len) ⇒ Object
- #setup(config) ⇒ Object
Instance Method Details
#clear ⇒ Object
32 33 34 35 36 |
# File 'lib/bosh_agent/configuration.rb', line 32 def clear CONFIG_OPTIONS.each do |option| send("#{option}=", nil) end end |
#default_ip ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/bosh_agent/configuration.rb', line 91 def default_ip ip = nil @state['networks'].each do |k, v| ip = v['ip'] if ip.nil? if v.key?('default') ip = v['ip'] end end ip end |
#infrastructure ⇒ Object
79 80 81 |
# File 'lib/bosh_agent/configuration.rb', line 79 def infrastructure @infrastructure ||= Bosh::Agent::Infrastructure.new(@infrastructure_name).infrastructure end |
#platform ⇒ Object
83 84 85 |
# File 'lib/bosh_agent/configuration.rb', line 83 def platform @platform ||= Bosh::Agent::Platform.platform(@platform_name) end |
#random_password(len) ⇒ Object
87 88 89 |
# File 'lib/bosh_agent/configuration.rb', line 87 def random_password(len) OpenSSL::Random.random_bytes(len).unpack('H*')[0] end |
#setup(config) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/bosh_agent/configuration.rb', line 38 def setup(config) @configure = config['configure'] # it is the responsibillity of the caller to make sure the dir exist logging_config = config.fetch('logging', {}) @logger = Logger.new(logging_config.fetch('file', STDOUT)) @logger.level = Logger.const_get(logging_config.fetch('level', 'info').upcase) @base_dir = config['base_dir'] || DEFAULT_BASE_DIR @agent_id = config['agent_id'] @mbus = config['mbus'] @blobstore_options = config['blobstore_options'] @blobstore_provider = config['blobstore_provider'] @infrastructure_name = config['infrastructure_name'] @platform_name = config['platform_name'] @system_root = config['root_dir'] || '/' @process_alerts = config['process_alerts'] @smtp_port = config['smtp_port'] @smtp_user = 'vcap' @smtp_password = random_password(8) @heartbeat_interval = config['heartbeat_interval'] unless @configure @logger.info("Configuring Agent with: #{config.inspect}") end @settings_file = File.join(@base_dir, 'bosh', 'settings.json') @credentials = config['credentials'] @settings = {} @state = State.new(File.join(@base_dir, 'bosh', 'state.yml')) end |