Parent

Included Modules

Chef::Expander::Configuration::Base

Constants

DEFAULT_PIDFILE

Public Class Methods

configurable(setting, default=nil, &validation) click to toggle source
# 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
configurables() click to toggle source
# File lib/chef/expander/configuration.rb, line 101
def self.configurables
  @configurables ||= []
end
defaults() click to toggle source
# File lib/chef/expander/configuration.rb, line 109
def self.defaults
  @defaults ||= {}
end
from_chef_compat_config(file) click to toggle source
# 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
from_hash(config_hash) click to toggle source
# 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
new() click to toggle source
# File lib/chef/expander/configuration.rb, line 204
def initialize
  reset!
end
validations() click to toggle source
# File lib/chef/expander/configuration.rb, line 105
def self.validations
  @validations ||= []
end

Public Instance Methods

amqp_config() click to toggle source
# 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
apply_defaults() click to toggle source
# 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
fail_if_invalid() click to toggle source
# 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
invalid(message) click to toggle source
# File lib/chef/expander/configuration.rb, line 235
def invalid(message)
  raise InvalidConfiguration, message
end
log_level=(level) click to toggle source

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
log_location=(location) click to toggle source

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
merge_config(other) click to toggle source
# 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
pidfile() click to toggle source
# 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
reset!(stdout=nil) click to toggle source
# 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
solr_url=(url) click to toggle source

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
validate!() click to toggle source
# File lib/chef/expander/configuration.rb, line 239
def validate!
  self.class.validations.each do |validation_proc|
    instance_eval(&validation_proc)
  end
end
vnode_numbers() click to toggle source
# 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.