Class: Splash::Config::Configuration
- Inherits:
-
Hash
- Object
- Hash
- Splash::Config::Configuration
- Includes:
- Splash::Constants
- Defined in:
- lib/splash/config.rb
Overview
Class to manage configuration in Splash from Splash::Constants override by Yaml CONFIG
Constant Summary
Constants included from Splash::Constants
Splash::Constants::AUTHOR, Splash::Constants::BACKENDS_STRUCT, Splash::Constants::CONFIG_FILE, Splash::Constants::COPYRIGHT, Splash::Constants::DAEMON_LOGMON_SCHEDULING, Splash::Constants::DAEMON_METRICS_SCHEDULING, Splash::Constants::DAEMON_PID_FILE, Splash::Constants::DAEMON_PROCESS_NAME, Splash::Constants::DAEMON_PROCMON_SCHEDULING, Splash::Constants::DAEMON_STDERR_TRACE, Splash::Constants::DAEMON_STDOUT_TRACE, Splash::Constants::DEFAULT_RETENTION, Splash::Constants::EMAIL, Splash::Constants::EXECUTION_TEMPLATE, Splash::Constants::EXECUTION_TEMPLATE_TOKENS_LIST, Splash::Constants::LICENSE, Splash::Constants::LOGGERS_STRUCT, Splash::Constants::PID_PATH, Splash::Constants::PROMETHEUS_ALERTMANAGER_URL, Splash::Constants::PROMETHEUS_PUSHGATEWAY_URL, Splash::Constants::PROMETHEUS_URL, Splash::Constants::TRACE_PATH, Splash::Constants::TRANSPORTS_STRUCT, Splash::Constants::VERSION, Splash::Constants::WEBADMIN_IP, Splash::Constants::WEBADMIN_PID_FILE, Splash::Constants::WEBADMIN_PID_PATH, Splash::Constants::WEBADMIN_PORT, Splash::Constants::WEBADMIN_PROCESS_NAME, Splash::Constants::WEBADMIN_PROXY, Splash::Constants::WEBADMIN_STDERR_TRACE, Splash::Constants::WEBADMIN_STDOUT_TRACE
Instance Attribute Summary collapse
-
#config_from_file ⇒ Object
Returns the value of attribute config_from_file.
accessors on configurations Items collapse
-
#author ⇒ String
getter for author Config sample.
-
#backends ⇒ Hash
getter for backends Hash Config sample.
-
#commands ⇒ Hash
getter for commands Hash Config sample.
-
#copyright ⇒ String
getter for copyright Config sample.
-
#daemon_full_pid_path ⇒ String
getter for daemon_full_pid_path Config sample.
-
#daemon_full_stderr_trace_path ⇒ String
getter for daemon_full_stderr_trace_path Config sample.
-
#daemon_full_stdout_trace_path ⇒ String
getter for daemon_full_stdout_trace_path Config sample.
-
#daemon_logmon_scheduling ⇒ Hash
getter for daemon_logmon_scheduling Hash Config sample.
-
#daemon_metrics_scheduling ⇒ Hash
getter for daemon_metrics_scheduling Hash Config sample.
-
#daemon_process_name ⇒ String
getter for daemon_process_name Config sample.
-
#daemon_procmon_scheduling ⇒ Hash
getter for daemon_procmon_scheduling Hash Config sample.
-
#execution_template_path ⇒ String
getter for execution_template_path Hash Config sample.
-
#execution_template_tokens ⇒ Array
getter for execution_template_tokens Hash Config sample.
-
#full ⇒ Hash
getter for full Config Hash.
-
#loggers ⇒ Hash
getter for loggers Hash Config sample.
-
#logs ⇒ Hash
getter for logs Hash Config sample.
-
#processes ⇒ Hash
getter for processes Hash Config sample.
-
#prometheus_alertmanager_url ⇒ String
getter for prometheus_alertmanager_url Config sample.
-
#prometheus_pushgateway_url ⇒ String
getter for prometheus_pushgateway_url Config sample.
-
#prometheus_url ⇒ String
getter for prometheus_url Config sample.
-
#sequences ⇒ Hash
getter for sequences Hash Config sample.
-
#transfers ⇒ Hash
getter for transfers Hash Config sample.
-
#transports ⇒ Hash
getter for transports Hash Config sample.
-
#version ⇒ String
getter for version Config sample.
-
#webadmin_full_pid_path ⇒ String
getter for webadmin_full_pid_path Config sample.
-
#webadmin_full_stderr_trace_path ⇒ String
getter for webadmin_full_stderr_trace_path Config sample.
-
#webadmin_full_stdout_trace_path ⇒ String
getter for webadmin_full_stdout_trace_path Config sample.
-
#webadmin_ip ⇒ String
getter for webadmin_ip Hash Config sample.
-
#webadmin_port ⇒ Fixnum
getter for webadmin_port Hash Config sample.
-
#webadmin_process_name ⇒ String
getter for webadmin_process_name Config sample.
-
#webadmin_proxy ⇒ TrueClass|FalseClass
getter for webadmin_proxy Hash Config sample.
Instance Method Summary collapse
- #add_record(options = {}) ⇒ Object
- #delete_record(options = {}) ⇒ Object
- #hash_config_to_default ⇒ Object
-
#initialize(config_file = CONFIG_FILE) ⇒ Configuration
constructor
constructor : read config file and map against Constants.
Constructor Details
#initialize(config_file = CONFIG_FILE) ⇒ Configuration
constructor : read config file and map against Constants
48 49 50 51 52 |
# File 'lib/splash/config.rb', line 48 def initialize(config_file=CONFIG_FILE) @config_file = config_file hash_config_to_default end |
Instance Attribute Details
#config_from_file ⇒ Object
Returns the value of attribute config_from_file.
45 46 47 |
# File 'lib/splash/config.rb', line 45 def config_from_file @config_from_file end |
Instance Method Details
#add_record(options = {}) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/splash/config.rb', line 102 def add_record( = {}) @config_from_file = readconf @config_file key = [:key] res = ConfigLinter::new.verify() if res[:status] == :success then if @config_from_file[[:type]].select{|item| item[[:key]] == [:record][[:key]]}.count > 0 then return {:status => :already_exist} else res[:useless].each {|item| [:record].delete item} if [:clean] @config_from_file[[:type]].push [:record] writeconf hash_config_to_default return {:status => :success} end else return res end end |
#author ⇒ String
getter for author Config sample
294 295 296 |
# File 'lib/splash/config.rb', line 294 def return self[:author] end |
#backends ⇒ Hash
getter for backends Hash Config sample
151 152 153 |
# File 'lib/splash/config.rb', line 151 def backends return self[:backends] end |
#commands ⇒ Hash
getter for commands Hash Config sample
276 277 278 |
# File 'lib/splash/config.rb', line 276 def commands return self[:commands] end |
#copyright ⇒ String
getter for copyright Config sample
300 301 302 |
# File 'lib/splash/config.rb', line 300 def copyright return self[:copyright] end |
#daemon_full_pid_path ⇒ String
getter for daemon_full_pid_path Config sample
194 195 196 |
# File 'lib/splash/config.rb', line 194 def daemon_full_pid_path return "#{self[:pid_path]}/#{self[:daemon_pid_file]}" end |
#daemon_full_stderr_trace_path ⇒ String
getter for daemon_full_stderr_trace_path Config sample
206 207 208 |
# File 'lib/splash/config.rb', line 206 def daemon_full_stderr_trace_path return "#{self[:trace_path]}/#{self[:daemon_stderr_trace]}" end |
#daemon_full_stdout_trace_path ⇒ String
getter for daemon_full_stdout_trace_path Config sample
200 201 202 |
# File 'lib/splash/config.rb', line 200 def daemon_full_stdout_trace_path return "#{self[:trace_path]}/#{self[:daemon_stdout_trace]}" end |
#daemon_logmon_scheduling ⇒ Hash
getter for daemon_logmon_scheduling Hash Config sample
169 170 171 |
# File 'lib/splash/config.rb', line 169 def daemon_logmon_scheduling return self[:daemon_logmon_scheduling] end |
#daemon_metrics_scheduling ⇒ Hash
getter for daemon_metrics_scheduling Hash Config sample
181 182 183 |
# File 'lib/splash/config.rb', line 181 def daemon_metrics_scheduling return self[:daemon_metrics_scheduling] end |
#daemon_process_name ⇒ String
getter for daemon_process_name Config sample
187 188 189 |
# File 'lib/splash/config.rb', line 187 def daemon_process_name return self[:daemon_process_name] end |
#daemon_procmon_scheduling ⇒ Hash
getter for daemon_procmon_scheduling Hash Config sample
175 176 177 |
# File 'lib/splash/config.rb', line 175 def daemon_procmon_scheduling return self[:daemon_procmon_scheduling] end |
#delete_record(options = {}) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/splash/config.rb', line 122 def delete_record( = {}) @config_from_file = readconf @config_file unless @config_from_file[[:type]].select{|item| item[[:key]] == [[:key]]}.count > 0 then return {:status => :not_found} else @config_from_file[[:type]].delete_if {|value| [[:key]] == value[[:key]] } writeconf hash_config_to_default return {:status => :success} end end |
#execution_template_path ⇒ String
getter for execution_template_path Hash Config sample
212 213 214 |
# File 'lib/splash/config.rb', line 212 def execution_template_path return self[:execution_template_path] end |
#execution_template_tokens ⇒ Array
getter for execution_template_tokens Hash Config sample
218 219 220 |
# File 'lib/splash/config.rb', line 218 def execution_template_tokens return self[:execution_template_tokens] end |
#full ⇒ Hash
getter for full Config Hash
139 140 141 |
# File 'lib/splash/config.rb', line 139 def full return self end |
#hash_config_to_default ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/splash/config.rb', line 55 def hash_config_to_default @config_from_file = readconf @config_file self[:version] = VERSION self[:author] = "#{AUTHOR} <#{EMAIL}>" self[:copyright] = "#{COPYRIGHT} #{LICENSE}" self[:prometheus_url] = (@config_from_file[:prometheus][:url])? @config_from_file[:prometheus][:url] : PROMETHEUS_URL self[:prometheus_pushgateway_url] = (@config_from_file[:prometheus][:pushgateway])? @config_from_file[:prometheus][:pushgateway] : PROMETHEUS_PUSHGATEWAY_URL self[:prometheus_alertmanager_url] = (@config_from_file[:prometheus][:alertmanager])? @config_from_file[:prometheus][:alertmanager] : PROMETHEUS_ALERTMANAGER_URL self[:daemon_process_name] = (@config_from_file[:daemon][:process_name])? @config_from_file[:daemon][:process_name] : DAEMON_PROCESS_NAME self[:daemon_logmon_scheduling] = (@config_from_file[:daemon][:logmon_scheduling])? @config_from_file[:daemon][:logmon_scheduling] : DAEMON_LOGMON_SCHEDULING self[:daemon_metrics_scheduling] = (@config_from_file[:daemon][:metrics_scheduling])? @config_from_file[:daemon][:metrics_scheduling] : DAEMON_METRICS_SCHEDULING self[:daemon_procmon_scheduling] = (@config_from_file[:daemon][:procmon_scheduling])? @config_from_file[:daemon][:procmon_scheduling] : DAEMON_PROCMON_SCHEDULING self[:daemon_pid_file] = (@config_from_file[:daemon][:files][:pid_file])? @config_from_file[:daemon][:files][:pid_file] : DAEMON_PID_FILE self[:daemon_stdout_trace] = (@config_from_file[:daemon][:files][:stdout_trace])? @config_from_file[:daemon][:files][:stdout_trace] : DAEMON_STDOUT_TRACE self[:daemon_stderr_trace] = (@config_from_file[:daemon][:files][:stderr_trace])? @config_from_file[:daemon][:files][:stderr_trace] : DAEMON_STDERR_TRACE self[:webadmin_port] = (@config_from_file[:webadmin][:port])? @config_from_file[:webadmin][:port] : WEBADMIN_PORT self[:webadmin_ip] = (@config_from_file[:webadmin][:ip])? @config_from_file[:webadmin][:ip] : WEBADMIN_IP self[:webadmin_proxy] = (@config_from_file[:webadmin][:proxy])? @config_from_file[:webadmin][:proxy] : WEBADMIN_PROXY self[:webadmin_process_name] = (@config_from_file[:webadmin][:process_name])? @config_from_file[:webadmin][:process_name] : WEBADMIN_PROCESS_NAME self[:webadmin_pid_file] = (@config_from_file[:webadmin][:files][:pid_file])? @config_from_file[:webadmin][:files][:pid_file] : WEBADMIN_PID_FILE self[:webadmin_stdout_trace] = (@config_from_file[:webadmin][:files][:stdout_trace])? @config_from_file[:webadmin][:files][:stdout_trace] : WEBADMIN_STDOUT_TRACE self[:webadmin_stderr_trace] = (@config_from_file[:webadmin][:files][:stderr_trace])? @config_from_file[:webadmin][:files][:stderr_trace] : WEBADMIN_STDERR_TRACE self[:pid_path] = (@config_from_file[:paths][:pid_path])? @config_from_file[:paths][:pid_path] : PID_PATH self[:trace_path] = (@config_from_file[:paths][:trace_path])? @config_from_file[:paths][:trace_path] : TRACE_PATH self[:execution_template_tokens] = EXECUTION_TEMPLATE_TOKENS_LIST self[:execution_template_path] = (@config_from_file[:templates][:execution][:path])? @config_from_file[:templates][:execution][:path] : EXECUTION_TEMPLATE self[:transports] = {} ; self[:transports].merge! TRANSPORTS_STRUCT ; self[:transports].merge! @config_from_file[:transports] if @config_from_file[:transports] self[:backends] = {} ; self[:backends].merge! BACKENDS_STRUCT ; self[:backends].merge! @config_from_file[:backends] if @config_from_file[:backends] self[:loggers] = {} ; self[:loggers].merge! LOGGERS_STRUCT ; self[:loggers].merge! @config_from_file[:loggers] if @config_from_file[:loggers] self[:processes] = (@config_from_file[:processes])? @config_from_file[:processes] : {} self[:logs] = (@config_from_file[:logs])? @config_from_file[:logs] : {} self[:commands] = (@config_from_file[:commands])? @config_from_file[:commands] : {} self[:sequences] = (@config_from_file[:sequences])? @config_from_file[:sequences] : {} self[:transfers] = (@config_from_file[:transfers])? @config_from_file[:transfers] : {} end |
#loggers ⇒ Hash
getter for loggers Hash Config sample
145 146 147 |
# File 'lib/splash/config.rb', line 145 def loggers return self[:loggers] end |
#logs ⇒ Hash
getter for logs Hash Config sample
270 271 272 |
# File 'lib/splash/config.rb', line 270 def logs return self[:logs] end |
#processes ⇒ Hash
getter for processes Hash Config sample
282 283 284 |
# File 'lib/splash/config.rb', line 282 def processes return self[:processes] end |
#prometheus_alertmanager_url ⇒ String
getter for prometheus_alertmanager_url Config sample
322 323 324 |
# File 'lib/splash/config.rb', line 322 def prometheus_alertmanager_url return self[:prometheus_alertmanager_url] end |
#prometheus_pushgateway_url ⇒ String
getter for prometheus_pushgateway_url Config sample
316 317 318 |
# File 'lib/splash/config.rb', line 316 def prometheus_pushgateway_url return self[:prometheus_pushgateway_url] end |
#prometheus_url ⇒ String
getter for prometheus_url Config sample
329 330 331 |
# File 'lib/splash/config.rb', line 329 def prometheus_url return self[:prometheus_url] end |
#sequences ⇒ Hash
getter for sequences Hash Config sample
288 289 290 |
# File 'lib/splash/config.rb', line 288 def sequences return self[:sequences] end |
#transfers ⇒ Hash
getter for transfers Hash Config sample
163 164 165 |
# File 'lib/splash/config.rb', line 163 def transfers return self[:transfers] end |
#transports ⇒ Hash
getter for transports Hash Config sample
157 158 159 |
# File 'lib/splash/config.rb', line 157 def transports return self[:transports] end |
#version ⇒ String
getter for version Config sample
306 307 308 |
# File 'lib/splash/config.rb', line 306 def version return self[:version] end |
#webadmin_full_pid_path ⇒ String
getter for webadmin_full_pid_path Config sample
249 250 251 |
# File 'lib/splash/config.rb', line 249 def webadmin_full_pid_path return "#{self[:pid_path]}/#{self[:webadmin_pid_file]}" end |
#webadmin_full_stderr_trace_path ⇒ String
getter for webadmin_full_stderr_trace_path Config sample
261 262 263 |
# File 'lib/splash/config.rb', line 261 def webadmin_full_stderr_trace_path return "#{self[:trace_path]}/#{self[:webadmin_stderr_trace]}" end |
#webadmin_full_stdout_trace_path ⇒ String
getter for webadmin_full_stdout_trace_path Config sample
255 256 257 |
# File 'lib/splash/config.rb', line 255 def webadmin_full_stdout_trace_path return "#{self[:trace_path]}/#{self[:webadmin_stdout_trace]}" end |
#webadmin_ip ⇒ String
getter for webadmin_ip Hash Config sample
231 232 233 |
# File 'lib/splash/config.rb', line 231 def webadmin_ip return self[:webadmin_ip] end |
#webadmin_port ⇒ Fixnum
getter for webadmin_port Hash Config sample
225 226 227 |
# File 'lib/splash/config.rb', line 225 def webadmin_port return self[:webadmin_port] end |
#webadmin_process_name ⇒ String
getter for webadmin_process_name Config sample
243 244 245 |
# File 'lib/splash/config.rb', line 243 def webadmin_process_name return self[:webadmin_process_name] end |
#webadmin_proxy ⇒ TrueClass|FalseClass
getter for webadmin_proxy Hash Config sample
237 238 239 |
# File 'lib/splash/config.rb', line 237 def webadmin_proxy return self[:webadmin_proxy] end |