class Rudy::Routines::Base
Attributes
machines[R]
An Array Rudy::Machines objects that will be processed
Public Class Methods
disable_run()
click to toggle source
# File lib/rudy/routines/base.rb, line 9 def self.disable_run; @@run = false; end
enable_run()
click to toggle source
# File lib/rudy/routines/base.rb, line 10 def self.enable_run; @@run = true; end
new(name=nil, option={}, argv=[], *args)
click to toggle source
-
name
The name of the command specified on the command line -
option
A Hash or OpenStruct of named command line options. If it's a Hash it will be converted to an OpenStruct. -
argv
An Array of arguments
option
and argv
are made available to the routine
block.
routines do magic do |options,argv| ... end end
# File lib/rudy/routines/base.rb, line 32 def initialize(name=nil, option={}, argv=[], *args) name ||= (self.class.to_s.split(/::/)).last.downcase option = OpenStruct.new(option) if option.is_a? Hash @name, @option, @argv = name.to_sym, option, argv a, s, r = @@global.accesskey, @@global.secretkey, @@global.region @@sdb ||= Rudy::AWS::SDB.new(a, s, r) # Grab the routines configuration for this routine name # e.g. startup, sysupdate, installdeps @routine = fetch_routine_config @name rescue {} ld "Routine: #{@routine.inspect}" if @routine # Removes the dependencies from the routines hash. # We run these separately from the other actions. @before, @after = @routine.delete(:before), @routine.delete(:after) end # Share one Rye::Box instance for localhost across all routines unless defined?(@@lbox) host, opts = @@global.localhost, { :user => Rudy.sysinfo.user } @@lbox = Rudy::Routines::Handlers::RyeTools.create_box host, opts end disable_run if @@global.testrun # We create these frozen globals for the benefit of # the local and remote routine blocks. $global = @@global.dup.freeze unless $global $option = option.dup.freeze unless $option ## TODO: get the machine config for just the current machine group. This ## probably requires Caesars to be aware of which nodes are structural. ##$config = fetch_machine_config unless $config init(*args) if respond_to? :init end
run?()
click to toggle source
# File lib/rudy/routines/base.rb, line 8 def self.run?; @@run; end
Public Instance Methods
disable_run()
click to toggle source
# File lib/rudy/routines/base.rb, line 13 def disable_run; @@run = false; end
enable_run()
click to toggle source
# File lib/rudy/routines/base.rb, line 14 def enable_run; @@run = true; end
execute()
click to toggle source
# File lib/rudy/routines/base.rb, line 72 def execute; raise "Please override"; end
raise_early_exceptions()
click to toggle source
# File lib/rudy/routines/base.rb, line 71 def raise_early_exceptions; raise "Please override"; end
run?()
click to toggle source
# File lib/rudy/routines/base.rb, line 12 def run?; @@run; end