Object
# File lib/chef/expander/configuration.rb, line 113 def self.configurable(setting, default=nil, &validation) attr_accessor(setting) configurables << setting defaults[setting] = default validations << validation if block_given? setting end
# File lib/chef/expander/configuration.rb, line 101 def self.configurables @configurables ||= [] end
# File lib/chef/expander/configuration.rb, line 109 def self.defaults @defaults ||= {} end
# File lib/chef/expander/configuration.rb, line 84 def self.from_chef_compat_config(file) config = ChefCompatibleConfig.new config.load(file) from_hash(config.config_hash) end
# File lib/chef/expander/configuration.rb, line 90 def self.from_hash(config_hash) config = new config_hash.each do |setting, value| setter = "#{setting}=".to_sym if config.respond_to?(setter) config.send(setter, value) end end config end
# File lib/chef/expander/configuration.rb, line 253 def amqp_config {:host => amqp_host, :port => amqp_port, :user => amqp_user, :pass => amqp_pass, :vhost => amqp_vhost} end
# File lib/chef/expander/configuration.rb, line 215 def apply_defaults self.class.defaults.each do |setting, value| self.send("#{setting}=".to_sym, value) end end
# File lib/chef/expander/configuration.rb, line 228 def fail_if_invalid validate! rescue InvalidConfiguration => e @stdout.puts("Invalid configuration: #{e.message}") exit(1) end
# File lib/chef/expander/configuration.rb, line 235 def invalid(message) raise InvalidConfiguration, message end
override the setter for log_level to also actually set the level
# File lib/chef/expander/configuration.rb, line 188 def log_level=(level) if level #don't accept nil for an answer level = level.to_sym Loggable::LOGGER.level = level @log_level = log_level end level end
override the setter for log_location to re-init the logger
# File lib/chef/expander/configuration.rb, line 200 def log_location=(location) Loggable::LOGGER.init(location) unless location.nil? end
# File lib/chef/expander/configuration.rb, line 221 def merge_config(other) self.class.configurables.each do |setting| value = other.send(setting) self.send("#{setting}=".to_sym, value) if value end end
# File lib/chef/expander/configuration.rb, line 177 def pidfile if @pidfile.equal?(DEFAULT_PIDFILE) Process.euid == 0 ? '/var/run/chef-expander.pid' : '/tmp/chef-expander.pid' else @pidfile end end
# File lib/chef/expander/configuration.rb, line 208 def reset!(stdout=nil) self.class.configurables.each do |setting| send("#{setting}=".to_sym, nil) end @stdout = stdout || STDOUT end
override the setter for solr_url for backward compatibilty
# File lib/chef/expander/configuration.rb, line 149 def solr_url=(url) if url && url == "http://localhost:8983" log.warn {"You seem to have a legacy setting for solr_url: did you mean #{url}/solr ?"} url = "#{url}/solr" end @solr_url = url end
# File lib/chef/expander/configuration.rb, line 239 def validate! self.class.validations.each do |validation_proc| instance_eval(&validation_proc) end end
# File lib/chef/expander/configuration.rb, line 245 def vnode_numbers vnodes_per_node = VNODES / node_count lower_bound = (index - 1) * vnodes_per_node upper_bound = lower_bound + vnodes_per_node upper_bound += VNODES % vnodes_per_node if index == node_count (lower_bound...upper_bound).to_a end
Generated with the Darkfish Rdoc Generator 2.