X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=lib%2Fmcollective%2Fconfig.rb;h=3b5dedc5570b9146193f8bdb5dc41917749f815f;hb=d1f1649ba43c5cbc43c4beb2380096ba051d646a;hp=8b5e4091ae8acd6efa9e57d399b6812e57597c3b;hpb=b87d2f4e68281062df1913440ca5753ae63314a9;p=packages%2Fprecise%2Fmcollective.git diff --git a/lib/mcollective/config.rb b/lib/mcollective/config.rb index 8b5e409..3b5dedc 100644 --- a/lib/mcollective/config.rb +++ b/lib/mcollective/config.rb @@ -5,16 +5,17 @@ module MCollective attr_accessor :mode - attr_reader :topicprefix, :daemonize, :pluginconf, :libdir, :configured + attr_reader :daemonize, :pluginconf, :libdir, :configured attr_reader :logfile, :keeplogs, :max_log_size, :loglevel, :logfacility attr_reader :identity, :daemonize, :connector, :securityprovider, :factsource - attr_reader :registration, :registerinterval, :topicsep, :classesfile + attr_reader :registration, :registerinterval, :classesfile attr_reader :rpcauditprovider, :rpcaudit, :configdir, :rpcauthprovider - attr_reader :rpcauthorization, :color, :configfile, :rpchelptemplate + attr_reader :rpcauthorization, :color, :configfile attr_reader :rpclimitmethod, :logger_type, :fact_cache_time, :collectives attr_reader :main_collective, :ssl_cipher, :registration_collective - attr_reader :direct_addressing, :direct_addressing_threshold, :ttl, :helptemplatedir - attr_reader :queueprefix, :default_discovery_method, :default_discovery_options + attr_reader :direct_addressing, :direct_addressing_threshold, :ttl + attr_reader :default_discovery_method, :default_discovery_options + attr_reader :publish_timeout, :threaded def initialize @configured = false @@ -24,19 +25,17 @@ module MCollective set_config_defaults(configfile) if File.exists?(configfile) - File.open(configfile, "r").each do |line| + File.readlines(configfile).each do |line| # strip blank spaces, tabs etc off the end of all lines line.gsub!(/\s*$/, "") unless line =~ /^#|^$/ if (line =~ /(.+?)\s*=\s*(.+)/) - key = $1 + key = $1.strip val = $2 case key - when "topicsep" - @topicsep = val when "registration" @registration = val.capitalize when "registration_collective" @@ -47,10 +46,6 @@ module MCollective @collectives = val.split(",").map {|c| c.strip} when "main_collective" @main_collective = val - when "topicprefix" - @topicprefix = val - when "queueprefix" - @queueprefix = val when "logfile" @logfile = val when "keeplogs" @@ -74,13 +69,13 @@ module MCollective when "identity" @identity = val when "direct_addressing" - val =~ /^1|y/i ? @direct_addressing = true : @direct_addressing = false + @direct_addressing = Util.str_to_bool(val) when "direct_addressing_threshold" @direct_addressing_threshold = val.to_i when "color" - val =~ /^1|y/i ? @color = true : @color = false + @color = Util.str_to_bool(val) when "daemonize" - val =~ /^1|y/i ? @daemonize = true : @daemonize = false + @daemonize = Util.str_to_bool(val) when "securityprovider" @securityprovider = val.capitalize when "factsource" @@ -91,16 +86,16 @@ module MCollective @classesfile = val when /^plugin.(.+)$/ @pluginconf[$1] = val + when "publish_timeout" + @publish_timeout = val.to_i when "rpcaudit" - val =~ /^1|y/i ? @rpcaudit = true : @rpcaudit = false + @rpcaudit = Util.str_to_bool(val) when "rpcauditprovider" @rpcauditprovider = val.capitalize when "rpcauthorization" - val =~ /^1|y/i ? @rpcauthorization = true : @rpcauthorization = false + @rpcauthorization = Util.str_to_bool(val) when "rpcauthprovider" @rpcauthprovider = val.capitalize - when "rpchelptemplate" - @rpchelptemplate = val when "rpclimitmethod" @rpclimitmethod = val.to_sym when "logger_type" @@ -109,21 +104,23 @@ module MCollective @fact_cache_time = val.to_i when "ssl_cipher" @ssl_cipher = val + when "threaded" + @threaded = Util.str_to_bool(val) when "ttl" @ttl = val.to_i - when "helptemplatedir" - @helptemplatedir = val when "default_discovery_options" @default_discovery_options << val when "default_discovery_method" @default_discovery_method = val else - raise("Unknown config parameter #{key}") + raise("Unknown config parameter '#{key}'") end end end end + raise('The %s config file does not specify a libdir setting, cannot continue' % configfile) if @libdir.empty? + I18n.load_path = Dir[File.expand_path(File.join(File.dirname(__FILE__), "locales", "*.yml"))] I18n.locale = :en @@ -163,9 +160,6 @@ module MCollective @registration = "Agentlist" @registerinterval = 0 @registration_collective = nil - @topicsep = "." - @topicprefix = "/topic/" - @queueprefix = "/queue/" @classesfile = "/var/lib/puppet/state/classes.txt" @rpcaudit = false @rpcauditprovider = "" @@ -185,19 +179,14 @@ module MCollective @collectives = ["mcollective"] @main_collective = @collectives.first @ssl_cipher = "aes-256-cbc" - @direct_addressing = false + @direct_addressing = true @direct_addressing_threshold = 10 @default_discovery_method = "mc" @default_discovery_options = [] @ttl = 60 @mode = :client - - # look in the config dir for the template so users can provide their own and windows - # with odd paths will just work more often, but fall back to old behavior if it does - # not exist - @rpchelptemplate = File.join(File.dirname(configfile), "rpc-help.erb") - @rpchelptemplate = "/etc/mcollective/rpc-help.erb" unless File.exists?(@rpchelptemplate) - @helptemplatedir = File.dirname(@rpchelptemplate) + @publish_timeout = 2 + @threaded = false end def read_plugin_config_dir(dir) @@ -212,7 +201,7 @@ module MCollective line.gsub!(/\s*$/, "") next if line =~ /^#|^$/ if (line =~ /(.+?)\s*=\s*(.+)/) - key = $1 + key = $1.strip val = $2 @pluginconf["#{plugin}.#{key}"] = val end