summaryrefslogtreecommitdiff
path: root/lib/oxidized/config.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-04-14 16:28:23 +0300
committerSaku Ytti <saku@ytti.fi>2014-04-14 16:28:23 +0300
commit57a8f4bc04b4f87ad0d7028dcbf29b96d49eaffd (patch)
tree82567c791b0114e62fa3b978eb2bb95733d6488b /lib/oxidized/config.rb
parent1a1794b2b3ac99764852546c550fd7988f84c37b (diff)
Use 'asetus' for configuration files
Main benefits a) we get support for system wide configs b) we don't use symbols in config file, they're confusing to non-rubyist
Diffstat (limited to 'lib/oxidized/config.rb')
-rw-r--r--lib/oxidized/config.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/oxidized/config.rb b/lib/oxidized/config.rb
new file mode 100644
index 0000000..475ae14
--- /dev/null
+++ b/lib/oxidized/config.rb
@@ -0,0 +1,44 @@
+module Oxidized
+ require 'asetus'
+ class Config
+ Root = File.join ENV['HOME'], '.config', 'oxidized'
+ Crash = File.join Root, 'crash'
+ InputDir = File.join Directory, %w(lib oxidized input)
+ OutputDir = File.join Directory, %w(lib oxidized output)
+ ModelDir = File.join Directory, %w(lib oxidized model)
+ SourceDir = File.join Directory, %w(lib oxidized source)
+ Sleep = 1
+ end
+ class << self
+ attr_accessor :mgr
+ end
+ CFGS = Asetus.new :name=>'oxidized', :load=>false, :key_to_s=>true
+ CFGS.default.username = 'username'
+ CFGS.default.password = 'password'
+ CFGS.default.model = 'junos'
+ CFGS.default.interval = 3600
+ CFGS.default.log = File.join Config::Root, 'log'
+ CFGS.default.debug = false
+ CFGS.default.threads = 30
+ CFGS.default.timeout = 30
+ CFGS.default.prompt = /^([\w.@-]+[#>]\s?)$/
+ CFGS.default.rest = '0.0.0.0:8888' # or false to disable
+ CFGS.default.vars = {} # could be 'enable'=>'enablePW'
+
+ CFGS.default.input.default = 'ssh, telnet'
+ CFGS.default.input.ssh.secure = false
+
+ CFGS.default.output.default = 'git'
+ CFGS.default.source.default = 'csv'
+
+ CFGS.default.model_map = {
+ 'cisco' => 'ios',
+ 'juniper' => 'junos',
+ }
+
+ CFGS.load # load system+user configs, merge to Config.cfg
+ CFG = CFGS.cfg # convenienence, instead of Config.cfg.password, CFG.password
+
+ Log.level = Logger::INFO unless CFG.debug
+ Log.file = CFG.log if CFG.log
+end