class SnapEbs
Constants
- VERSION
Public Class Methods
logger(logfile)
click to toggle source
# File lib/snap_ebs.rb, line 14 def self.logger logfile unless @@logger @@logger = Logger.new(logfile || STDOUT) @@logger.level = Logger::DEBUG @@logger.formatter = proc do |severity, datetime, progname, msg| "[#{severity}] #{datetime.strftime("%Y-%m-%d %H:%M:%S")} #{msg}\n" end end @@logger end
logger=(logger_)
click to toggle source
# File lib/snap_ebs.rb, line 26 def self.logger= logger_ @@logger = logger_ end
Public Instance Methods
execute()
click to toggle source
Entry point for the `snap-ebs` binary
# File lib/snap_ebs.rb, line 72 def execute option_parser.parse! logger.debug "Debug logging enabled" begin run rescue Exception => e logger.fatal "Encountered exception #{e}" e.backtrace.map { |x| logger.fatal x } end end
logger()
click to toggle source
Get the global logger instance `logger.debug 'reticulating splines'`
# File lib/snap_ebs.rb, line 85 def logger # HACK -- the logfile argument only gets used on the first invocation SnapEbs.logger options.logfile end
options()
click to toggle source
Get the root `options` object, and instance of OpenStruct
# File lib/snap_ebs/options.rb, line 68 def options @options ||= OpenStruct.new(default_options) end
plugins()
click to toggle source
# File lib/snap_ebs.rb, line 30 def plugins @plugins ||= registered_plugins.collect { |klass| klass.new } end
registered_plugins()
click to toggle source
# File lib/snap_ebs.rb, line 34 def registered_plugins SnapEbs::Plugin.registered_plugins end
run()
click to toggle source
Executes plugin before hooks, takes the snapshot, then runs the after hooks. Plugin
hooks are called within `rescue` blocks to isolate errors from affecting other plugins or the snapshot plugins. Note that non- standard exceptions (i.e. out of memory or keyboard interrupt) will still cause a execution to abort.
# File lib/snap_ebs.rb, line 43 def run ok = true plugins.each do |plugin| next unless plugin.options.enable begin # we don't snap unless all plugin.before calls return a truthy value unless plugin.before plugin.options.enable = false ok = false end rescue => e logger.error "Encountered error while running the #{plugin.name} plugin's before hook" logger.error e end end take_snapshots if ok plugins.each do |plugin| begin plugin.after if plugin.options.enable rescue => e logger.error "Encountered error while running the #{plugin.name} plugin's after hook" logger.error e end end end
Private Instance Methods
default_options()
click to toggle source
# File lib/snap_ebs/options.rb, line 74 def default_options { retry_count: 100, retry_interval: 10 } end