Class: Rudy::CLI::Routines

Inherits:
CommandBase
  • Object
show all
Defined in:
lib/rudy/cli/routines.rb

Instance Attribute Summary

Attributes inherited from CommandBase

#config

Instance Method Summary collapse

Methods included from Huxtable

change_environment, change_position, change_region, change_role, change_zone, #check_keys, #config_dirname, create_domain, #current_group_name, #current_machine_address, #current_machine_count, #current_machine_group, #current_machine_hostname, #current_machine_image, #current_machine_name, #current_machine_size, #current_user, #current_user_keypairpath, debug?, #debug?, domain, domain_exists?, #group_metadata, #has_keypair?, #has_keys?, #has_pem_keys?, #has_root_keypair?, keypair_path_to_name, #known_machine_group?, #root_keypairname, #root_keypairpath, #switch_user, update_config, update_global, update_logger, #user_keypairname, #user_keypairpath

Instance Method Details

#passthroughObject

All unknown commands are sent here (using Drydock’s trawler). By default, the generic passthrough routine is executed which does nothing other than execute the routine config block that matches @alias (the name used on the command-line). Calling

$ rudy unknown

would end up here because it’s an unknown command. Passthrough then looks for a routine config in the current environment and role called “unknown”. If found, it’s executed otherwise it’ll raise an exception.



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/rudy/cli/routines.rb', line 66

def passthrough
  machines = @rr.execute
  
  unless machines.empty?
    puts $/, "The following machines were processed:"
    machines.each do |machine|
      puts @@global.verbose > 0 ? machine.inspect : machine.dump(@@global.format)
    end
  end
  
end

#passthrough_valid?Boolean

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/rudy/cli/routines.rb', line 48

def passthrough_valid?
  @rr = Rudy::Routines::Passthrough.new(@alias)
  @rr.raise_early_exceptions
  true
end

#rebootObject



24
25
26
27
28
29
30
# File 'lib/rudy/cli/routines.rb', line 24

def reboot
  machines = @rr.execute
  puts $/, "The following machines have been restarted:"
  machines.each do |machine|
    puts machine.to_s
  end
end

#reboot_valid?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/rudy/cli/routines.rb', line 19

def reboot_valid?
  @rr = Rudy::Routines::Reboot.new
  @rr.raise_early_exceptions
  true
end

#releaseObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/rudy/cli/routines.rb', line 37

def release
  machines = @rr.execute
  
  unless machines.empty?
    puts $/, "The following machines were processed:"
    machines.each do |machine|
      puts machine.to_s
    end
  end
end

#release_valid?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/rudy/cli/routines.rb', line 32

def release_valid?
  @rr = Rudy::Routines::Release.new(@alias) # Important: could be rerelease
  @rr.raise_early_exceptions
  true
end

#shutdownObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/rudy/cli/routines.rb', line 83

def shutdown
  routine = fetch_routine_config(:shutdown)
  
  puts "All machines in #{current_machine_group} will be shutdown".bright
  if routine && routine.disks
    if routine.disks.destroy
      puts "The following filesystems will be destroyed:".bright
      puts routine.disks.destroy.keys.join($/).bright
    end
  end
  
  execute_check :medium
  
  machines = @rr.execute
  puts $/, "The following instances have been destroyed:"
  machines.each do |machine|
    puts '%s %s ' % [machine.name.bright, machine.awsid]
  end
  
  
end

#shutdown_valid?Boolean

Returns:

  • (Boolean)


78
79
80
81
82
# File 'lib/rudy/cli/routines.rb', line 78

def shutdown_valid?
  @rr = Rudy::Routines::Shutdown.new
  @rr.raise_early_exceptions
  true
end

#startupObject



11
12
13
14
15
16
17
# File 'lib/rudy/cli/routines.rb', line 11

def startup
  machines = @rr.execute || []
  puts $/, "The following machines are now available:" unless machines.empty?
  machines.each do |machine|
    puts machine.to_s
  end
end

#startup_valid?Boolean

Returns:

  • (Boolean)


6
7
8
9
10
# File 'lib/rudy/cli/routines.rb', line 6

def startup_valid?
  @rr = Rudy::Routines::Startup.new
  @rr.raise_early_exceptions
  true
end