solutious-rudy 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/CHANGES.txt +19 -1
  2. data/README.rdoc +66 -35
  3. data/Rakefile +1 -0
  4. data/Rudyfile +97 -6
  5. data/bin/ird +7 -4
  6. data/bin/rudy +120 -212
  7. data/bin/rudy-ec2 +240 -0
  8. data/bin/rudy-s3 +76 -0
  9. data/bin/rudy-sdb +67 -0
  10. data/lib/annoy.rb +61 -18
  11. data/lib/console.rb +10 -5
  12. data/lib/rudy/aws/ec2/address.rb +76 -40
  13. data/lib/rudy/aws/ec2/group.rb +138 -78
  14. data/lib/rudy/aws/ec2/image.rb +134 -12
  15. data/lib/rudy/aws/ec2/instance.rb +116 -89
  16. data/lib/rudy/aws/ec2/keypair.rb +26 -14
  17. data/lib/rudy/aws/ec2/snapshot.rb +23 -12
  18. data/lib/rudy/aws/ec2/volume.rb +198 -202
  19. data/lib/rudy/aws/ec2/zone.rb +77 -0
  20. data/lib/rudy/aws/ec2.rb +56 -25
  21. data/lib/rudy/aws/s3.rb +54 -0
  22. data/lib/rudy/aws/sdb/error.rb +46 -0
  23. data/lib/rudy/aws/sdb.rb +298 -0
  24. data/lib/rudy/aws.rb +29 -57
  25. data/lib/rudy/{metadata/backup.rb → backup.rb} +8 -8
  26. data/lib/rudy/cli/aws/ec2/addresses.rb +105 -0
  27. data/lib/rudy/cli/aws/ec2/candy.rb +208 -0
  28. data/lib/rudy/cli/aws/ec2/groups.rb +121 -0
  29. data/lib/rudy/cli/aws/ec2/images.rb +196 -0
  30. data/lib/rudy/cli/aws/ec2/instances.rb +194 -0
  31. data/lib/rudy/cli/aws/ec2/keypairs.rb +53 -0
  32. data/lib/rudy/cli/aws/ec2/snapshots.rb +49 -0
  33. data/lib/rudy/cli/aws/ec2/volumes.rb +104 -0
  34. data/lib/rudy/cli/aws/ec2/zones.rb +22 -0
  35. data/lib/rudy/cli/aws/s3/buckets.rb +50 -0
  36. data/lib/rudy/cli/aws/s3/store.rb +22 -0
  37. data/lib/rudy/cli/aws/sdb/domains.rb +41 -0
  38. data/lib/rudy/cli/{deploy.rb → candy.rb} +2 -6
  39. data/lib/rudy/cli/config.rb +25 -20
  40. data/lib/rudy/cli/disks.rb +18 -108
  41. data/lib/rudy/cli/machines.rb +94 -0
  42. data/lib/rudy/cli/routines.rb +47 -70
  43. data/lib/rudy/cli.rb +104 -89
  44. data/lib/rudy/config/objects.rb +5 -43
  45. data/lib/rudy/config.rb +8 -24
  46. data/lib/rudy/disks.rb +248 -0
  47. data/lib/rudy/global.rb +121 -0
  48. data/lib/rudy/huxtable.rb +232 -147
  49. data/lib/rudy/machines.rb +245 -0
  50. data/lib/rudy/metadata.rb +136 -0
  51. data/lib/rudy/routines/helpers/diskhelper.rb +101 -0
  52. data/lib/rudy/routines/helpers/scripthelper.rb +91 -0
  53. data/lib/rudy/routines/release.rb +27 -8
  54. data/lib/rudy/routines/shutdown.rb +47 -32
  55. data/lib/rudy/routines/startup.rb +47 -37
  56. data/lib/rudy/routines.rb +30 -37
  57. data/lib/rudy/scm/svn.rb +1 -1
  58. data/lib/rudy/utils.rb +262 -4
  59. data/lib/rudy.rb +76 -248
  60. data/lib/storable.rb +19 -16
  61. data/lib/sysinfo.rb +1 -1
  62. data/rudy.gemspec +88 -68
  63. data/support/rudy-ec2-startup +5 -5
  64. data/test/05_config/00_setup_test.rb +3 -7
  65. data/test/20_sdb/00_setup_test.rb +2 -17
  66. data/test/20_sdb/10_domains_test.rb +18 -16
  67. data/test/25_ec2/00_setup_test.rb +5 -10
  68. data/test/25_ec2/10_keypairs_test.rb +13 -5
  69. data/test/25_ec2/20_groups_test.rb +48 -56
  70. data/test/25_ec2/30_addresses_test.rb +13 -10
  71. data/test/25_ec2/40_volumes_test.rb +11 -8
  72. data/test/25_ec2/50_snapshots_test.rb +17 -12
  73. data/test/26_ec2_instances/00_setup_test.rb +3 -8
  74. data/test/26_ec2_instances/10_instances_test.rb +21 -19
  75. data/test/30_sdb_metadata/00_setup_test.rb +2 -9
  76. data/test/30_sdb_metadata/10_disks_test.rb +47 -37
  77. data/test/30_sdb_metadata/20_backups_test.rb +9 -9
  78. data/test/helper.rb +5 -3
  79. data/vendor/highline-1.5.1/CHANGELOG +222 -0
  80. data/vendor/highline-1.5.1/INSTALL +35 -0
  81. data/vendor/highline-1.5.1/LICENSE +7 -0
  82. data/vendor/highline-1.5.1/README +63 -0
  83. data/vendor/highline-1.5.1/Rakefile +82 -0
  84. data/vendor/highline-1.5.1/TODO +6 -0
  85. data/vendor/highline-1.5.1/examples/ansi_colors.rb +38 -0
  86. data/vendor/highline-1.5.1/examples/asking_for_arrays.rb +18 -0
  87. data/vendor/highline-1.5.1/examples/basic_usage.rb +75 -0
  88. data/vendor/highline-1.5.1/examples/color_scheme.rb +32 -0
  89. data/vendor/highline-1.5.1/examples/limit.rb +12 -0
  90. data/vendor/highline-1.5.1/examples/menus.rb +65 -0
  91. data/vendor/highline-1.5.1/examples/overwrite.rb +19 -0
  92. data/vendor/highline-1.5.1/examples/page_and_wrap.rb +322 -0
  93. data/vendor/highline-1.5.1/examples/password.rb +7 -0
  94. data/vendor/highline-1.5.1/examples/trapping_eof.rb +22 -0
  95. data/vendor/highline-1.5.1/examples/using_readline.rb +17 -0
  96. data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +120 -0
  97. data/vendor/highline-1.5.1/lib/highline/compatibility.rb +17 -0
  98. data/vendor/highline-1.5.1/lib/highline/import.rb +43 -0
  99. data/vendor/highline-1.5.1/lib/highline/menu.rb +395 -0
  100. data/vendor/highline-1.5.1/lib/highline/question.rb +463 -0
  101. data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +193 -0
  102. data/vendor/highline-1.5.1/lib/highline.rb +758 -0
  103. data/vendor/highline-1.5.1/setup.rb +1360 -0
  104. data/vendor/highline-1.5.1/test/tc_color_scheme.rb +56 -0
  105. data/vendor/highline-1.5.1/test/tc_highline.rb +823 -0
  106. data/vendor/highline-1.5.1/test/tc_import.rb +54 -0
  107. data/vendor/highline-1.5.1/test/tc_menu.rb +429 -0
  108. data/vendor/highline-1.5.1/test/ts_all.rb +15 -0
  109. metadata +81 -69
  110. data/lib/aws_sdb/error.rb +0 -42
  111. data/lib/aws_sdb/service.rb +0 -215
  112. data/lib/aws_sdb.rb +0 -3
  113. data/lib/rudy/aws/simpledb.rb +0 -71
  114. data/lib/rudy/cli/addresses.rb +0 -85
  115. data/lib/rudy/cli/backups.rb +0 -175
  116. data/lib/rudy/cli/domains.rb +0 -17
  117. data/lib/rudy/cli/groups.rb +0 -77
  118. data/lib/rudy/cli/images.rb +0 -111
  119. data/lib/rudy/cli/instances.rb +0 -142
  120. data/lib/rudy/cli/keypairs.rb +0 -47
  121. data/lib/rudy/cli/manager.rb +0 -51
  122. data/lib/rudy/cli/release.rb +0 -174
  123. data/lib/rudy/cli/volumes.rb +0 -121
  124. data/lib/rudy/command/addresses.rb +0 -69
  125. data/lib/rudy/command/backups.rb +0 -65
  126. data/lib/rudy/command/disks-old.rb +0 -322
  127. data/lib/rudy/command/disks.rb +0 -9
  128. data/lib/rudy/command/domains.rb +0 -34
  129. data/lib/rudy/command/groups.rb +0 -118
  130. data/lib/rudy/command/instances.rb +0 -278
  131. data/lib/rudy/command/keypairs.rb +0 -149
  132. data/lib/rudy/command/manager.rb +0 -65
  133. data/lib/rudy/command/volumes.rb +0 -127
  134. data/lib/rudy/metadata/disk.rb +0 -149
  135. data/lib/rudy/metadata/machine.rb +0 -34
  136. data/lib/rudy/routines/disk_handler.rb +0 -190
  137. data/lib/rudy/routines/script_runner.rb +0 -65
  138. data/test/50_commands/00_setup_test.rb +0 -11
  139. data/test/50_commands/10_keypairs_test.rb +0 -79
  140. data/test/50_commands/20_groups_test.rb +0 -77
  141. data/test/50_commands/40_volumes_test.rb +0 -55
  142. data/test/50_commands/50_instances_test.rb +0 -110
  143. data/tryouts/console_tryout.rb +0 -91
  144. data/tryouts/disks.rb +0 -55
  145. data/tryouts/nested_methods.rb +0 -36
  146. data/tryouts/session_tryout.rb +0 -46
@@ -0,0 +1,194 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module EC2;
5
+ class InstanceAndGroupError < Drydock::ArgError
6
+ def message; "You cannot provide a group and an instance ID"; end
7
+ end
8
+ class NoInstanceError < Drydock::ArgError
9
+ def message; "You must provide a group or instance ID"; end
10
+ end
11
+
12
+ class Instances < Rudy::CLI::CommandBase
13
+
14
+ def instances_create_valid?
15
+
16
+ raise "Cannot supply an instance ID" if @option.instid
17
+
18
+ if @option.group
19
+ rgroup = Rudy::AWS::EC2::Groups.new(@@global.accesskey, @@global.secretkey, @@global.region)
20
+ raise "Group #{@option.group} does not exist" unless rgroup.exists?(@option.group)
21
+ end
22
+
23
+ true
24
+ end
25
+
26
+ def instances_create
27
+
28
+ opts = { # Defaults
29
+ :group => 'default',
30
+ :size => 'm1.small',
31
+ :zone => @@global.zone
32
+ }
33
+
34
+ radd = Rudy::AWS::EC2::Addresses.new(@@global.accesskey, @@global.secretkey, @@global.region)
35
+ rinst = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
36
+
37
+ if @option.address
38
+ raise "Cannot specify both -a and -n" if @option.newaddress
39
+ raise "#{@option.address} is not allocated to you" unless radd.exists?(@option.address)
40
+ raise "#{@option.address} is already associated!" if radd.associated?(@option.address)
41
+ end
42
+
43
+ # These can be sent directly to EC2 class
44
+ [:group, :ami, :size, :keypair, :private].each do |n|
45
+ opts[n] = @option.send(n) if @option.send(n)
46
+ end
47
+
48
+ puts "Creating #{opts[:size]} instance in #{@@global.zone}"
49
+
50
+ unless opts[:keypair]
51
+ puts "You did not specify a keypair. Unless you've prepared a user account".color(:blue)
52
+ puts "on this image (#{opts[:ami]}) you will not be able to log in to it.".color(:blue)
53
+ exit unless Annoy.proceed?(:low)
54
+ end
55
+
56
+ instances = rinst.list_group(opts[:group], :running)
57
+
58
+ if instances && instances.size > 0
59
+ instance_count = (instances.size == 1) ? 'is 1 instance' : "are #{instances.size} instances"
60
+ puts "There #{instance_count} running in the #{opts[:group]} group."
61
+ exit unless Annoy.proceed?(:low)
62
+ end
63
+
64
+ if @option.newaddress
65
+ print "Creating address... "
66
+ address = radd.create
67
+ puts "#{address.ipaddress}"
68
+ @option.address = address.ipaddress
69
+ end
70
+
71
+ execute_action do
72
+ first_instance = true
73
+ rinst.create(opts) do |inst| # Rudy::AWS::EC2::Instance objects
74
+
75
+ # Assign IP address to only the first instance
76
+ if first_instance && @option.address
77
+ puts "Associating #{@option.address} to #{inst.awsid}"
78
+ radd.associate(@option.address, inst.awsid)
79
+ first_instance = false
80
+ end
81
+
82
+ puts @@global.verbose > 0 ? inst.inspect : inst.dump(@@global.format)
83
+ end
84
+ end
85
+ end
86
+
87
+ def instances_restart_valid?
88
+ raise InstanceAndGroupError.new(nil, @alias) if @option.group && @argv.instid
89
+ raise NoInstanceError.new(nil, @alias) if !@option.group && !@argv.instid
90
+
91
+ if @option.group
92
+ rgroup = Rudy::AWS::EC2::Groups.new(@@global.accesskey, @@global.secretkey, @@global.region)
93
+ raise "Group #{@option.group} does not exist" unless rgroup.exists?(@option.group)
94
+ end
95
+
96
+ if @option.private
97
+ raise Drydock::OptsError.new(nil, @alias, "Cannot allocate public IP for private instance") if @option.address || @option.newadress
98
+ end
99
+
100
+ @rinst = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
101
+ raise "No instances" unless @rinst.any?
102
+ true
103
+ end
104
+ alias :instances_destroy_valid? :instances_restart_valid?
105
+
106
+ def instances_destroy
107
+ instances_action :destroy
108
+ end
109
+
110
+ def instances_restart
111
+ instances_action :restart
112
+ end
113
+
114
+ def consoles_valid?
115
+ @rinst = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
116
+ raise "No instances" unless @rinst.any?
117
+ true
118
+ end
119
+ def consoles
120
+ opts = {}
121
+ opts[:group] = @option.group if @option.group
122
+ opts[:id] = @argv.instid if @argv.instid
123
+ opts[:id] &&= [opts[:id]].flatten
124
+
125
+ lt = @rinst.list_group(opts[:group], :any, opts[:id]) do |inst|
126
+ puts '-'*50
127
+ puts "Console for: #{inst.liner_note}", $/
128
+ console = @rinst.console(inst.awsid)
129
+ output = console ? Base64.decode64(console) : "Unavailable"
130
+ puts output.noansi # Remove color and clear, etc...
131
+ end
132
+
133
+ end
134
+
135
+ def status
136
+ opts = {}
137
+
138
+ opts[:group] = @option.group if @option.group
139
+ opts[:state] = @option.state if @option.state
140
+
141
+ # A nil value forces the @ec2.instances.list to return all instances
142
+ if @option.all
143
+ opts[:state] = :any
144
+ opts[:group] = :any
145
+ end
146
+
147
+ opts[:id] = @argv.instid if @argv.instid
148
+ opts[:id] &&= [opts[:id]].flatten
149
+
150
+ rudy = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
151
+ lt = rudy.list_group(opts[:group], opts[:state], opts[:id]) do |inst|
152
+ puts @@global.verbose > 0 ? inst.inspect : inst.dump(@@global.format)
153
+ end
154
+ puts "No instances running" if !lt || lt.empty?
155
+ end
156
+ alias :instances :status
157
+
158
+
159
+ private
160
+
161
+ # * +action+ is one of :destroy, :restart
162
+ def instances_action(action)
163
+ opts = {}
164
+ opts[:group] = @option.group if @option.group
165
+ opts[:id] = @argv.instid if @argv.instid
166
+ opts[:id] &&= [opts[:id]].flatten
167
+
168
+ instances = @rinst.list_group(opts[:group], :running, opts[:id])
169
+ raise "No matching instances running" if instances.nil?
170
+
171
+ inst_names = instances.collect { |inst| inst.dns_public || inst.awsid }
172
+ inst_ids = instances.collect { |inst| inst.awsid }
173
+
174
+ instance_count = (instances.size == 1) ? '1 instance' : "#{instances.size} instances"
175
+
176
+ print "#{action.to_s.capitalize} #{instance_count} (#{inst_names.join(', ')}) "
177
+ print "in #{opts[:group]}" if opts[:group]
178
+ puts
179
+ execute_check(:medium)
180
+
181
+ execute_action("#{action.to_s.capitalize} Failed") {
182
+ @rinst.send(action, inst_ids)
183
+ }
184
+ status
185
+ end
186
+
187
+
188
+ end
189
+
190
+ end; end
191
+ end; end
192
+
193
+
194
+
@@ -0,0 +1,53 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module EC2;
5
+
6
+ class KeyPairs < Rudy::CLI::CommandBase
7
+
8
+ def create_keypairs_valid?
9
+ raise Drydock::ArgError.new('name', @alias) unless @argv.name
10
+ true
11
+ end
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) }
15
+ if %w[s string].member?(@@global.format)
16
+ puts "Name: #{kp.name}"
17
+ puts "Fingerprint: #{kp.fingerprint}", $/
18
+ puts "Copy the following private key data into a file."
19
+ puts "Set the permissions to 0600 and keep it safe.", $/
20
+ puts kp.private_key
21
+ else
22
+ puts @@global.verbose > 0 ? kp.inspect : kp.dump(@@global.format)
23
+ end
24
+ end
25
+
26
+ def destroy_keypairs_valid?
27
+ raise Drydock::ArgError.new('name', @alias) unless @argv.name
28
+ true
29
+ end
30
+ 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)
34
+ puts "Destroying: #{kp.name}"
35
+ execute_check(:medium)
36
+ execute_action { rkey.destroy(kp.name) }
37
+ keypairs
38
+ end
39
+
40
+ def keypairs
41
+ rkey = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
42
+ (rkey.list || []).each do |kp|
43
+ puts @@global.verbose > 0 ? kp.inspect : kp.dump(@@global.format)
44
+ end
45
+ puts "No keypairs" unless rkey.any?
46
+ end
47
+
48
+
49
+ end
50
+
51
+
52
+ end; end
53
+ end; end
@@ -0,0 +1,49 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module EC2;
5
+
6
+ class Snapshots < Rudy::CLI::CommandBase
7
+
8
+ def create_snapshots_valid?
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)
12
+ raise "Volume #{@volume.awsid} does not exist" unless @volume
13
+ true
14
+ end
15
+ def create_snapshots
16
+ rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
17
+ snap = execute_action { rsnap.create(@volume.awsid) }
18
+ puts @@global.verbose > 0 ? snap.inspect : snap.dump(@@global.format)
19
+ end
20
+
21
+ def destroy_snapshots_valid?
22
+ 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)
25
+ raise "Snapshot #{@snap.awsid} does not exist" unless @snap
26
+ true
27
+ end
28
+ def destroy_snapshots
29
+ puts "Destroying: #{@snap.awsid}"
30
+ execute_check(:medium)
31
+ execute_action { @rsnap.destroy(@snap.awsid) }
32
+ snapshots
33
+ end
34
+
35
+ def snapshots
36
+ rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
37
+ snaps = rsnap.list || []
38
+ snaps.each do |snap|
39
+ puts @@global.verbose > 0 ? snap.inspect : snap.dump(@@global.format)
40
+ end
41
+ puts "No snapshots" if snaps.empty?
42
+ end
43
+
44
+
45
+ end
46
+
47
+
48
+ end; end
49
+ end; end
@@ -0,0 +1,104 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module EC2;
5
+
6
+ class Volumes < Rudy::CLI::CommandBase
7
+
8
+
9
+ def volumes_create_valid?
10
+ raise "You must supply a volume size. See rudy volume -h" unless @option.size
11
+ raise "You must supply a zone." unless @@global.zone
12
+ true
13
+ end
14
+ def volumes_create
15
+ puts "Creating #{@option.size}GB volume in #{@@global.zone}"
16
+ rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
17
+ execute_check(:low)
18
+ vol = execute_action("Create Failed") {
19
+ rvol.create(@option.size, @@global.zone, @option.snapshot)
20
+ }
21
+ puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
22
+ end
23
+
24
+
25
+ def destroy_volumes_valid?
26
+ raise "You must supply a volume ID. See rudy volume -h" unless @argv.volid
27
+ true
28
+ end
29
+
30
+ def destroy_volumes
31
+ @rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
32
+ @volume = @rvol.get(@argv.volid)
33
+ raise "Volume #{@volume.awsid} does not exist" unless @volume
34
+ raise "Volume #{@volume.awsid} is still in-use" if @volume.in_use?
35
+ raise "Volume #{@volume.awsid} is still attached" if @volume.attached?
36
+ raise "Volume #{@volume.awsid} is not available (#{@volume.state})" unless @volume.available?
37
+
38
+ puts "Destroying #{@volume.awsid}"
39
+ execute_check(:medium)
40
+ execute_action("Destroy Failed") { @rvol.destroy(@volume.awsid) }
41
+
42
+ vol = @rvol.get(@volume.awsid)
43
+ puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
44
+ end
45
+
46
+
47
+ def volumes_attach_valid?
48
+ raise "You must supply an instance ID." unless @option.instance
49
+ raise "You must supply a volume ID." unless @argv.volid
50
+ true
51
+ end
52
+ def volumes_attach
53
+ @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)
60
+
61
+ puts "Attaching #{@argv.volid} to #{@option.instance} on #{@option.device}"
62
+ execute_check(:low)
63
+ execute_action("Attach Failed") {
64
+ rvol.attach(@argv.volid, @option.instance, @option.device)
65
+ }
66
+
67
+ vol = rvol.get(@argv.volid)
68
+ puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
69
+ end
70
+
71
+ def volumes_detach_valid?
72
+ raise "You must supply a volume ID." unless @argv.volid
73
+ true
74
+ end
75
+
76
+ 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)
81
+ raise "Volume #{vol.awsid} is not attached" unless vol.attached?
82
+
83
+ puts "Detaching #{vol.awsid} from #{vol.instid}"
84
+ execute_check(:medium)
85
+ execute_action("Detach Failed") { rvol.detach(vol.awsid) }
86
+
87
+ vol = rvol.get(vol.awsid)
88
+ puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
89
+ end
90
+
91
+
92
+ def volumes
93
+ rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
94
+ volumes = rvol.list || []
95
+ volumes.each do |vol|
96
+ puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
97
+ end
98
+ puts "No volumes" if volumes.empty?
99
+ end
100
+
101
+ end
102
+
103
+ end; end
104
+ end; end
@@ -0,0 +1,22 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module EC2;
5
+
6
+ class Zones < Rudy::CLI::CommandBase
7
+
8
+
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|
12
+ puts zon.dump(@@global.format)
13
+ end
14
+ puts "No zones" unless rzone.any?
15
+ end
16
+
17
+
18
+ end
19
+
20
+
21
+ end; end
22
+ end; end
@@ -0,0 +1,50 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module S3;
5
+
6
+ class Buckets < Rudy::CLI::CommandBase
7
+
8
+
9
+ def buckets
10
+ raise "No bucket name supplied" if !@argv.name && @option.list
11
+ s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region)
12
+ unless @option.list
13
+ (s3.list_buckets || []).each do |b|
14
+ puts b.name
15
+ end
16
+ else
17
+ puts "All objects in #{@argv.name}:"
18
+ (s3.list_bucket_objects(@argv.name) || []).each do |o|
19
+ puts o
20
+ end
21
+ end
22
+ end
23
+
24
+ def create_buckets_valid?
25
+ raise "No bucket name supplied" unless @argv.name
26
+ true
27
+ end
28
+ def create_buckets
29
+ execute_check(:low)
30
+ s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region)
31
+ s3.create_bucket(@argv.name)
32
+ buckets
33
+ end
34
+
35
+ def destroy_buckets_valid?
36
+ raise "No bucket name supplied" unless @argv.name
37
+ true
38
+ end
39
+ def destroy_buckets
40
+ execute_check(:medium)
41
+ s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region)
42
+ s3.destroy_bucket(@argv.name)
43
+ buckets
44
+ end
45
+
46
+
47
+ end
48
+
49
+ end; end
50
+ end; end
@@ -0,0 +1,22 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module S3;
5
+
6
+ class Store < Rudy::CLI::CommandBase
7
+
8
+ def store_valid?
9
+ raise "No path specified" unless @argv.path
10
+ raise "No bucket specified" unless @option.bucket
11
+ true
12
+ end
13
+ def store
14
+ s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region)
15
+ puts "Success: %s" % s3.store(@argv.path, @option.bucket)
16
+
17
+ end
18
+
19
+ end
20
+
21
+ end;end
22
+ end;end
@@ -0,0 +1,41 @@
1
+
2
+
3
+ module Rudy; module CLI;
4
+ module AWS; module SDB;
5
+
6
+ class Domains < Rudy::CLI::CommandBase
7
+
8
+
9
+ def domains
10
+ sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
11
+ domains = sdb.list_domains
12
+ puts domains
13
+ puts "No domains" if domains.nil? || domains.empty?
14
+ end
15
+
16
+ def domains_create_valid?
17
+ @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
18
+ raise "No name specified" unless @argv.name
19
+ true
20
+ end
21
+ def domains_create
22
+ @sdb.create_domain @argv.name
23
+ execute_check(:low)
24
+ domains
25
+ end
26
+
27
+ def domains_destroy_valid?
28
+ @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
29
+ raise "No name specified" unless @argv.name
30
+ true
31
+ end
32
+ def domains_destroy
33
+ execute_check(:medium)
34
+ @sdb.destroy_domain @argv.name
35
+ domains
36
+ end
37
+
38
+ end
39
+
40
+ end; end
41
+ end; end
@@ -1,12 +1,8 @@
1
1
 
2
-
3
-
4
-
5
2
  module Rudy
6
3
  module CLI
7
- class Deploy < Rudy::CLI::Base
4
+ class Candy < Rudy::CLI::CommandBase
8
5
 
9
6
  end
10
7
  end
11
- end
12
-
8
+ end
@@ -2,12 +2,12 @@
2
2
 
3
3
  module Rudy
4
4
  module CLI
5
- class Config < Rudy::CLI::Base
5
+ class Config < Rudy::CLI::CommandBase
6
6
 
7
7
  # We force the CLI::Base#print_header to be quiet
8
8
  def print_header
9
- @global.quiet = true
10
- super
9
+ #@@global.quiet = true
10
+ #super
11
11
  end
12
12
 
13
13
 
@@ -31,47 +31,52 @@ module Rudy
31
31
  # $ rudy config --all
32
32
  #
33
33
  def config
34
- return if @config.nil?
34
+ return if @@config.nil?
35
35
 
36
36
 
37
- @option.group ||= [@global.environment, @global.role].join(RUDY_DELIM)
37
+ @option.group ||= [@@global.environment, @@global.role].join(Rudy::DELIM)
38
38
 
39
- return if @config.empty?
39
+ return if @@config.empty?
40
40
 
41
41
  # We need to check whether we're running on a human's computer
42
42
  # or within EC2 (we call that running "in-situ"). The userdata
43
43
  # available when running in-situ is in a different format.
44
44
  if Rudy.in_situ?
45
-
46
-
45
+ puts "TODO: do something intelligent with config when running on EC2"
47
46
  else
48
47
  if @option.all
49
48
  puts "# ACCOUNTS: not displayed"
50
49
  puts "# MACHINES: "
51
- if @config.machines?
52
- y @config.machines.to_hash
50
+ if @@config.machines?
51
+ y @@config.machines.to_hash
53
52
  end
54
- if @config.routines?
53
+ if @@config.routines?
55
54
  puts "# ROUTINES: "
56
- y @config.routines.to_hash
55
+ y @@config.routines.to_hash
57
56
  end
58
57
  elsif @option.defaults?
59
- y @config.defaults.to_hash
58
+ y @@config.defaults.to_hash
59
+ elsif @option.script
60
+ y fetch_script_config.to_hash
61
+ elsif @option.rudy
62
+ rf = File.join(RUDY_HOME, 'Rudyfile')
63
+ raise "Cannot find: #{rf}" unless File.exists?(rf)
64
+ puts File.read(rf)
60
65
  else
61
- zon, env, rol = @global.zone, @global.environment, @global.role
62
- usr, att = @global.user, @argv.name
63
- val = @config.machines.find_deferred(zon, env, rol, usr, att) || ''
66
+ zon, env, rol = @@global.zone, @@global.environment, @@global.role
67
+ usr, att = @@global.user, @argv.name
68
+ val = @@config.machines.find_deferred(zon, env, rol, usr, att) || ''
64
69
  puts (val.is_a?(String)) ? val : val.to_hash.to_yaml
65
70
  end
66
71
 
67
72
  #name = @argv.first
68
- #if name && @config.userdata.has_key?(which)
69
- # value = @config.userdata[which][name.to_s]
73
+ #if name && @@config.userdata.has_key?(which)
74
+ # value = @@config.userdata[which][name.to_s]
70
75
  # puts value if value
71
76
  #elsif @option.all
72
- # puts @config.to_yaml
77
+ # puts @@config.to_yaml
73
78
  #else
74
- # value = @config.userdata[which]
79
+ # value = @@config.userdata[which]
75
80
  # puts value.to_yaml if value
76
81
  #end
77
82
  end