rudy 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/CHANGES.txt +8 -1
  2. data/bin/rudy +4 -0
  3. data/bin/rudy-ec2 +1 -0
  4. data/lib/rudy/aws/ec2/group.rb +0 -2
  5. data/lib/rudy/aws/ec2.rb +4 -5
  6. data/lib/rudy/aws/sdb.rb +3 -3
  7. data/lib/rudy/cli/aws/ec2/addresses.rb +5 -5
  8. data/lib/rudy/cli/aws/ec2/candy.rb +16 -16
  9. data/lib/rudy/cli/aws/ec2/groups.rb +6 -6
  10. data/lib/rudy/cli/aws/ec2/images.rb +3 -3
  11. data/lib/rudy/cli/aws/ec2/info.rb +18 -18
  12. data/lib/rudy/cli/aws/ec2/instances.rb +15 -15
  13. data/lib/rudy/cli/aws/ec2/keypairs.rb +6 -6
  14. data/lib/rudy/cli/aws/ec2/snapshots.rb +1 -1
  15. data/lib/rudy/cli/aws/ec2/volumes.rb +10 -10
  16. data/lib/rudy/cli/backups.rb +5 -5
  17. data/lib/rudy/cli/base.rb +9 -9
  18. data/lib/rudy/cli/candy.rb +1 -1
  19. data/lib/rudy/cli/config.rb +6 -6
  20. data/lib/rudy/cli/disks.rb +5 -5
  21. data/lib/rudy/cli/images.rb +12 -12
  22. data/lib/rudy/cli/info.rb +9 -9
  23. data/lib/rudy/cli/keypairs.rb +5 -5
  24. data/lib/rudy/cli/machines.rb +26 -26
  25. data/lib/rudy/cli/metadata.rb +2 -2
  26. data/lib/rudy/cli/networks.rb +17 -8
  27. data/lib/rudy/cli/routines.rb +10 -10
  28. data/lib/rudy/config/objects.rb +1 -1
  29. data/lib/rudy/config.rb +2 -2
  30. data/lib/rudy/huxtable.rb +11 -5
  31. data/lib/rudy/machines.rb +4 -1
  32. data/lib/rudy/metadata/machine.rb +18 -9
  33. data/lib/rudy/routines/handlers/base.rb +6 -6
  34. data/lib/rudy/routines/handlers/disks.rb +9 -9
  35. data/lib/rudy/routines/handlers/group.rb +1 -1
  36. data/lib/rudy/routines/handlers/rye.rb +7 -5
  37. data/lib/rudy/routines/handlers/script.rb +2 -2
  38. data/lib/rudy/routines/passthrough.rb +11 -4
  39. data/lib/rudy/routines/reboot.rb +16 -5
  40. data/lib/rudy/routines/shutdown.rb +14 -5
  41. data/lib/rudy/routines/startup.rb +5 -6
  42. data/lib/rudy/routines.rb +4 -4
  43. data/lib/rudy/utils.rb +2 -2
  44. data/lib/rudy.rb +1 -1
  45. data/rudy.gemspec +1 -1
  46. metadata +2 -2
@@ -126,6 +126,16 @@ module Rudy
126
126
  k.decrypt encrtypted_text
127
127
  end
128
128
 
129
+ def create_mock
130
+ refresh!
131
+ @dns_public = @dns_private = nil
132
+ inst = Rudy::AWS::EC2::Instances.list(:running).first
133
+ @instid = inst.awsid
134
+ self.save :replace
135
+ sleep 1
136
+ self
137
+ end
138
+
129
139
  def create
130
140
  raise "#{name} is already running" if instance_running?
131
141
 
@@ -140,11 +150,7 @@ module Rudy
140
150
  :machine_data => self.generate_machine_data.to_yaml
141
151
  }
142
152
 
143
- Rudy::Huxtable.ld "OPTS: #{opts.inspect}"
144
-
145
- #@dns_public = @dns_private = nil
146
- #inst = Rudy::AWS::EC2::Instances.list(:running).first
147
- #@instid = inst.awsid
153
+ ld "OPTS: #{opts.inspect}"
148
154
 
149
155
  Rudy::AWS::EC2::Instances.create(opts) do |inst|
150
156
  @instid = inst.awsid
@@ -157,19 +163,22 @@ module Rudy
157
163
  if @address
158
164
  # Make sure the address is associated to the current account
159
165
  if Rudy::AWS::EC2::Addresses.exists?(@address)
160
- puts "Associating #{@address} to #{@instid}"
166
+ li "Associating #{@address} to #{@instid}"
161
167
  Rudy::AWS::EC2::Addresses.associate(@address, @instid)
162
168
  else
163
- STDERR.puts "Unknown address: #{@address}"
169
+ le "Unknown address: #{@address}"
164
170
  end
165
171
  end
166
172
  rescue => ex
167
- STDERR.puts "Error: #{ex.message}"
168
- STDERR.puts ex.backtrace if Rudy.debug?
173
+ le "Error: #{ex.message}"
174
+ le ex.backtrace if Rudy.debug?
169
175
  end
170
176
  end
171
177
 
172
178
  self.save
179
+
180
+ sleep 1 # Eventual consistency in SimpleDB
181
+
173
182
  self
174
183
  end
175
184
 
@@ -8,10 +8,10 @@ module Rudy; module Routines; module Handlers;
8
8
  begin
9
9
  ret = command.call if command
10
10
  return unless ret.is_a?(Rye::Rap)
11
- puts ' ' << ret.stdout.join("#{$/} ") if !ret.stdout.empty?
11
+ li ' ' << ret.stdout.join("#{$/} ") if !ret.stdout.empty?
12
12
  print_response(ret)
13
13
  rescue IOError => ex
14
- STDERR.puts " Connection Error (#{ex.message})".color(:red)
14
+ le " Connection Error (#{ex.message})".color(:red)
15
15
  choice = Annoy.get_user_input('(S)kip (R)etry (F)orce (A)bort: ', nil, 3600) || ''
16
16
  if choice.match(/\AS/i)
17
17
  return
@@ -38,11 +38,11 @@ module Rudy; module Routines; module Handlers;
38
38
  colour = rap.exit_code != 0 ? :red : :normal
39
39
  [:stderr].each do |sumpin|
40
40
  next if rap.send(sumpin).empty?
41
- STDERR.puts
42
- STDERR.puts((" #{sumpin.to_s.upcase} " << '-'*38).color(colour).bright)
43
- STDERR.puts " " << rap.send(sumpin).join("#{$/} ").color(colour)
41
+ le
42
+ le((" #{sumpin.to_s.upcase} " << '-'*38).color(colour).bright)
43
+ le " " << rap.send(sumpin).join("#{$/} ").color(colour)
44
44
  end
45
- STDERR.puts " Exit code: #{rap.exit_code}".color(colour) if rap.exit_code != 0
45
+ le " Exit code: #{rap.exit_code}".color(colour) if rap.exit_code != 0
46
46
  end
47
47
 
48
48
  end
@@ -82,7 +82,7 @@ module Rudy::Routines::Handlers;
82
82
 
83
83
  def create(rbox, disk, index)
84
84
  if disk.exists?
85
- puts "Disk found: #{disk.name}"
85
+ li "Disk found: #{disk.name}"
86
86
  disk.refresh!
87
87
  end
88
88
 
@@ -179,7 +179,7 @@ module Rudy::Routines::Handlers;
179
179
  raise Rudy::Disks::AlreadyMounted, disk.name if disk.mounted?
180
180
  end
181
181
 
182
- puts "Mounting at #{disk.path}... "
182
+ li "Mounting at #{disk.path}... "
183
183
 
184
184
 
185
185
  rbox.mkdir(:p, disk.path)
@@ -201,7 +201,7 @@ module Rudy::Routines::Handlers;
201
201
  raise Rudy::Disks::NotMounted, disk.name if !disk.mounted?
202
202
  end
203
203
 
204
- puts "Unmounting #{disk.path}... "
204
+ li "Unmounting #{disk.path}... "
205
205
 
206
206
  unless rbox.nil? || rbox.stash.windows?
207
207
  rbox.umount(disk.path)
@@ -232,11 +232,11 @@ module Rudy::Routines::Handlers;
232
232
 
233
233
  print "Creating #{disk.fstype} filesystem for #{disk.path}... "
234
234
  if rbox.stash.windows?
235
- puts "(index: #{index})"
235
+ li "(index: #{index})"
236
236
  windows_diskpart_partition rbox, disk, index
237
237
  disk.mounted = true
238
238
  else
239
- puts $/
239
+ li $/
240
240
  rbox.rudy_mkfs(:t, disk.fstype, :F, disk.device)
241
241
  end
242
242
 
@@ -257,7 +257,7 @@ module Rudy::Routines::Handlers;
257
257
  raise Rudy::Disks::InUse, disk.name if disk.volume_attached?
258
258
  end
259
259
 
260
- puts "Destroying #{disk.name}"
260
+ li "Destroying #{disk.name}"
261
261
  disk.destroy
262
262
  end
263
263
 
@@ -268,13 +268,13 @@ module Rudy::Routines::Handlers;
268
268
  raise Rudy::Disks::NotAttached, disk.name if !disk.volume_attached?
269
269
 
270
270
  back = disk.archive
271
- puts "Created backup: #{back.name}"
271
+ li "Created backup: #{back.name}"
272
272
  end
273
273
 
274
274
  def restore(rbox, disk, index)
275
275
 
276
276
  if disk.exists?
277
- puts "Disk found: #{disk.name}"
277
+ li "Disk found: #{disk.name}"
278
278
  disk.refresh!
279
279
  end
280
280
 
@@ -290,7 +290,7 @@ module Rudy::Routines::Handlers;
290
290
 
291
291
  disk.size, disk.fstype = latest_backup.size, latest_backup.fstype
292
292
 
293
- puts "Backup found: #{latest_backup.name}"
293
+ li "Backup found: #{latest_backup.name}"
294
294
 
295
295
  unless disk.volume_exists?
296
296
  msg = "Creating volume... "
@@ -70,7 +70,7 @@ module Rudy; module Routines; module Handlers;
70
70
  end
71
71
 
72
72
  ports.each do |port|
73
- #li "Authorizing port #{port} access for: #{addresses.join(', ')}"
73
+ li "#{action} port #{port} access for: #{addresses.join(', ')}"
74
74
  Rudy::AWS::EC2::Groups.send(action, name, addresses, [[port, port]]) rescue nil
75
75
  end
76
76
  end
@@ -13,7 +13,7 @@ module Rudy::Routines::Handlers;
13
13
  def create_box(hostname, opts={})
14
14
  ld [:hostname, hostname, opts, caller[0]]
15
15
  opts = {
16
- :info => (@@global.verbose >= 3), # rudy -vvv
16
+ :info => (@@global.verbose >= 2), # rudy -vv
17
17
  :debug => false,
18
18
  :user => current_machine_user,
19
19
  :ostype => current_machine_os || :unix,
@@ -35,14 +35,14 @@ module Rudy::Routines::Handlers;
35
35
  # We define hooks so we can still print each command and its output
36
36
  # when running the command blocks. NOTE: We only print this in
37
37
  # verbosity mode.
38
- if @@global.verbose > 0 && !@@global.parallel
38
+ if !@@global.parallel && !@@global.quiet
39
39
  # This block gets called for every command method call.
40
40
  box.pre_command_hook do |cmd, user, host, nickname|
41
41
  print_command user, nickname, cmd
42
42
  end
43
43
  end
44
44
 
45
- if @@global.verbose > 1
45
+ if @@global.verbose > 0 && !@@global.quiet
46
46
  # And this one gets called after each command method call.
47
47
  box.post_command_hook do |ret|
48
48
  print_response ret
@@ -68,7 +68,9 @@ module Rudy::Routines::Handlers;
68
68
  # NOTE: Windows machines are skipped and not added to the set.
69
69
  def create_set(hostnames, opts={})
70
70
  hostnames ||= []
71
-
71
+
72
+ ld "Creating set from:", hostnames.inspect
73
+
72
74
  opts = {
73
75
  :user => (current_machine_user).to_s,
74
76
  :parallel => @@global.parallel
@@ -164,7 +166,7 @@ module Rudy::Routines::Handlers;
164
166
  else
165
167
  le prefix << "#{ex.class}: #{ex.message}".color(:red)
166
168
  end
167
- le *ex.backtrace if @@global.verbose > 2
169
+ le ex.backtrace if @@global.verbose > 1
168
170
  end
169
171
 
170
172
 
@@ -59,8 +59,8 @@ module Rudy; module Routines; module Handlers;
59
59
  robj.switch_user user
60
60
 
61
61
  rescue Net::SSH::AuthenticationFailed, Net::SSH::HostKeyMismatch => ex
62
- STDERR.puts "Error connecting: #{ex.message}".color(:red)
63
- STDERR.puts "Skipping user #{user}".color(:red)
62
+ le "Error connecting: #{ex.message}".color(:red)
63
+ le "Skipping user #{user}".color(:red)
64
64
  next
65
65
  end
66
66
  end
@@ -3,14 +3,21 @@ module Rudy; module Routines;
3
3
  class Passthrough < Rudy::Routines::Base
4
4
 
5
5
  def init(*args)
6
- @machines = Rudy::Machines.list || []
7
- @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
6
+ Rudy::Routines.rescue {
7
+ @machines = Rudy::Machines.list || []
8
+ @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
9
+ }
8
10
  end
9
11
 
10
12
  def execute
11
- li "Executing routine: #{@name}"
12
- return @machines unless run?
13
13
  Rudy::Routines::Handlers::Depends.execute_all @before
14
+ li " Executing routine: #{@name} ".att(:reverse)
15
+ # Re-retreive the machine set to reflect dependency changes
16
+ Rudy::Routines.rescue {
17
+ @machines = Rudy::Machines.list || []
18
+ @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
19
+ }
20
+ return @machines unless run?
14
21
  Rudy::Routines.runner(@routine, @@rset, @@lbox, @argv)
15
22
  Rudy::Routines::Handlers::Depends.execute_all @after
16
23
  @machines
@@ -11,8 +11,10 @@ module Rudy; module Routines;
11
11
 
12
12
  def init(*args)
13
13
  @routine ||= {}
14
- @machines = Rudy::Machines.list
15
- @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
14
+ Rudy::Routines.rescue {
15
+ @machines = Rudy::Machines.list || []
16
+ @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
17
+ }
16
18
  end
17
19
 
18
20
  # Startup routines run in the following order:
@@ -24,10 +26,19 @@ module Rudy; module Routines;
24
26
  # * all other actions
25
27
  # * after dependencies
26
28
  def execute
27
- li "Executing routine: #{@name}"
28
- ld "[this is a generic routine]" if @routine.empty?
29
29
 
30
30
  if run?
31
+ Rudy::Routines::Handlers::Depends.execute_all @before
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
+
31
42
  Rudy::Routines.rescue {
32
43
  Rudy::Routines::Handlers::Group.authorize rescue nil
33
44
  }
@@ -57,7 +68,7 @@ module Rudy; module Routines;
57
68
  li "Rebooting #{current_group_name}..."
58
69
  @machines.each { |m| m.restart } if run?
59
70
 
60
- 15.times { print '.'; Kernel.sleep 2 }; puts $/ # Wait for 30 seconds
71
+ 15.times { print '.'; Kernel.sleep 2 }; li $/ # Wait for 30 seconds
61
72
 
62
73
  Rudy::Routines.rescue {
63
74
  if !Rudy::Routines::Handlers::Host.is_running? @@rset
@@ -9,9 +9,11 @@ module Rudy; module Routines;
9
9
  :local, :remote, :after_local, :after]
10
10
 
11
11
  def init(*args)
12
- @machines = Rudy::Machines.list || []
13
- @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
14
12
  @routine ||= {}
13
+ Rudy::Routines.rescue {
14
+ @machines = Rudy::Machines.list || []
15
+ @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
16
+ }
15
17
  end
16
18
 
17
19
  # Startup routines run in the following order:
@@ -21,8 +23,6 @@ module Rudy; module Routines;
21
23
  # * after_local (if present)
22
24
  # * after dependencies
23
25
  def execute
24
- li "Executing routine: #{@name}"
25
- ld "[this is a generic routine]" if @routine.empty?
26
26
 
27
27
  # We need to remove after_local so the runner doesn't see it
28
28
  after_local = @routine.delete(:after_local)
@@ -33,7 +33,16 @@ module Rudy; module Routines;
33
33
  }
34
34
 
35
35
  Rudy::Routines::Handlers::Depends.execute_all @before
36
-
36
+
37
+ li " Executing routine: #{@name} ".att(:reverse)
38
+ ld "[this is a generic routine]" if @routine.empty?
39
+
40
+ # Re-retreive the machine set to reflect dependency changes
41
+ Rudy::Routines.rescue {
42
+ @machines = Rudy::Machines.list || []
43
+ @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
44
+ }
45
+
37
46
  # This is the meat of the sandwich
38
47
  Rudy::Routines.runner(@routine, @@rset, @@lbox, @argv)
39
48
 
@@ -20,13 +20,13 @@ module Rudy; module Routines;
20
20
  # * all other actions
21
21
  # * after dependencies
22
22
  def execute
23
- li "Executing routine: #{@name}"
24
- ld "[this is a generic routine]" if @routine.empty?
25
-
26
23
 
27
24
  if run?
28
25
  Rudy::Routines::Handlers::Depends.execute_all @before
29
-
26
+
27
+ li " Executing routine: #{@name} ".att(:reverse)
28
+ ld "[this is a generic routine]" if @routine.empty?
29
+
30
30
  if @routine.has_key? :before_local
31
31
  handler = Rudy::Routines.get_handler :local
32
32
  Rudy::Routines.rescue {
@@ -52,7 +52,7 @@ module Rudy; module Routines;
52
52
 
53
53
  end
54
54
 
55
- ## puts Rudy::Routines.machine_separator(machine.name, machine.awsid)
55
+ ## li Rudy::Routines.machine_separator(machine.name, machine.awsid)
56
56
 
57
57
  # If this is a testrun we won't create new instances
58
58
  # we'll just grab the list of machines in this group.
@@ -62,7 +62,6 @@ module Rudy; module Routines;
62
62
  @@rset = Rudy::Routines::Handlers::RyeTools.create_set @machines
63
63
  }
64
64
 
65
- sleep 1 # SimpleDB eventual consistency
66
65
 
67
66
  Rudy::Routines.rescue {
68
67
  if !Rudy::Routines::Handlers::Host.is_running? @@rset
data/lib/rudy/routines.rb CHANGED
@@ -87,7 +87,7 @@ module Rudy
87
87
  def self.runner(routine, rset, lbox, argv=nil)
88
88
  routine.each_pair do |name,definition|
89
89
  handler = Rudy::Routines.get_handler name
90
- Rudy::Huxtable.ld " executing handler: #{name}"
90
+ Rudy::Huxtable.li " #{name}:".bright
91
91
  self.rescue {
92
92
  handler.execute(name, definition, rset, lbox, argv)
93
93
  }
@@ -99,8 +99,8 @@ module Rudy
99
99
  begin
100
100
  ret = bloc_party.call
101
101
  rescue NameError, ArgumentError, RuntimeError, Errno::ECONNREFUSED => ex
102
- STDERR.puts " #{ex.class}: #{ex.message}".color(:red)
103
- STDERR.puts ex.backtrace if Rudy.debug?
102
+ Rudy::Huxtable.le "#{ex.class}: #{ex.message}".color(:red)
103
+ Rudy::Huxtable.le ex.backtrace if Rudy.debug?
104
104
  unless Rudy::Huxtable.global.parallel
105
105
  choice = Annoy.get_user_input('(S)kip (A)bort: ', nil, 3600) || ''
106
106
  if choice.match(/\AS/i)
@@ -110,7 +110,7 @@ module Rudy
110
110
  end
111
111
  end
112
112
  rescue Interrupt
113
- puts "Aborting..."
113
+ li "Aborting..."
114
114
  exit 12
115
115
  end
116
116
  ret
data/lib/rudy/utils.rb CHANGED
@@ -23,7 +23,7 @@ module Rudy
23
23
  break if ip && !ip.empty?
24
24
  end
25
25
  rescue SocketError, Errno::ETIMEDOUT => ex
26
- STDERR.puts "Connection Error. Check your internets!"
26
+ Rudy::Huxtable.le "Connection Error. Check your internets!"
27
27
  end
28
28
  ip
29
29
  end
@@ -297,7 +297,7 @@ module Rudy::Utils::RSSReader
297
297
  begin
298
298
  xmlstr = Net::HTTP.get(URI.parse(uri))
299
299
  rescue SocketError, Errno::ETIMEDOUT
300
- STDERR.puts "Connection Error. Check your internets!"
300
+ Rudy::Huxtable.le "Connection Error. Check your internets!"
301
301
  end
302
302
 
303
303
  xml = REXML::Document.new xmlstr
data/lib/rudy.rb CHANGED
@@ -42,7 +42,7 @@ module Rudy
42
42
  unless defined?(MAJOR)
43
43
  MAJOR = 0.freeze
44
44
  MINOR = 9.freeze
45
- TINY = 3.freeze
45
+ TINY = 4.freeze
46
46
  end
47
47
  def self.to_s; [MAJOR, MINOR, TINY].join('.'); end
48
48
  def self.to_f; self.to_s.to_f; end
data/rudy.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "rudy"
3
3
  s.rubyforge_project = 'rudy'
4
- s.version = "0.9.3"
4
+ s.version = "0.9.4"
5
5
  s.summary = "Rudy: Not your grandparents' EC2 deployment tool."
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-26 00:00:00 -04:00
12
+ date: 2009-08-28 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency