Module Rudy::Routines
  1. lib/rudy/routines/base.rb
  2. lib/rudy/routines/handlers/base.rb
  3. lib/rudy/routines/handlers/depends.rb
  4. lib/rudy/routines/handlers/group.rb
  5. lib/rudy/routines/handlers/host.rb
  6. lib/rudy/routines/handlers/keypair.rb
  7. lib/rudy/routines/handlers/script.rb
  8. lib/rudy/routines/handlers/user.rb
  9. lib/rudy/routines/passthrough.rb
  10. lib/rudy/routines/reboot.rb
  11. lib/rudy/routines/shutdown.rb
  12. lib/rudy/routines/startup.rb
  13. lib/rudy/routines.rb
  14. show all

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.

Public class methods

add_handler (name, klass)

Add a routine handler to @@handler.

[show source]
    # 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_routine (name, klass)

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.

[show source]
    # 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
get_handler (name)

Returns the value in the @@handler associated to the key name if it exists, otherwise it returns nil

[show source]
    # File lib/rudy/routines.rb, line 79
79:     def self.get_handler(name)
80:       get_some_class(@@handler, name) || nil
81:     end
get_routine (name)

Returns the value in the @@routine associated to the key routine_name if it exists, otherwise it returns Rudy::Routines::Passthrough

[show source]
    # File lib/rudy/routines.rb, line 68
68:     def self.get_routine(name)
69:       get_some_class(@@routine, name) || Rudy::Routines::Passthrough
70:     end
has_handler? (name)
[show source]
    # File lib/rudy/routines.rb, line 84
84:     def self.has_handler?(name);  @@handler.has_key?(name);  end
has_routine? (name)
[show source]
    # File lib/rudy/routines.rb, line 83
83:     def self.has_routine?(name); @@routine.has_key?(name); end
machine_separator (name, awsid)
[show source]
     # 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
rescue (ret=nil, &bloc_party)
[show source]
     # 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
runner (routine, rset, lbox, argv=nil)

Executes a routine block

[show source]
    # 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