Module: RSMP::Supervisor::Modules::Configuration
- Included in:
- RSMP::Supervisor
- Defined in:
- lib/rsmp/node/supervisor/modules/configuration.rb
Overview
Handles supervisor configuration and site settings
Instance Method Summary collapse
- #check_site_sxl_types ⇒ Object
- #handle_supervisor_settings(supervisor_settings) ⇒ Object
- #ip_to_site_settings(ip) ⇒ Object
- #site_id_to_site_setting(site_id) ⇒ Object
Instance Method Details
#check_site_sxl_types ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rsmp/node/supervisor/modules/configuration.rb', line 29 def check_site_sxl_types sites = @supervisor_settings['sites'].clone || {} sites['guest'] = @supervisor_settings['guest'] sites.each do |site_id, settings| raise RSMP::ConfigurationError, "Configuration for site '#{site_id}' is empty" unless settings sxl = settings['sxl'] raise RSMP::ConfigurationError, "Configuration error for site '#{site_id}': No SXL specified" unless sxl RSMP::Schema.find_schemas! sxl if sxl rescue RSMP::Schema::UnknownSchemaError => e raise RSMP::ConfigurationError, "Configuration error for site '#{site_id}': #{e}" end end |
#handle_supervisor_settings(supervisor_settings) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rsmp/node/supervisor/modules/configuration.rb', line 6 def handle_supervisor_settings(supervisor_settings) defaults = { 'port' => 12_111, 'ips' => 'all', 'guest' => { 'sxl' => 'tlc', 'intervals' => { 'timer' => 1, 'watchdog' => 1 }, 'timeouts' => { 'watchdog' => 2, 'acknowledgement' => 2 } } } # merge options into defaults @supervisor_settings = defaults.deep_merge(supervisor_settings) @core_version = @supervisor_settings['guest']['core_version'] check_site_sxl_types end |
#ip_to_site_settings(ip) ⇒ Object
53 54 55 |
# File 'lib/rsmp/node/supervisor/modules/configuration.rb', line 53 def ip_to_site_settings(ip) @supervisor_settings['sites'][ip] || @supervisor_settings['sites']['guest'] end |
#site_id_to_site_setting(site_id) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/rsmp/node/supervisor/modules/configuration.rb', line 44 def site_id_to_site_setting(site_id) return {} unless @supervisor_settings['sites'] @supervisor_settings['sites'].each_pair do |id, settings| return settings if id == 'guest' || id == site_id end raise HandshakeError, "site id #{site_id} unknown" end |