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.
Add a routine handler to @@handler.
# File lib/rudy/routines.rb, line 73 def self.add_handler(name, klass) add_some_class @@handler, Rudy::Routines::Handlers::Base, name, klass 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 def self.add_routine(name, klass) add_some_class @@routine, Rudy::Routines::Base, name, klass 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 def self.get_handler(name) get_some_class(@@handler, name) || nil 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 def self.get_routine(name) get_some_class(@@routine, name) || Rudy::Routines::Passthrough end
# File lib/rudy/routines.rb, line 84 def self.has_handler?(name); @@handler.has_key?(name); end
# File lib/rudy/routines.rb, line 83 def self.has_routine?(name); @@routine.has_key?(name); end
# File lib/rudy/routines.rb, line 120 def self.machine_separator(name, awsid) ('%s %-50s awsid: %s ' % [$/, name, awsid]).att(:reverse) end
# File lib/rudy/routines.rb, line 97 def self.rescue(ret=nil, &bloc_party) begin ret = bloc_party.call rescue NameError, ArgumentError, RuntimeError, Errno::ECONNREFUSED => ex Rudy::Huxtable.le "#{ex.class}: #{ex.message}".color(:red) Rudy::Huxtable.le ex.backtrace if Rudy.debug? unless Rudy::Huxtable.global.parallel choice = Annoy.get_user_input('(S)kip (A)bort: ', nil, 3600) || '' if choice.match(/\AS/) # do nothing else exit 12 end end rescue Interrupt Rudy::Huxtable.li "Aborting..." exit 12 end ret end
Executes a routine block
# File lib/rudy/routines.rb, line 87 def self.runner(routine, rset, lbox, argv=nil) routine.each_pair do |name,definition| handler = Rudy::Routines.get_handler name #Rudy::Huxtable.li " #{name}:".bright self.rescue { handler.execute(name, definition, rset, lbox, argv) } end end
Generated with the Darkfish Rdoc Generator 2.