Rudy::Routines
Every Rudy routine is associated to a handler. There are four standard handler types: Startup, Shutdown, Reboot, and Passthrough. The first three are associated to routines of the same same. All other routines are handled by Rudy::Routines::Passthrough.
An individual routine is made up of various actions. Each action is associated to one of the following handlers: depends, disk, script, user. See each handler for the list of actions it is responsible for.
Methods
public class
Classes and Modules
Module Rudy::Routines::HandlersClass Rudy::Routines::Base
Class Rudy::Routines::EmptyDepends
Class Rudy::Routines::GroupNotAvailable
Class Rudy::Routines::GroupNotRunning
Class Rudy::Routines::NoHandler
Class Rudy::Routines::NoRoutine
Class Rudy::Routines::Passthrough
Class Rudy::Routines::Reboot
Class Rudy::Routines::Shutdown
Class Rudy::Routines::Startup
Class Rudy::Routines::UnsupportedActions
Public class methods
Add a routine handler to @@handler.
# File lib/rudy/routines.rb, line 73 73: def self.add_handler(name, klass) 74: add_some_class @@handler, Rudy::Routines::Handlers::Base, name, klass 75: end
Add a routine handler to @@routine.
- routine_name Literally the name of the routine that will have a special handler, like startup, shutdown, and reboot.
- handler The class that will handle this routine. It must inherit Rudy::Routine::Base
Returns the value of handler.
# File lib/rudy/routines.rb, line 62 62: def self.add_routine(name, klass) 63: add_some_class @@routine, Rudy::Routines::Base, name, klass 64: end
Returns the value in the @@handler associated to the key name if it exists, otherwise it returns nil
# File lib/rudy/routines.rb, line 79 79: def self.get_handler(name) 80: get_some_class(@@handler, name) || nil 81: end
Returns the value in the @@routine associated to the key routine_name if it exists, otherwise it returns Rudy::Routines::Passthrough
# File lib/rudy/routines.rb, line 68 68: def self.get_routine(name) 69: get_some_class(@@routine, name) || Rudy::Routines::Passthrough 70: end
# File lib/rudy/routines.rb, line 84 84: def self.has_handler?(name); @@handler.has_key?(name); end
# File lib/rudy/routines.rb, line 83 83: def self.has_routine?(name); @@routine.has_key?(name); end
# File lib/rudy/routines.rb, line 120 120: def self.machine_separator(name, awsid) 121: ('%s %-50s awsid: %s ' % [$/, name, awsid]).att(:reverse) 122: end
# File lib/rudy/routines.rb, line 97 97: def self.rescue(ret=nil, &bloc_party) 98: 99: begin 100: ret = bloc_party.call 101: rescue NameError, ArgumentError, RuntimeError, Errno::ECONNREFUSED => ex 102: Rudy::Huxtable.le "#{ex.class}: #{ex.message}".color(:red) 103: Rudy::Huxtable.le ex.backtrace if Rudy.debug? 104: 105: unless Rudy::Huxtable.global.parallel 106: choice = Annoy.get_user_input('(S)kip (A)bort: ', nil, 3600) || '' 107: if choice.match(/\AS/i) 108: # do nothing 109: else 110: exit 12 111: end 112: end 113: rescue Interrupt 114: Rudy::Huxtable.li "Aborting..." 115: exit 12 116: end 117: ret 118: end
Executes a routine block
# File lib/rudy/routines.rb, line 87 87: def self.runner(routine, rset, lbox, argv=nil) 88: routine.each_pair do |name,definition| 89: handler = Rudy::Routines.get_handler name 90: #Rudy::Huxtable.li " #{name}:".bright 91: self.rescue { 92: handler.execute(name, definition, rset, lbox, argv) 93: } 94: end 95: end