solutious-rudy 0.8.5 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. data/CHANGES.txt +55 -14
  2. data/README.rdoc +26 -34
  3. data/Rudyfile +27 -32
  4. data/bin/rudy +47 -27
  5. data/bin/rudy-ec2 +2 -16
  6. data/bin/rudy-s3 +0 -10
  7. data/bin/rudy-sdb +11 -12
  8. data/lib/rudy.rb +49 -89
  9. data/lib/rudy/aws.rb +2 -43
  10. data/lib/rudy/aws/ec2.rb +57 -20
  11. data/lib/rudy/aws/ec2/address.rb +10 -11
  12. data/lib/rudy/aws/ec2/group.rb +10 -9
  13. data/lib/rudy/aws/ec2/image.rb +8 -8
  14. data/lib/rudy/aws/ec2/instance.rb +15 -16
  15. data/lib/rudy/aws/ec2/keypair.rb +14 -19
  16. data/lib/rudy/aws/ec2/snapshot.rb +16 -9
  17. data/lib/rudy/aws/ec2/volume.rb +37 -24
  18. data/lib/rudy/aws/ec2/zone.rb +5 -4
  19. data/lib/rudy/aws/s3.rb +2 -1
  20. data/lib/rudy/aws/sdb.rb +35 -86
  21. data/lib/rudy/backups.rb +24 -0
  22. data/lib/rudy/cli.rb +5 -131
  23. data/lib/rudy/cli/aws/ec2/addresses.rb +19 -27
  24. data/lib/rudy/cli/aws/ec2/candy.rb +32 -7
  25. data/lib/rudy/cli/aws/ec2/groups.rb +9 -13
  26. data/lib/rudy/cli/aws/ec2/images.rb +5 -133
  27. data/lib/rudy/cli/aws/ec2/instances.rb +25 -25
  28. data/lib/rudy/cli/aws/ec2/keypairs.rb +7 -11
  29. data/lib/rudy/cli/aws/ec2/snapshots.rb +5 -9
  30. data/lib/rudy/cli/aws/ec2/volumes.rb +22 -23
  31. data/lib/rudy/cli/aws/ec2/zones.rb +2 -3
  32. data/lib/rudy/cli/aws/sdb/domains.rb +5 -6
  33. data/lib/rudy/cli/aws/sdb/objects.rb +33 -0
  34. data/lib/rudy/cli/aws/sdb/select.rb +23 -0
  35. data/lib/rudy/cli/backups.rb +38 -0
  36. data/lib/rudy/cli/base.rb +98 -0
  37. data/lib/rudy/cli/candy.rb +1 -2
  38. data/lib/rudy/cli/config.rb +7 -4
  39. data/lib/rudy/cli/disks.rb +6 -8
  40. data/lib/rudy/cli/execbase.rb +53 -0
  41. data/lib/rudy/cli/machines.rb +14 -18
  42. data/lib/rudy/cli/metadata.rb +24 -10
  43. data/lib/rudy/cli/routines.rb +31 -5
  44. data/lib/rudy/config.rb +17 -22
  45. data/lib/rudy/config/objects.rb +44 -30
  46. data/lib/rudy/disks.rb +25 -0
  47. data/lib/rudy/exceptions.rb +95 -0
  48. data/lib/rudy/global.rb +46 -23
  49. data/lib/rudy/guidelines.rb +3 -2
  50. data/lib/rudy/huxtable.rb +66 -57
  51. data/lib/rudy/machines.rb +41 -263
  52. data/lib/rudy/metadata.rb +212 -38
  53. data/lib/rudy/metadata/backup.rb +123 -78
  54. data/lib/rudy/metadata/disk.rb +152 -170
  55. data/lib/rudy/metadata/machine.rb +179 -0
  56. data/lib/rudy/mixins.rb +2 -1
  57. data/lib/rudy/mixins/hash.rb +3 -1
  58. data/lib/rudy/mixins/symbol.rb +8 -0
  59. data/lib/rudy/routines.rb +127 -344
  60. data/lib/rudy/routines/base.rb +226 -0
  61. data/lib/rudy/routines/handlers/base.rb +48 -0
  62. data/lib/rudy/routines/handlers/depends.rb +49 -0
  63. data/lib/rudy/routines/handlers/disks.rb +239 -0
  64. data/lib/rudy/routines/handlers/group.rb +42 -0
  65. data/lib/rudy/routines/handlers/host.rb +72 -0
  66. data/lib/rudy/routines/handlers/keypair.rb +70 -0
  67. data/lib/rudy/routines/handlers/machines.rb +15 -0
  68. data/lib/rudy/routines/handlers/script.rb +85 -0
  69. data/lib/rudy/routines/handlers/user.rb +41 -0
  70. data/lib/rudy/routines/passthrough.rb +19 -23
  71. data/lib/rudy/routines/reboot.rb +82 -51
  72. data/lib/rudy/routines/shutdown.rb +61 -14
  73. data/lib/rudy/routines/startup.rb +111 -17
  74. data/lib/rudy/utils.rb +12 -59
  75. data/rudy.gemspec +85 -25
  76. data/tryouts/01_mixins/01_hash_tryouts.rb +20 -0
  77. data/tryouts/10_require_time/10_rudy_tryouts.rb +33 -0
  78. data/tryouts/10_require_time/15_global_tryouts.rb +58 -0
  79. data/tryouts/12_config/10_load_config_tryouts.rb +43 -0
  80. data/tryouts/12_config/20_defaults_tryouts.rb +16 -0
  81. data/tryouts/12_config/30_accounts_tryouts.rb +17 -0
  82. data/tryouts/12_config/40_machines_tryouts.rb +53 -0
  83. data/tryouts/12_config/50_commands_tryouts.rb +17 -0
  84. data/tryouts/12_config/60_routines_tryouts.rb +16 -0
  85. data/tryouts/15_huxtable/10_huxtable_tryouts.rb +47 -0
  86. data/tryouts/15_huxtable/20_user_tryouts.rb +47 -0
  87. data/tryouts/20_simpledb/10_domains_tryouts.rb +36 -0
  88. data/tryouts/20_simpledb/20_objects_tryouts.rb +56 -0
  89. data/tryouts/25_ec2/10_keypairs_tryouts.rb +54 -0
  90. data/tryouts/25_ec2/20_groups_tryouts.rb +56 -0
  91. data/tryouts/25_ec2/21_groups_authorize_address_tryouts.rb +53 -0
  92. data/tryouts/25_ec2/22_groups_authorize_account_tryouts.rb +54 -0
  93. data/tryouts/25_ec2/30_addresses_tryouts.rb +42 -0
  94. data/tryouts/25_ec2/40_volumes_tryouts.rb +53 -0
  95. data/tryouts/25_ec2/50_snapshots_tryouts.rb +75 -0
  96. data/tryouts/26_ec2_instances/10_instance_tryouts.rb +107 -0
  97. data/tryouts/26_ec2_instances/50_images_tryouts.rb +7 -0
  98. data/tryouts/30_metadata/10_include_tryouts.rb +45 -0
  99. data/tryouts/30_metadata/13_object_tryouts.rb +19 -0
  100. data/tryouts/30_metadata/50_disk_tryouts.rb +115 -0
  101. data/tryouts/30_metadata/51_disk_digest_tryouts.rb +24 -0
  102. data/tryouts/30_metadata/53_disk_list_tryouts.rb +35 -0
  103. data/tryouts/30_metadata/56_disk_volume_tryouts.rb +68 -0
  104. data/tryouts/30_metadata/60_backup_tryouts.rb +101 -0
  105. data/tryouts/30_metadata/63_backup_list_tryouts.rb +38 -0
  106. data/tryouts/30_metadata/64_backup_disk_tryouts.rb +65 -0
  107. data/tryouts/30_metadata/66_backup_snapshot_tryouts.rb +76 -0
  108. data/tryouts/30_metadata/70_machine_tryouts.rb +85 -0
  109. data/tryouts/30_metadata/73_machine_list_tryouts.rb +58 -0
  110. data/tryouts/30_metadata/76_machine_instance_tryouts.rb +64 -0
  111. data/tryouts/30_metadata/77_machines_tryouts.rb +45 -0
  112. data/tryouts/40_routines/10_keypair_handler_tryouts.rb +52 -0
  113. data/tryouts/40_routines/11_group_handler_tryouts.rb +36 -0
  114. data/tryouts/80_cli/10_rudyec2_tryouts.rb +8 -0
  115. data/tryouts/80_cli/60_rudy_tryouts.rb +41 -0
  116. data/tryouts/failer +6 -0
  117. data/tryouts/misc/console_tryout.rb +91 -0
  118. data/tryouts/misc/disks_tryout.rb +48 -0
  119. data/tryouts/misc/drydock_tryout.rb +48 -0
  120. data/tryouts/misc/nested_methods.rb +103 -0
  121. data/tryouts/misc/session_tryout.rb +46 -0
  122. data/tryouts/misc/tryouts.rb +33 -0
  123. data/tryouts/misc/usage_tryout.rb +23 -0
  124. metadata +119 -31
  125. data/bin/ird +0 -153
  126. data/lib/rudy/metadata/backups.rb +0 -67
  127. data/lib/rudy/metadata/debug.rb +0 -38
  128. data/lib/rudy/metadata/disks.rb +0 -67
  129. data/lib/rudy/metadata/objectbase.rb +0 -108
  130. data/lib/rudy/routines/helper.rb +0 -76
  131. data/lib/rudy/routines/helpers/dependshelper.rb +0 -34
  132. data/lib/rudy/routines/helpers/diskhelper.rb +0 -403
  133. data/lib/rudy/routines/helpers/scripthelper.rb +0 -197
  134. data/lib/rudy/routines/helpers/userhelper.rb +0 -37
  135. data/support/rudy-ec2-startup +0 -200
@@ -3,15 +3,14 @@
3
3
  module Rudy; module CLI;
4
4
  module AWS; module EC2;
5
5
 
6
- class KeyPairs < Rudy::CLI::CommandBase
6
+ class EC2::Keypairs < Rudy::CLI::CommandBase
7
7
 
8
8
  def create_keypairs_valid?
9
9
  raise Drydock::ArgError.new('name', @alias) unless @argv.name
10
10
  true
11
11
  end
12
12
  def create_keypairs
13
- rkey = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
14
- kp = execute_action { rkey.create(@argv.name) }
13
+ kp = execute_action { Rudy::AWS::EC2::Keypairs.create(@argv.name) }
15
14
  if [:s, :string].member?(@@global.format)
16
15
  puts "Name: #{kp.name}"
17
16
  puts "Fingerprint: #{kp.fingerprint}", $/
@@ -28,21 +27,18 @@ module AWS; module EC2;
28
27
  true
29
28
  end
30
29
  def destroy_keypairs
31
- rkey = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
32
- raise "KeyPair #{@argv.name} does not exist" unless rkey.exists?(@argv.name)
33
- kp = rkey.get(@argv.name)
30
+ raise "Keypair #{@argv.name} does not exist" unless Rudy::AWS::EC2::Keypairs.exists?(@argv.name)
31
+ kp = Rudy::AWS::EC2::Keypairs.get(@argv.name)
34
32
  puts "Destroying: #{kp.name}"
35
33
  execute_check(:medium)
36
- execute_action { rkey.destroy(kp.name) }
37
- keypairs
34
+ execute_action { Rudy::AWS::EC2::Keypairs.destroy(kp.name) }
38
35
  end
39
36
 
40
37
  def keypairs
41
- rkey = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
42
- (rkey.list || []).each do |kp|
38
+ (Rudy::AWS::EC2::Keypairs.list || []).each do |kp|
43
39
  puts @@global.verbose > 0 ? kp.inspect : kp.dump(@@global.format)
44
40
  end
45
- puts "No keypairs" unless rkey.any?
41
+ puts "No keypairs" unless Rudy::AWS::EC2::Keypairs.any?
46
42
  end
47
43
 
48
44
 
@@ -7,34 +7,30 @@ module AWS; module EC2;
7
7
 
8
8
  def create_snapshots_valid?
9
9
  raise Drydock::ArgError.new('volume ID', @alias) unless @option.volume
10
- @rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
11
- @volume = @rvol.get(@argv.volid)
10
+ @volume = Rudy::AWS::EC2::Volumes.get(@argv.volid)
12
11
  raise "Volume #{@volume.awsid} does not exist" unless @volume
13
12
  true
14
13
  end
15
14
  def create_snapshots
16
- rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
17
- snap = execute_action { rsnap.create(@volume.awsid) }
15
+ snap = execute_action { Rudy::AWS::EC2::Snapshots.create(@volume.awsid) }
18
16
  puts @@global.verbose > 0 ? snap.inspect : snap.dump(@@global.format)
19
17
  end
20
18
 
21
19
  def destroy_snapshots_valid?
22
20
  raise Drydock::ArgError.new('snapshot ID', @alias) unless @argv.snapid
23
- @rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
24
- @snap = @rsnap.get(@argv.snapid)
21
+ @snap = Rudy::AWS::EC2::Snapshots.get(@argv.snapid)
25
22
  raise "Snapshot #{@snap.awsid} does not exist" unless @snap
26
23
  true
27
24
  end
28
25
  def destroy_snapshots
29
26
  puts "Destroying: #{@snap.awsid}"
30
27
  execute_check(:medium)
31
- execute_action { @rsnap.destroy(@snap.awsid) }
28
+ execute_action { Rudy::AWS::EC2::Snapshots.destroy(@snap.awsid) }
32
29
  snapshots
33
30
  end
34
31
 
35
32
  def snapshots
36
- rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
37
- snaps = rsnap.list || []
33
+ snaps = Rudy::AWS::EC2::Snapshots.list || []
38
34
  snaps.each do |snap|
39
35
  puts @@global.verbose > 0 ? snap.inspect : snap.dump(@@global.format)
40
36
  end
@@ -13,23 +13,27 @@ module AWS; module EC2;
13
13
  end
14
14
  def volumes_create
15
15
  puts "Creating #{@option.size}GB volume in #{@@global.zone}"
16
- rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
17
16
  execute_check(:low)
18
17
  vol = execute_action("Create Failed") {
19
- rvol.create(@option.size, @@global.zone, @option.snapshot)
18
+ Rudy::AWS::EC2::Volumes.create(@option.size, @@global.zone, @option.snapshot)
20
19
  }
21
20
  puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
22
21
  end
23
22
 
24
23
 
25
24
  def destroy_volumes_valid?
26
- raise "You must supply a volume ID. See rudy volume -h" unless @argv.volid
25
+ raise "You must supply a volume ID. See rudy volume -h" unless @argv.volid
26
+
27
+ unless Rudy::AWS::EC2::Volumes.exists? @argv.volid
28
+ raise Rudy::AWS::EC2::UnknownVolume, @argv.volid
29
+ end
27
30
  true
28
31
  end
29
32
 
30
33
  def destroy_volumes
31
- @rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
32
- @volume = @rvol.get(@argv.volid)
34
+
35
+ @volume = Rudy::AWS::EC2::Volumes.get(@argv.volid)
36
+
33
37
  raise "Volume #{@volume.awsid} does not exist" unless @volume
34
38
  raise "Volume #{@volume.awsid} is still in-use" if @volume.in_use?
35
39
  raise "Volume #{@volume.awsid} is still attached" if @volume.attached?
@@ -37,9 +41,10 @@ module AWS; module EC2;
37
41
 
38
42
  puts "Destroying #{@volume.awsid}"
39
43
  execute_check(:medium)
40
- execute_action("Destroy Failed") { @rvol.destroy(@volume.awsid) }
44
+ execute_action("Destroy Failed") { Rudy::AWS::EC2::Volumes.destroy(@volume.awsid) }
41
45
 
42
- vol = @rvol.get(@volume.awsid)
46
+ vol = Rudy::AWS::EC2::Volumes.get(@volume.awsid)
47
+
43
48
  puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
44
49
  end
45
50
 
@@ -51,20 +56,17 @@ module AWS; module EC2;
51
56
  end
52
57
  def volumes_attach
53
58
  @option.device ||= "/dev/sdh"
54
-
55
- rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
56
- rinst = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
57
- raise "Volume #{@argv.volid} does not exist" unless rvol.exists?(@argv.volid)
58
- raise "Volume #{@argv.volid} is already attached" if rvol.attached?(@argv.volid)
59
- raise "Instance #{@option.instance} does not exist" unless rinst.exists?(@option.instance)
59
+ raise "Volume #{@argv.volid} does not exist" unless Rudy::AWS::EC2::Volumes.exists?(@argv.volid)
60
+ raise "Volume #{@argv.volid} is already attached" if Rudy::AWS::EC2::Volumes.attached?(@argv.volid)
61
+ raise "Instance #{@option.instance} does not exist" unless Rudy::AWS::EC2::Instances.exists?(@option.instance)
60
62
 
61
63
  puts "Attaching #{@argv.volid} to #{@option.instance} on #{@option.device}"
62
64
  execute_check(:low)
63
65
  execute_action("Attach Failed") {
64
- rvol.attach(@argv.volid, @option.instance, @option.device)
66
+ Rudy::AWS::EC2::Volumes.attach(@argv.volid, @option.instance, @option.device)
65
67
  }
66
68
 
67
- vol = rvol.get(@argv.volid)
69
+ vol = Rudy::AWS::EC2::Volumes.get(@argv.volid)
68
70
  puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
69
71
  end
70
72
 
@@ -74,24 +76,21 @@ module AWS; module EC2;
74
76
  end
75
77
 
76
78
  def volumes_detach
77
- rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
78
- raise "Volume #{@argv.volid} does not exist" unless rvol.exists?(@argv.volid)
79
-
80
- vol = rvol.get(@argv.volid)
79
+ raise "Volume #{@argv.volid} does not exist" unless Rudy::AWS::EC2::Volumes.exists?(@argv.volid)
80
+ vol = Rudy::AWS::EC2::Volumes.get(@argv.volid)
81
81
  raise "Volume #{vol.awsid} is not attached" unless vol.attached?
82
82
 
83
83
  puts "Detaching #{vol.awsid} from #{vol.instid}"
84
84
  execute_check(:medium)
85
- execute_action("Detach Failed") { rvol.detach(vol.awsid) }
85
+ execute_action("Detach Failed") { Rudy::AWS::EC2::Volumes.detach(vol.awsid) }
86
86
 
87
- vol = rvol.get(vol.awsid)
87
+ vol = Rudy::AWS::EC2::Volumes.get(vol.awsid)
88
88
  puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
89
89
  end
90
90
 
91
91
 
92
92
  def volumes
93
- rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
94
- volumes = rvol.list || []
93
+ volumes = Rudy::AWS::EC2::Volumes.list || []
95
94
  volumes.each do |vol|
96
95
  puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
97
96
  end
@@ -7,11 +7,10 @@ module AWS; module EC2;
7
7
 
8
8
 
9
9
  def zones
10
- rzone = Rudy::AWS::EC2::Zones.new(@@global.accesskey, @@global.secretkey, @@global.region)
11
- rzone.list_as_hash(@argv.name).each_value do |zon|
10
+ Rudy::AWS::EC2::Zones.list_as_hash(@argv.name).each_value do |zon|
12
11
  puts zon.dump(@@global.format)
13
12
  end
14
- puts "No zones" unless rzone.any?
13
+ puts "No zones" unless Rudy::AWS::EC2::Zones.any?
15
14
  end
16
15
 
17
16
 
@@ -4,32 +4,31 @@ module Rudy; module CLI;
4
4
  module AWS; module SDB;
5
5
 
6
6
  class Domains < Rudy::CLI::CommandBase
7
-
8
-
7
+
9
8
  def domains
10
- sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
11
- domains = sdb.list_domains
9
+ @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
10
+ domains = @sdb.list_domains
12
11
  puts domains
13
12
  puts "No domains" if domains.nil? || domains.empty?
14
13
  end
15
14
 
16
15
  def domains_create_valid?
17
- @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
18
16
  raise "No name specified" unless @argv.name
19
17
  true
20
18
  end
21
19
  def domains_create
20
+ @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
22
21
  @sdb.create_domain @argv.name
23
22
  execute_check(:low)
24
23
  domains
25
24
  end
26
25
 
27
26
  def domains_destroy_valid?
28
- @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
29
27
  raise "No name specified" unless @argv.name
30
28
  true
31
29
  end
32
30
  def domains_destroy
31
+ @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
33
32
  execute_check(:medium)
34
33
  @sdb.destroy_domain @argv.name
35
34
  domains
@@ -0,0 +1,33 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module SDB;
5
+
6
+ class Objects < Rudy::CLI::CommandBase
7
+
8
+
9
+ def objects_valid?
10
+ raise "Must supply domain" if @argv.empty?
11
+ true
12
+ end
13
+ def objects
14
+ @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
15
+
16
+ if @argv.key.nil?
17
+ query = "select * from #{@argv.name}"
18
+ items = @sdb.select query
19
+ else
20
+ items = [@sdb.get( @argv.name, @argv.key)]
21
+ end
22
+
23
+ exit unless items
24
+
25
+ items.each do |i|
26
+ p i
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ end; end
33
+ end; end
@@ -0,0 +1,23 @@
1
+
2
+ module Rudy; module CLI;
3
+ module AWS; module SDB;
4
+
5
+ class Select < Rudy::CLI::CommandBase
6
+
7
+ def query_valid?
8
+ raise "No select query supplied" if @argv.empty?
9
+ true
10
+ end
11
+
12
+ def query
13
+ @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
14
+ results = @sdb.select @argv.query
15
+ return if results.nil?
16
+ results.each do |r|
17
+ p r
18
+ end
19
+ end
20
+ end
21
+
22
+ end; end
23
+ end; end
@@ -0,0 +1,38 @@
1
+
2
+
3
+ module Rudy
4
+ module CLI
5
+ class Backups < Rudy::CLI::CommandBase
6
+
7
+
8
+ def backups
9
+ more, less = {}, []
10
+ less = [:environment, :role] if @option.all
11
+ # We first get the disk metadata
12
+ b_list = Rudy::Backups.list(more, less) || []
13
+ b_list.each do |back|
14
+ puts @global.verbose > 0 ? "#{back.name}: #{back.inspect}" : back.name
15
+ end
16
+ end
17
+
18
+ def backups_wash
19
+ dirt = (Rudy::Backups.list || []).select { |b| !b.snapshot_exists? }
20
+ if dirt.empty?
21
+ puts "Nothing to wash in #{current_machine_group}"
22
+ return
23
+ end
24
+
25
+ puts "The following backup metadata will be deleted:"
26
+ puts dirt.collect {|b| b.name }
27
+
28
+ execute_check(:medium)
29
+
30
+ dirt.each do |b|
31
+ b.destroy(:force)
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,98 @@
1
+
2
+
3
+ module Rudy::CLI
4
+
5
+ class CommandBase < Drydock::Command
6
+ include Rudy::Huxtable
7
+
8
+ attr_reader :config
9
+
10
+ protected
11
+ def init
12
+
13
+ if Drydock.debug?
14
+ #Caesars.enable_debug
15
+ Rudy.enable_debug
16
+ end
17
+
18
+ # The CLI wants output!
19
+ Rudy::Huxtable.update_logger STDOUT
20
+
21
+ # Send The Huxtables the global values from the command-line
22
+ Rudy::Huxtable.update_global @global
23
+
24
+ # Reload configuration. This must come after update_global
25
+ # so it will catch the @@global.config path (if supplied).
26
+ begin
27
+ Rudy::Huxtable.update_config
28
+ rescue Caesars::SyntaxError => ex
29
+ STDERR.puts ex.message
30
+ STDERR.puts ex.backtrace if @@global.verbose > 0
31
+ exit 81
32
+ end
33
+
34
+ @@global.nocolor ? String.disable_color : String.enable_color
35
+ @@global.yes ? Annoy.enable_skip : Annoy.disable_skip
36
+
37
+ unless @@global.accesskey && @@global.secretkey
38
+ STDERR.puts "No AWS credentials. Check your configs!"
39
+ STDERR.puts "Try: rudy init"
40
+ exit 1
41
+ end
42
+
43
+ if @@global.environment =~ /^prod/ && Rudy.debug?
44
+ puts Rudy::Utils.banner("PRODUCTION ACCESS IS DISABLED IN DEBUG MODE")
45
+ exit 1
46
+ end
47
+
48
+ if @@global.verbose >= 4 # -vvvv
49
+ format = @@global.format == :json ? :json : :yaml
50
+ gcopy = @@global.dup
51
+ gcopy.secretkey = "[HIDDEN]"
52
+ puts "# GLOBALS: ", gcopy.dump(format)
53
+ end
54
+
55
+ Rudy::Metadata.connect @@global.accesskey, @@global.secretkey, @@global.region
56
+ Rudy::AWS::EC2.connect @@global.accesskey, @@global.secretkey, @@global.region
57
+ end
58
+
59
+ def execute_action(emsg="Failed", &action)
60
+ begin
61
+ ret = action.call
62
+ raise emsg unless ret
63
+ ret
64
+ rescue Rudy::AWS::EC2::NoAMI => ex
65
+ raise Drydock::OptError.new('-a', @alias)
66
+ end
67
+ end
68
+
69
+ def execute_check(level=:medium)
70
+ ret = Annoy.are_you_sure?(level)
71
+ exit 0 unless ret
72
+ ret
73
+ end
74
+
75
+ # Print a default header to the screen for every command.
76
+ #
77
+ def print_header
78
+
79
+ # Send The Huxtables the global values again because they could be
80
+ # updated after initialization but before the command was executed
81
+ Rudy::Huxtable.update_global @global
82
+
83
+ puts Rudy::CLI.generate_header(@@global, @@config) if @@global.print_header
84
+
85
+ unless @@global.quiet
86
+ if @@global.environment == "prod"
87
+ msg = "YOU ARE PLAYING WITH PRODUCTION"
88
+ puts Rudy::Utils.banner(msg, :normal), $/
89
+ end
90
+ end
91
+ end
92
+
93
+ def machine_separator(name, awsid)
94
+ ('%s %-50s awsid: %s ' % [$/, name, awsid]).att(:reverse)
95
+ end
96
+
97
+ end
98
+ end
@@ -4,8 +4,7 @@ module Rudy
4
4
  class Candy < Rudy::CLI::CommandBase
5
5
 
6
6
  def open
7
- rmach = Rudy::Machines.new
8
- machines = rmach.list
7
+ machines = Rudy::Machines.list
9
8
 
10
9
  if machines
11
10
  `open http://#{machines.first.dns_public}`
@@ -24,14 +24,17 @@ module Rudy
24
24
  # i.e. if [prod][app][ami] is not available, it will check [prod][ami]
25
25
  # and then [ami].
26
26
  #
27
- # # Display the value for a specific machine.
28
- # $ rudy -e prod -r db config param-name
29
- #
30
27
  # # Display all configuration
31
28
  # $ rudy config --all
32
29
  #
30
+ # # Display just machines
31
+ # $ rudy config --defaults
32
+ #
33
33
  def config
34
- # if Rudy.in_situ? # TODO: do something intelligent when running on EC2
34
+
35
+ # TODO: Re-enable:
36
+ # # Display the value for a specific machine.
37
+ # $ rudy -e prod -r db config param-name
35
38
 
36
39
  if @@config.nil? || @@config.empty?
37
40
  return if @@global.quiet