Public instance methods
execute
()
Startup routines run in the following order:
- before_local (if present)
- before_remote (if present)
- Reboot instances
- Set hostname
- before dependencies
- all other actions
- after dependencies
[show source]
# File lib/rudy/routines/reboot.rb, line 28 28: def execute 29: 30: if run? 31: Rudy::Routines::Handlers::Depends.execute_all @before, @argv 32: 33: li " Executing routine: #{@name} ".att(:reverse), "" 34: ld "[this is a generic routine]" if @routine.empty? 35: 36: # Re-retreive the machine set to reflect dependency changes 37: Rudy::Routines.rescue { 38: @machines = Rudy::Machines.list || [] 39: @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines 40: } 41: 42: Rudy::Routines.rescue { 43: Rudy::Routines::Handlers::Group.authorize rescue nil 44: } 45: 46: if @routine.has_key? :before_local 47: handler = Rudy::Routines.get_handler :local 48: Rudy::Routines.rescue { 49: handler.execute(:local, @routine.delete(:before_local), nil, @@lbox, @argv) 50: } 51: end 52: 53: if @routine.has_key? :before_remote 54: handler = Rudy::Routines.get_handler :remote 55: Rudy::Routines.rescue { 56: handler.execute(:remote, @routine.delete(:before_remote), @@rset, @@lbox, @argv) 57: } 58: end 59: end 60: 61: Rudy::Routines.rescue { 62: if Rudy::Routines::Handlers::Disks.mount? @routine 63: fake = Hash[:umount => @routine.disks[:mount]] 64: Rudy::Routines::Handlers::Disks.execute :umount, fake, @@rset, @@lbox, @argv 65: end 66: } 67: 68: li "Rebooting #{current_group_name}..." 69: @machines.each { |m| m.restart } if run? 70: 71: 15.times { print '.'; Kernel.sleep 2 }; li $/ # Wait for 30 seconds 72: 73: Rudy::Routines.rescue { 74: if !Rudy::Routines::Handlers::Host.is_running? @@rset 75: a = @@rset.boxes.select { |box| !box.stash.instance_running? } 76: raise GroupNotRunning, a 77: end 78: } 79: 80: # This is important b/c the machines will not 81: # have DNS info until after they are running. 82: Rudy::Routines.rescue { Rudy::Routines::Handlers::Host.update_dns @@rset } 83: 84: Rudy::Routines.rescue { 85: if !Rudy::Routines::Handlers::Host.is_available? @@rset 86: a = @@rset.boxes.select { |box| !box.stash.instance_available? } 87: raise GroupNotAvailable, a 88: end 89: } 90: Rudy::Routines.rescue { 91: Rudy::Routines::Handlers::Host.set_hostname @@rset 92: } 93: 94: if run? 95: # This is the meat of the sandwich 96: Rudy::Routines.runner @routine, @@rset, @@lbox, @argv 97: 98: Rudy::Routines.rescue { 99: Rudy::Routines::Handlers::Depends.execute_all @after, @argv 100: } 101: end 102: 103: @machines 104: end
init
(*args)
[show source]
# File lib/rudy/routines/reboot.rb, line 12 12: def init(*args) 13: @routine ||= {} 14: Rudy::Routines.rescue { 15: @machines = Rudy::Machines.list || [] 16: @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines 17: } 18: end
raise_early_exceptions
()
Called by generic_machine_runner
[show source]
# File lib/rudy/routines/reboot.rb, line 107 107: def raise_early_exceptions 108: raise NoMachinesConfig unless @@config.machines 109: # There's no keypair check here because Rudy::Machines will attempt 110: # to create one. 111: raise MachineGroupNotDefined, current_machine_group unless known_machine_group? 112: 113: # If this is a test run we don't care if the group is running 114: if run? 115: raise MachineGroupNotRunning, current_machine_group unless Rudy::Machines.running? 116: end 117: 118: if @routine 119: bad = @routine.keys - @@allowed_actions 120: raise UnsupportedActions.new(@name, bad) unless bad.empty? 121: end 122: 123: if @machines 124: down = @@rset.boxes.select { |box| !box.stash.instance_running? } 125: raise GroupNotAvailable, down unless down.empty? 126: end 127: 128: end