module DopCommon

DOP Common infrastructure hash parser

DOPi CLI gloable options

DOP Common command hash parser

Dop configurator helper functions

DOP Common configuration lookup

DOP Common credential hash parser

DOP common hooks hash parser

DOP Common infrastructure properties parser

DOP Common infrastructure hash parser

Node configuration parts for hiera variable lookups and facts

This module provides a method to filter list of nodes.

Defered signal handling

This class will handle the trapping of signals

This code uses tricks from timuruski.net/blog/2014/graceful-shutdown for setup and teardown of the signal handlers. And the self pipe trick from www.sitepoint.com/the-self-pipe-trick-explained

DOP common step hash parser

DOP common step set hash parser

This is log formatter which will log to different files based on the context which was set for the current thread. if no context was set then it will log to the 'all' context.

This is used to separate log for different nodes even for logs which are generated in some external library which is not aware of the context.

DOP Common Validator

Some Validation Helper stuff

Constants

VERSION

Public Class Methods

add_log_filter(filter_proc) click to toggle source
# File lib/dop_common/log.rb, line 36
def self.add_log_filter(filter_proc)
  log_filters << filter_proc
end
add_log_junction(logger) click to toggle source
# File lib/dop_common/log.rb, line 44
def self.add_log_junction(logger)
  log_junctions << logger
end
config() click to toggle source
# File lib/dop_common/config.rb, line 15
def self.config
  @config ||= Config.new
end
configure() { |config| ... } click to toggle source
# File lib/dop_common/config.rb, line 19
def self.configure
  yield config
end
configure=(options_hash) click to toggle source
# File lib/dop_common/config.rb, line 23
def self.configure=(options_hash)
  options_hash.each do |key, value|
    variable_name = '@' + key.to_s
    if config.instance_variable_defined?( variable_name )
      config.instance_variable_set( variable_name , value )
    end
  end
end
formatter() click to toggle source
# File lib/dop_common/log.rb, line 18
def self.formatter
  @formatter ||= Logger::Formatter.new
end
formatter=(formatter_proc) click to toggle source
# File lib/dop_common/log.rb, line 22
def self.formatter=(formatter_proc)
  @formatter ||= formatter_proc
end
log() click to toggle source
# File lib/dop_common/log.rb, line 9
def self.log
  @log ||= create_logger(STDOUT)
end
log_filters() click to toggle source
# File lib/dop_common/log.rb, line 32
def self.log_filters
  @log_filters ||= []
end
log_junctions() click to toggle source
# File lib/dop_common/log.rb, line 40
def self.log_junctions
  @log_junction ||= []
end
logger=(logger) click to toggle source
# File lib/dop_common/log.rb, line 13
def self.logger=(logger)
  logger.formatter = DopCommon.filter_formatter
  @log = logger
end
remove_log_junction(logger) click to toggle source
# File lib/dop_common/log.rb, line 48
def self.remove_log_junction(logger)
  log_junctions.delete(logger)
end
reset_logger() click to toggle source
# File lib/dop_common/log.rb, line 26
def self.reset_logger
  @log = nil
  @log_filters = []
  @log_junction = []
end

Private Class Methods

create_logger(logdev = STDOUT) click to toggle source
# File lib/dop_common/log.rb, line 54
def self.create_logger(logdev = STDOUT)
  logger = Logger.new(logdev)
  logger.formatter = DopCommon.filter_formatter
  logger
end
filter_formatter() click to toggle source
# File lib/dop_common/log.rb, line 60
def self.filter_formatter
  Proc.new do |severity, datetime, progname, msg|
    filtered_message = msg
    log_filters.each do |filter|
      filtered_message = case filtered_message
                         when Exception
                           filtered_message.exception(filter.call(filtered_message.message))
                         when String
                           filter.call(filtered_message)
                         else
                           filter.call(filtered_message.inspect)
                         end
    end
    log_junctions.each {|logger| logger.log(::Logger.const_get(severity), filtered_message, progname)}
    formatter.call(severity, datetime, progname, filtered_message)
  end
end