Class | MCollective::Config |
In: |
lib/mcollective/config.rb
|
Parent: | Object |
A pretty sucky config class, ripe for refactoring/improving
classesfile | [R] | |
color | [R] | |
configdir | [R] | |
configfile | [R] | |
configured | [R] | |
connector | [R] | |
daemonize | [R] | |
daemonize | [R] | |
factsource | [R] | |
identity | [R] | |
keeplogs | [R] | |
libdir | [R] | |
logfile | [R] | |
loglevel | [R] | |
max_log_size | [R] | |
pluginconf | [R] | |
registerinterval | [R] | |
registration | [R] | |
rpcaudit | [R] | |
rpcauditprovider | [R] | |
rpcauthorization | [R] | |
rpcauthprovider | [R] | |
rpchelptemplate | [R] | |
rpclimitmethod | [R] | |
securityprovider | [R] | |
topicprefix | [R] | |
topicsep | [R] |
# File lib/mcollective/config.rb, line 16 16: def loadconfig(configfile) 17: @stomp = Hash.new 18: @subscribe = Array.new 19: @pluginconf = Hash.new 20: @connector = "Stomp" 21: @securityprovider = "Psk" 22: @factsource = "Yaml" 23: @identity = Socket.gethostname 24: @registration = "Agentlist" 25: @registerinterval = 0 26: @topicsep = "." 27: @classesfile = "/var/lib/puppet/classes.txt" 28: @rpcaudit = false 29: @rpcauditprovider = "" 30: @rpcauthorization = false 31: @rpcauthprovider = "" 32: @configdir = File.dirname(configfile) 33: @color = true 34: @configfile = configfile 35: @rpchelptemplate = "/etc/mcollective/rpc-help.erb" 36: @keeplogs = 5 37: @max_log_size = 2097152 38: @rpclimitmethod = :first 39: 40: if File.exists?(configfile) 41: File.open(configfile, "r").each do |line| 42: 43: # strip blank spaces, tabs etc off the end of all lines 44: line.gsub!(/\s*$/, "") 45: 46: unless line =~ /^#|^$/ 47: if (line =~ /(.+?)\s*=\s*(.+)/) 48: key = $1 49: val = $2 50: 51: case key 52: when "topicsep" 53: @topicsep = val 54: when "registration" 55: @registration = val.capitalize 56: when "registerinterval" 57: @registerinterval = val.to_i 58: when "topicprefix" 59: @topicprefix = val 60: when "logfile" 61: @logfile = val 62: when "keeplogs" 63: @keeplogs = val.to_i 64: when "max_log_size" 65: @max_log_size = val.to_i 66: when "loglevel" 67: @loglevel = val 68: when "libdir" 69: @libdir = val 70: unless $LOAD_PATH.include?(val) 71: $LOAD_PATH << val 72: end 73: when "identity" 74: @identity = val 75: when "color" 76: val =~ /^1|y/i ? @color = true : @color = false 77: when "daemonize" 78: val =~ /^1|y/i ? @daemonize = true : @daemonize = false 79: when "securityprovider" 80: @securityprovider = val.capitalize 81: when "factsource" 82: @factsource = val.capitalize 83: when "connector" 84: @connector = val.capitalize 85: when "classesfile" 86: @classesfile = val 87: when /^plugin.(.+)$/ 88: @pluginconf[$1] = val 89: when "rpcaudit" 90: val =~ /^1|y/i ? @rpcaudit = true : @rpcaudit = false 91: when "rpcauditprovider" 92: @rpcauditprovider = val.capitalize 93: when "rpcauthorization" 94: val =~ /^1|y/i ? @rpcauthorization = true : @rpcauthorization = false 95: when "rpcauthprovider" 96: @rpcauthprovider = val.capitalize 97: when "rpchelptemplate" 98: @rpchelptemplate = val 99: when "rpclimitmethod" 100: @rpclimitmethod = val.to_sym 101: 102: else 103: raise("Unknown config parameter #{key}") 104: end 105: end 106: end 107: end 108: 109: @configured = true 110: 111: PluginManager.loadclass("Mcollective::Facts::#{@factsource}") 112: PluginManager.loadclass("Mcollective::Connector::#{@connector}") 113: PluginManager.loadclass("Mcollective::Security::#{@securityprovider}") 114: PluginManager.loadclass("Mcollective::Registration::#{@registration}") 115: PluginManager.loadclass("Mcollective::Audit::#{@rpcauditprovider}") if @rpcaudit 116: PluginManager << {:type => "global_stats", :class => RunnerStats.new} 117: else 118: raise("Cannot find config file '#{configfile}'") 119: end 120: end