Class: SnapEbs
Defined Under Namespace
Modules: Options, Snapshotter
Classes: Plugin
Constant Summary
collapse
- @@logger =
nil
Constants included
from Snapshotter
Snapshotter::AWS_INSTANCE_ID_URL
Instance Attribute Summary
Attributes included from Snapshotter
#compute
Class Method Summary
collapse
Instance Method Summary
collapse
#access_key, #attached_volumes, #credentials, #devices_to_snap, #instance_id, #instance_name, #region, #secret_key, #should_snap, #snapshot_name, #take_snapshots
Methods included from Options
#option_parser
Class Method Details
.logger(logfile) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/snap_ebs.rb', line 13
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_) ⇒ Object
25
26
27
|
# File 'lib/snap_ebs.rb', line 25
def self.logger= logger_
@@logger = logger_
end
|
Instance Method Details
#execute ⇒ Object
59
60
61
62
63
|
# File 'lib/snap_ebs.rb', line 59
def execute
option_parser.parse!
logger.debug "Debug logging enabled"
run
end
|
#logger ⇒ Object
65
66
67
68
|
# File 'lib/snap_ebs.rb', line 65
def logger
SnapEbs.logger options.logfile
end
|
#options ⇒ Object
47
48
49
|
# File 'lib/snap_ebs/options.rb', line 47
def options
@options ||= OpenStruct.new
end
|
#plugins ⇒ Object
29
30
31
|
# File 'lib/snap_ebs.rb', line 29
def plugins
@plugins ||= registered_plugins.collect { |klass| klass.new }
end
|
#registered_plugins ⇒ Object
#run ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/snap_ebs.rb', line 37
def run
plugins.each do |plugin|
begin
plugin.before if plugin.options.enable
rescue Exception => e
logger.error "Encountered error while running the #{plugin.name} plugin's before hook"
logger.error e
end
end
take_snapshots
plugins.each do |plugin|
begin
plugin.after if plugin.options.enable
rescue Exception => e
logger.error "Encountered error while running the #{plugin.name} plugin's after hook"
logger.error e
end
end
end
|