Class: EY::Stonith::Commands::Notify
Constant Summary
Constants inherited
from Abstract
Abstract::DEFAULT_CONFIG_PATH, Abstract::SCRIPT_NAME
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Abstract
#call, #command_options, #config, #execute, #history, #init_logger, #initialize, #parse!, #parser, #script
Class Method Details
.banner ⇒ Object
9
10
11
|
# File 'lib/ey_stonith/commands/notify.rb', line 9
def self.banner
'Notify the provisioning server that master is down.'
end
|
.command ⇒ Object
5
6
7
|
# File 'lib/ey_stonith/commands/notify.rb', line 5
def self.command
'notify'
end
|
Instance Method Details
#invoke ⇒ Object
17
18
19
20
21
22
|
# File 'lib/ey_stonith/commands/notify.rb', line 17
def invoke
Stonith.logger.warn "Notifying provisioning server that master is down."
history << :notify
notify!
exit
end
|
#notify! ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/ey_stonith/commands/notify.rb', line 24
def notify!
notifier = AwsmNotifier.new(config.notify_uri, config.endpoint_id, config.endpoint_token, {
'monitor_host' => config.monitor_host
})
notifier.notify method(:success), method(:unreachable)
end
|
#notify_path ⇒ Object
13
14
15
|
# File 'lib/ey_stonith/commands/notify.rb', line 13
def notify_path
@notify_path ||= config.notify_path
end
|
#success(data) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/ey_stonith/commands/notify.rb', line 32
def success(data)
history << :notified
count = data['notification_count'] || 'N/A'
takeover = data['takeover'].inspect
Stonith.logger.info "Provisioning server notified: (notification_count: #{count}, takeover: #{takeover})"
end
|
#unreachable ⇒ Object
39
40
41
42
43
|
# File 'lib/ey_stonith/commands/notify.rb', line 39
def unreachable
msg = "Unable to notify provisioning server that master is down."
Stonith.logger.warn msg
abort "#{msg}\nIf you're running this from the command line, you should run `stonith notify` again."
end
|