solutious-rudy 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/CHANGES.txt +28 -5
  2. data/README.rdoc +1 -1
  3. data/Rudyfile +51 -19
  4. data/bin/ird +153 -0
  5. data/bin/rudy +18 -23
  6. data/bin/rudy-ec2 +5 -10
  7. data/bin/rudy-s3 +1 -3
  8. data/bin/rudy-sdb +0 -2
  9. data/examples/README.md +10 -0
  10. data/examples/debian-sinatra-passenger/commands.rb +19 -0
  11. data/examples/debian-sinatra-passenger/machines.rb +32 -0
  12. data/examples/debian-sinatra-passenger/routines.rb +30 -0
  13. data/examples/debian-sinatra-thin/commands.rb +17 -0
  14. data/examples/debian-sinatra-thin/machines.rb +35 -0
  15. data/examples/debian-sinatra-thin/routines.rb +72 -0
  16. data/lib/rudy.rb +8 -17
  17. data/lib/rudy/aws.rb +1 -2
  18. data/lib/rudy/aws/ec2/address.rb +0 -1
  19. data/lib/rudy/aws/ec2/snapshot.rb +11 -0
  20. data/lib/rudy/aws/s3.rb +6 -3
  21. data/lib/rudy/cli.rb +12 -2
  22. data/lib/rudy/cli/aws/ec2/candy.rb +19 -48
  23. data/lib/rudy/cli/aws/ec2/images.rb +109 -122
  24. data/lib/rudy/cli/aws/s3/buckets.rb +1 -2
  25. data/lib/rudy/cli/config.rb +13 -0
  26. data/lib/rudy/cli/disks.rb +24 -1
  27. data/lib/rudy/cli/routines.rb +10 -11
  28. data/lib/rudy/config.rb +6 -9
  29. data/lib/rudy/config/objects.rb +4 -0
  30. data/lib/rudy/global.rb +4 -5
  31. data/lib/rudy/huxtable.rb +23 -8
  32. data/lib/rudy/machines.rb +11 -4
  33. data/lib/rudy/metadata.rb +8 -94
  34. data/lib/rudy/metadata/backup.rb +113 -0
  35. data/lib/rudy/metadata/backups.rb +65 -0
  36. data/lib/rudy/{disks.rb → metadata/disk.rb} +36 -69
  37. data/lib/rudy/metadata/disks.rb +67 -0
  38. data/lib/rudy/metadata/objectbase.rb +104 -0
  39. data/lib/rudy/mixins.rb +2 -0
  40. data/lib/rudy/routines.rb +173 -88
  41. data/lib/rudy/routines/helpers/dependshelper.rb +34 -0
  42. data/lib/rudy/routines/helpers/diskhelper.rb +174 -5
  43. data/lib/rudy/routines/helpers/scmhelper.rb +2 -2
  44. data/lib/rudy/routines/helpers/scripthelper.rb +11 -4
  45. data/lib/rudy/routines/passthrough.rb +3 -1
  46. data/lib/rudy/routines/reboot.rb +75 -0
  47. data/lib/rudy/routines/startup.rb +3 -3
  48. data/lib/rudy/scm/git.rb +17 -17
  49. data/lib/rudy/scm/svn.rb +46 -5
  50. data/lib/rudy/utils.rb +3 -2
  51. data/rudy.gemspec +24 -46
  52. data/test/30_sdb_metadata/10_disks_test.rb +5 -5
  53. metadata +35 -67
  54. data/lib/annoy.rb +0 -298
  55. data/lib/console.rb +0 -404
  56. data/lib/escape.rb +0 -305
  57. data/lib/rudy/backup.rb +0 -135
  58. data/lib/storable.rb +0 -292
  59. data/lib/sysinfo.rb +0 -285
  60. data/lib/tryouts.rb +0 -33
  61. data/vendor/highline-1.5.1/CHANGELOG +0 -222
  62. data/vendor/highline-1.5.1/INSTALL +0 -35
  63. data/vendor/highline-1.5.1/LICENSE +0 -7
  64. data/vendor/highline-1.5.1/README +0 -63
  65. data/vendor/highline-1.5.1/Rakefile +0 -82
  66. data/vendor/highline-1.5.1/TODO +0 -6
  67. data/vendor/highline-1.5.1/examples/ansi_colors.rb +0 -38
  68. data/vendor/highline-1.5.1/examples/asking_for_arrays.rb +0 -18
  69. data/vendor/highline-1.5.1/examples/basic_usage.rb +0 -75
  70. data/vendor/highline-1.5.1/examples/color_scheme.rb +0 -32
  71. data/vendor/highline-1.5.1/examples/limit.rb +0 -12
  72. data/vendor/highline-1.5.1/examples/menus.rb +0 -65
  73. data/vendor/highline-1.5.1/examples/overwrite.rb +0 -19
  74. data/vendor/highline-1.5.1/examples/page_and_wrap.rb +0 -322
  75. data/vendor/highline-1.5.1/examples/password.rb +0 -7
  76. data/vendor/highline-1.5.1/examples/trapping_eof.rb +0 -22
  77. data/vendor/highline-1.5.1/examples/using_readline.rb +0 -17
  78. data/vendor/highline-1.5.1/lib/highline.rb +0 -758
  79. data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +0 -120
  80. data/vendor/highline-1.5.1/lib/highline/compatibility.rb +0 -17
  81. data/vendor/highline-1.5.1/lib/highline/import.rb +0 -43
  82. data/vendor/highline-1.5.1/lib/highline/menu.rb +0 -395
  83. data/vendor/highline-1.5.1/lib/highline/question.rb +0 -463
  84. data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +0 -193
  85. data/vendor/highline-1.5.1/setup.rb +0 -1360
  86. data/vendor/highline-1.5.1/test/tc_color_scheme.rb +0 -56
  87. data/vendor/highline-1.5.1/test/tc_highline.rb +0 -823
  88. data/vendor/highline-1.5.1/test/tc_import.rb +0 -54
  89. data/vendor/highline-1.5.1/test/tc_menu.rb +0 -429
  90. data/vendor/highline-1.5.1/test/ts_all.rb +0 -15
@@ -64,7 +64,7 @@ module AWS; module EC2;
64
64
  opts[:group] = :any if @option.all
65
65
  opts[:id] = @option.instid if @option.instid
66
66
 
67
- # Options to be sent to Net::SSH
67
+ # Options to be sent to Rye::Box
68
68
  ssh_opts = { :user => @global.user || Rudy.sysinfo.user, :debug => nil }
69
69
  if @@global.pkey
70
70
  raise "Cannot find file #{@@global.pkey}" unless File.exists?(@@global.pkey)
@@ -124,12 +124,13 @@ module AWS; module EC2;
124
124
  opts[:id] = @argv.shift if Rudy::Utils.is_id?(:instance, @argv.first)
125
125
  opts[:id] &&= [opts[:id]].flatten
126
126
 
127
- # * +:recursive: recursively transfer directories (default: false)
128
- # * +:preserve: preserve atimes and ctimes (default: false)
129
- # * +:task+ one of: :upload (default), :download.
130
- # * +:paths+ an array of paths to copy. The last element is the "to" path.
131
- opts[:recursive] = @option.recursive ? true : false
132
- opts[:preserve] = @option.preserve ? true : false
127
+ # Options to be sent to Net::SSH
128
+ ssh_opts = { :user => @global.user || Rudy.sysinfo.user, :debug => nil }
129
+ if @@global.pkey
130
+ raise "Cannot find file #{@@global.pkey}" unless File.exists?(@@global.pkey)
131
+ raise InsecureKeyPermissions, @@global.pkey unless File.stat(@@global.pkey).mode == 33152
132
+ ssh_opts[:keys] = @@global.pkey
133
+ end
133
134
 
134
135
  opts[:paths] = @argv
135
136
  opts[:dest] = opts[:paths].pop
@@ -139,14 +140,16 @@ module AWS; module EC2;
139
140
  opts[:task] ||= :upload
140
141
  opts[:user] = @global.user || Rudy.sysinfo.user
141
142
 
142
- # Options to be sent to Net::SSH
143
- ssh_opts = { :user => opts[:user], :debug => nil }
144
- ssh_opts[:keys] = @@global.pkey if @@global.pkey
145
-
146
- if @@global.pkey
143
+
144
+ # Options to be sent to Rye::Box
145
+ info = @@global.quiet ? nil : STDERR
146
+ ssh_opts = { :user => @global.user || Rudy.sysinfo.user, :info => info }
147
+ if @@global.pkey
147
148
  raise "Cannot find file #{@@global.pkey}" unless File.exists?(@@global.pkey)
148
- raise "Insecure permissions for #{@@global.pkey}" unless (File.stat(@@global.pkey).mode & 600) == 0
149
+ raise InsecureKeyPermissions, @@global.pkey unless File.stat(@@global.pkey).mode == 33152
150
+ ssh_opts[:keys] = @@global.pkey
149
151
  end
152
+
150
153
 
151
154
  checked = false
152
155
  rudy = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
@@ -171,46 +174,14 @@ module AWS; module EC2;
171
174
  checked = true
172
175
  end
173
176
 
174
- scp_opts = {
175
- :recursive => opts[:recursive],
176
- :preserve => opts[:preserve],
177
- :chunk_size => 16384
178
- }
179
-
180
- Candy.scp(opts[:task], inst.dns_public, opts[:user], @@global.pkey, opts[:paths], opts[:dest], scp_opts)
181
- puts
182
- puts unless @@global.quiet
177
+ # Open the connection and run the command
178
+ rbox = Rye::Box.new(inst.dns_public, ssh_opts)
179
+ rbox.send(opts[:task], opts[:paths], opts[:dest])
183
180
  end
184
181
 
185
182
  end
186
183
 
187
184
 
188
- private
189
-
190
- def Candy.scp(task, host, user, keypairpath, paths, dest, opts)
191
-
192
- connect_opts = {}
193
- connect_opts[:keys] = [keypairpath] if keypairpath
194
-
195
- Net::SCP.start(host, user, connect_opts) do |scp|
196
-
197
- paths.each do |path|
198
- prev_path = nil
199
- scp.send("#{task}", path, dest, opts) do |ch, name, sent, total|
200
- #print "#{name}: #{sent}/#{total}\r"
201
- msg = ((prev_path == name) ? "\r" : "\n") # new line for new file
202
- msg << "#{name}: #{sent}/#{total}" # otherwise, update the same line
203
- print msg
204
- STDOUT.flush # update the screen every cycle
205
- prev_path = name
206
- break if sent == total
207
- end
208
- puts unless prev_path == path
209
- end
210
-
211
- end
212
- end
213
-
214
185
 
215
186
 
216
187
  end
@@ -33,161 +33,148 @@ module AWS; module EC2;
33
33
  puts "No images" if images.empty?
34
34
  end
35
35
 
36
- def prepare_images_valid?
37
- true
38
- end
39
- def prepare_images
40
- opts = {}
41
- opts[:group] = @option.group if @option.group
42
- opts[:group] = :any if @option.all
43
- opts[:id] = @option.instid if @option.instid
44
-
45
- puts "This will do the following:"
46
- puts "- Clear bash history"
47
- # NOTE: We can't delete the host keys here. Otherwise we can't create the image.
48
- #puts "- Delete host SSH keys (this is permanent!)"
49
- puts ""
50
-
51
- # Options to be sent to Net::SSH
52
- ssh_opts = { :user => @global.user || Rudy.sysinfo.user, :debug => STDERR }
53
- if @@global.pkey
54
- raise "Cannot find file #{@@global.pkey}" unless File.exists?(@@global.pkey)
55
- raise InsecureKeyPermissions, @@global.pkey unless File.stat(@@global.pkey).mode == 33152
56
- ssh_opts[:keys] = @@global.pkey
57
- end
58
-
59
- execute_check(:medium)
60
-
61
- rudy = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
62
- lt = rudy.list_group(opts[:group], :running, opts[:id]) do |inst|
63
-
64
- puts "Preparing #{inst.dns_public}..."
65
-
66
- # Open the connection and run the command
67
- rbox = Rye::Box.new(inst.dns_public, ssh_opts)
68
- rbox.safe = false
69
- # We need to explicitly add the rm command for rbox so we
70
- # can delete the SSH host keys. This is will force the instance
71
- # to re-create it's SSH keys on first boot.
72
- def rbox.rm(*args); cmd('rm', args); end
73
- p ret = rbox.history(:c)
74
- p ret.exit_code
75
- p ret.stderr
76
- p ret.stdout
77
-
78
- end
79
-
80
- puts "done"
81
- end
36
+ ##def prepare_images_valid?
37
+ ## true
38
+ ##end
39
+ ##def prepare_images
40
+ ## opts = {}
41
+ ## opts[:id] = @option.instid if @option.instid
42
+ ##
43
+ ## puts "This will do the following:"
44
+ ## puts "- Clear bash history"
45
+ ## # NOTE: We can't delete the host keys here. Otherwise we can't create the image.
46
+ ## #puts "- Delete host SSH keys (this is permanent!)"
47
+ ## puts ""
48
+ ##
49
+ ## ## TODO:
50
+ ## ## ~/.rudy, /etc/motd, history -c, /etc/hosts, /var/log/rudy*
51
+ ##
52
+ ## execute_check(:medium)
53
+ ##
54
+ ##
55
+ ## # Options to be sent to Net::SSH
56
+ ## ssh_opts = { :user => @global.user || Rudy.sysinfo.user, :debug => STDERR }
57
+ ## if @@global.pkey
58
+ ## raise "Cannot find file #{@@global.pkey}" unless File.exists?(@@global.pkey)
59
+ ## raise InsecureKeyPermissions, @@global.pkey unless File.stat(@@global.pkey).mode == 33152
60
+ ## ssh_opts[:keys] = @@global.pkey
61
+ ## end
62
+ ##
63
+ ##
64
+ ## rudy = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
65
+ ## lt = rudy.list_group(nil, :running, opts[:id]) do |inst|
66
+ ##
67
+ ## puts "Preparing #{inst.dns_public}..."
68
+ ##
69
+ ## # Open the connection and run the command
70
+ ## rbox = Rye::Box.new(inst.dns_public, ssh_opts)
71
+ ##
72
+ ## # We need to explicitly add the rm command for rbox so we
73
+ ## # can delete the SSH host keys. This is will force the instance
74
+ ## # to re-create it's SSH keys on first boot.
75
+ ## def rbox.rm(*args); cmd('rm', args); end
76
+ ## p ret = rbox.history(:c)
77
+ ## p ret.exit_code
78
+ ## p ret.stderr
79
+ ## p ret.stdout
80
+ ##
81
+ ## end
82
+ ##
83
+ ## puts "done"
84
+ ##end
82
85
 
83
86
  def create_images_valid?
84
87
  raise "No account number" unless @@global.accountnum
85
88
  raise "No Amazon cert-***.pem" unless @@global.cert
86
89
  raise "No Amazon pk-***.pem" unless @@global.privatekey
90
+ raise "You must supply a root keypair path" unless @@global.pkey
91
+
92
+ @rinst = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
93
+ @rimages = Rudy::AWS::EC2::Images.new(@@global.accesskey, @@global.secretkey, @@global.region)
94
+ @s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region)
95
+ raise "No instances" unless @rinst.any?
96
+ raise "You must supply an S3 bucket name. See: 'rudy-s3 buckets'" unless @option.bucket
97
+ raise "You must supply an image name" unless @option.name
98
+ raise "The bucket '#{@option.bucket}' does not exist" unless @s3.bucket_exists?(@option.bucket)
87
99
  true
88
100
  end
89
101
 
90
102
  def create_images
91
103
  opts = {}
92
- opts[:group] = @option.group if @option.group
93
- opts[:group] = :any if @option.all
94
104
  opts[:id] = @option.instid if @option.instid
95
105
 
96
- puts "You may want to run rudy-ec2 #{@alias} --prepare before this.".bright
97
- puts "This feature is experimental. Make sure you enter the bucket"
98
- puts "and image names correctly because if they're wrong the image"
99
- puts "won't get created and you'll be annoyed that you waited."
106
+ @@global.user = 'root'
100
107
 
108
+ puts "You may want to run rudy-ec2 #{@alias} --prepare first".bright
109
+ puts "NOTE 1: This process is currently Linux-only"
110
+ puts "NOTE 2: If you plan to create a public machine image, there are "
111
+ puts "additional steps to take to remove any sensitive information"
112
+ puts "before creating the image. See:"
113
+ puts "http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/AESDG-chapter-sharingamis.html"
114
+ exit unless Annoy.pose_question(" Continue?\a ", /yes|y|ya|sure|you bet!/i, STDERR)
115
+
101
116
  # Options to be sent to Net::SSH
102
- ssh_opts = { :user => @global.user || Rudy.sysinfo.user, :debug => STDERR }
117
+ ssh_opts = { :user => @@global.user || Rudy.sysinfo.user, :debug => nil }
103
118
  if @@global.pkey
104
119
  raise "Cannot find file #{@@global.pkey}" unless File.exists?(@@global.pkey)
105
120
  raise InsecureKeyPermissions, @@global.pkey unless File.stat(@@global.pkey).mode == 33152
106
121
  ssh_opts[:keys] = @@global.pkey
107
122
  end
108
123
 
109
- unless @option.name
110
- print "Enter the image name: "
111
- @option.image_name = gets.chomp
112
- end
113
-
114
- unless @option.bucket
115
- print "Enter the S3 bucket that will store the image: "
116
- @option.bucket_name = gets.chomp
117
- end
118
-
119
- execute_check(:medium)
120
-
121
- rudy = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
122
- lt = rudy.list_group(opts[:group], :running, opts[:id]) do |inst|
124
+ lt = @rinst.list_group(nil, :running, opts[:id]) do |inst|
123
125
 
124
- puts inst.dns_public
126
+ puts inst.to_s
125
127
 
126
128
  # Open the connection and run the command
127
129
  rbox = Rye::Box.new(inst.dns_public, ssh_opts)
128
-
129
- # TODO: Replace with rbox.upload
130
-
131
- # ~/.rudy, /etc/motd, history -c, /etc/hosts, /var/log/rudy*
132
- cert = File.read(@@global.cert)
133
- pk = File.read(@@global.privatekey)
134
- rbox.safe = false
135
- rbox.echo("'#{cert}' > /mnt/cert-temporary.pem")
136
- rbox.echo("'#{pk}' > /mnt/pk-temporary.pem")
137
- rbox.safe = true
130
+ def rbox.bundle_vol(*args); cmd('ec2-bundle-vol', args); end
131
+ def rbox.upload_vol(*args); cmd('ec2-upload-bundle', args); end
132
+
133
+ rbox.upload(@@global.cert, @@global.privatekey, "/mnt")
138
134
  rbox.touch("/root/firstrun")
139
135
 
140
- # TODO:
141
- # We have to delete the host keys just before we run the bundle command.
142
- # The problem is that if we lose the connection we won't be able to connect
143
- # to the instance again. A better solution is to ass the keys to the ignore
144
- # list for the bundle command.
136
+ ## TODO:
137
+ ## We have to delete the host keys just before we run the bundle command.
138
+ ## The problem is that if we lose the connection we won't be able to connect
139
+ ## to the instance again. A better solution is to add the keys to the ignore
140
+ ## list for the bundle command.
141
+ ##ret = rbox.rm('/etc/ssh/ssh_host_*_key*')
142
+
143
+ puts "Starting bundling process..."
144
+
145
+ pkeyfile = File.basename(@@global.privatekey)
146
+ certfile = File.basename(@@global.cert)
145
147
 
146
- #ret = rbox.rm('/etc/ssh/ssh_host_*_key*')
147
- #puts "Starting bundling process...".bright
148
- #puts ssh_command(machine[:dns_name], keypairpath, @global.user, "ec2-bundle-vol -r i386 -p #{@option.image_name} -k /mnt/pk-*pem -c /mnt/cert*pem -u #{@option.account}", @option.print)
149
- #puts ssh_command(machine[:dns_name], keypairpath, @global.user, "ec2-upload-bundle -b #{@option.bucket_name} -m /tmp/#{@option.image_name}.manifest.xml -a #{@global.accesskey} -s #{@global.secretkey}", @option.print)
150
- #
151
- #@ec2.images.register("#{@option.bucket_name}/#{@option.image_name}.manifest.xml") unless @option.print
148
+ rbox.bundle_vol(:r, "i386", :p, @option.name, :k, "/mnt/#{pkeyfile}", :c, "/mnt/#{certfile}", :u, @@global.accountnum)
149
+ rbox.upload_vol(:b, @option.bucket, :m, "/tmp/#{@option.name}.manifest.xml", :a, @@global.accesskey, :s, @@global.secretkey)
150
+
151
+ @rimages.register("#{@option.bucket}/#{@option.name}.manifest.xml")
152
152
 
153
153
  break
154
154
  end
155
155
 
156
156
  end
157
157
 
158
- #def create_images_valid?
159
- # puts "Make sure the machine is clean. I don't want archive no crud!"
160
- # switch_user("root")
161
- #
162
- # raise "No EC2 .pem keys provided" unless has_pem_keys?
163
- # raise "No SSH key provided for #{@global.user}!" unless has_keypair?
164
- # raise "No SSH key provided for root!" unless has_keypair?(:root)
165
- # true
166
- #end
167
- #
168
- #
169
- #def prepare_images
170
- # # TODO: Avail hooks for clean an instance
171
- # # Clean off Rudy specific crap.
172
- #end
173
- #
174
- #
175
-
176
- #
177
- #def deregister
178
- # ami = @argv.first
179
- # raise "You must supply an AMI ID (ami-XXXXXXX)" unless ami
180
- # puts "Deregistering AMI: #{ami}"
181
- #
182
- # exit unless Annoy.are_you_sure?
183
- #
184
- # if @ec2.images.deregister(ami)
185
- # puts "Done!"
186
- # else
187
- # puts "There was an unknown problem!"
188
- # end
189
- #
190
- #end
158
+ def deregister_valid?
159
+ unless @argv.ami && Rudy::Utils.is_id?(:image, @argv.ami)
160
+ raise "You must supply an AMI ID (ami-XXXXXXX)"
161
+ end
162
+ end
163
+ def deregister
164
+ puts "Deregistering #{@argv.ami}"
165
+
166
+ execute_check(:medium)
167
+
168
+ rimages = Rudy::AWS::EC2::Images.new(@@global.accesskey, @@global.secretkey, @@global.region)
169
+
170
+ if rimages.deregister(ami)
171
+ puts "Done!"
172
+ else
173
+ puts "There was an unknown problem!"
174
+ end
175
+
176
+ end
177
+
191
178
 
192
179
  end
193
180
 
@@ -26,9 +26,8 @@ module AWS; module S3;
26
26
  true
27
27
  end
28
28
  def create_buckets
29
- execute_check(:low)
30
29
  s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region)
31
- s3.create_bucket(@argv.name)
30
+ s3.create_bucket(@argv.name, @option.location)
32
31
  buckets
33
32
  end
34
33
 
@@ -63,6 +63,19 @@ module Rudy
63
63
  end
64
64
 
65
65
  end
66
+
67
+ def print_global
68
+ # NOTE: This method cannot be called just "global" b/c that conflicts
69
+ # with the global accessor for Drydock::Command classes.
70
+ if @@global.nil?
71
+ raise Rudy::NoGlobal
72
+ end
73
+ gtmp = @@global.clone
74
+ gtmp.format = "yaml" if gtmp.format == :s || gtmp.format == :string
75
+ gtmp.accesskey = gtmp.secretkey = "[not displayed]"
76
+ puts gtmp.dump(gtmp.format)
77
+ end
78
+
66
79
  end
67
80
  end
68
81
  end
@@ -7,8 +7,31 @@ module Rudy
7
7
 
8
8
  def disks
9
9
  rdisk = Rudy::Disks.new
10
- rdisk.list do |d|
10
+ rback = Rudy::Backups.new
11
+ more, less = [], []
12
+ less = [:environment, :role] if @option.all
13
+ # We first get the disk metadata
14
+ disk_list = rdisk.list(more, less) || []
15
+ # If there are no disks currently, there could be backups
16
+ # so we grab those to create a list of disks.
17
+ if @option.backups
18
+ backups = rback.list(more, less) || []
19
+ backups.each_with_index do |b, index|
20
+ disk_list << b.disk
21
+ end
22
+ end
23
+ # We go through the list of disks but we'll skip ones we've seen
24
+ seen = []
25
+ disk_list.each do |d|
26
+ next if seen.member?(d.name)
27
+ seen << d.name
11
28
  puts @@global.verbose > 0 ? d.inspect : d.dump(@@global.format)
29
+ if @option.backups
30
+ d.list_backups.each_with_index do |b, index|
31
+ puts ' %s' % b.name
32
+ break if @option.all.nil? && index >= 2 # display only 3, unless all
33
+ end
34
+ end
12
35
  end
13
36
  end
14
37
 
@@ -9,25 +9,24 @@ module Rudy; module CLI;
9
9
  true
10
10
  end
11
11
  def startup
12
- machines = @rr.execute
13
- puts $/, "The following machines are now available:"
12
+ machines = @rr.execute || []
13
+ puts $/, "The following machines are now available:" unless machines.empty?
14
14
  machines.each do |machine|
15
15
  puts machine.to_s
16
16
  end
17
17
  end
18
18
 
19
- def restart_valid?
20
- @rr = Rudy::Routines::Restart.new
19
+ def reboot_valid?
20
+ @rr = Rudy::Routines::Reboot.new
21
21
  @rr.raise_early_exceptions
22
22
  true
23
23
  end
24
- def restart
25
- #machines = @rr.execute
26
- #puts $/, "The following machines have been restarted:"
27
- #machines.each do |machine|
28
- # puts machine.to_s
29
- #end
30
- #puts "Restart is disabled"
24
+ def reboot
25
+ machines = @rr.execute
26
+ puts $/, "The following machines have been restarted:"
27
+ machines.each do |machine|
28
+ puts machine.to_s
29
+ end
31
30
  end
32
31
 
33
32
  def release_valid?