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 (132) hide show
  1. data/CHANGES.txt +110 -18
  2. data/README.rdoc +40 -44
  3. data/Rudyfile +35 -50
  4. data/bin/rudy +88 -57
  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 +59 -91
  9. data/lib/rudy/aws.rb +4 -45
  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 +18 -19
  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 +39 -26
  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 +45 -20
  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 +104 -0
  37. data/lib/rudy/cli/candy.rb +1 -2
  38. data/lib/rudy/cli/config.rb +20 -7
  39. data/lib/rudy/cli/disks.rb +7 -9
  40. data/lib/rudy/cli/execbase.rb +56 -0
  41. data/lib/rudy/cli/machines.rb +242 -45
  42. data/lib/rudy/cli/metadata.rb +24 -10
  43. data/lib/rudy/cli/networks.rb +34 -0
  44. data/lib/rudy/cli/routines.rb +32 -6
  45. data/lib/rudy/cli/status.rb +60 -0
  46. data/lib/rudy/config.rb +55 -32
  47. data/lib/rudy/config/objects.rb +44 -30
  48. data/lib/rudy/disks.rb +25 -0
  49. data/lib/rudy/exceptions.rb +99 -0
  50. data/lib/rudy/global.rb +67 -28
  51. data/lib/rudy/guidelines.rb +3 -2
  52. data/lib/rudy/huxtable.rb +67 -58
  53. data/lib/rudy/machines.rb +41 -263
  54. data/lib/rudy/metadata.rb +212 -38
  55. data/lib/rudy/metadata/backup.rb +123 -78
  56. data/lib/rudy/metadata/disk.rb +153 -170
  57. data/lib/rudy/metadata/machine.rb +179 -0
  58. data/lib/rudy/mixins.rb +2 -1
  59. data/lib/rudy/mixins/hash.rb +3 -1
  60. data/lib/rudy/mixins/symbol.rb +8 -0
  61. data/lib/rudy/routines.rb +127 -344
  62. data/lib/rudy/routines/base.rb +229 -0
  63. data/lib/rudy/routines/handlers/base.rb +48 -0
  64. data/lib/rudy/routines/handlers/depends.rb +49 -0
  65. data/lib/rudy/routines/handlers/disks.rb +249 -0
  66. data/lib/rudy/routines/handlers/group.rb +44 -0
  67. data/lib/rudy/routines/handlers/host.rb +70 -0
  68. data/lib/rudy/routines/handlers/keypair.rb +70 -0
  69. data/lib/rudy/routines/handlers/machines.rb +15 -0
  70. data/lib/rudy/routines/handlers/script.rb +85 -0
  71. data/lib/rudy/routines/handlers/user.rb +45 -0
  72. data/lib/rudy/routines/passthrough.rb +19 -23
  73. data/lib/rudy/routines/reboot.rb +98 -50
  74. data/lib/rudy/routines/shutdown.rb +65 -14
  75. data/lib/rudy/routines/startup.rb +112 -17
  76. data/lib/rudy/utils.rb +35 -68
  77. data/rudy.gemspec +82 -25
  78. data/tryouts/01_mixins/01_hash_tryouts.rb +20 -0
  79. data/tryouts/10_require_time/10_rudy_tryouts.rb +33 -0
  80. data/tryouts/10_require_time/15_global_tryouts.rb +58 -0
  81. data/tryouts/12_config/10_load_config_tryouts.rb +43 -0
  82. data/tryouts/12_config/20_defaults_tryouts.rb +16 -0
  83. data/tryouts/12_config/30_accounts_tryouts.rb +17 -0
  84. data/tryouts/12_config/40_machines_tryouts.rb +53 -0
  85. data/tryouts/12_config/50_commands_tryouts.rb +17 -0
  86. data/tryouts/12_config/60_routines_tryouts.rb +16 -0
  87. data/tryouts/15_huxtable/10_huxtable_tryouts.rb +47 -0
  88. data/tryouts/15_huxtable/20_user_tryouts.rb +47 -0
  89. data/tryouts/20_simpledb/10_domains_tryouts.rb +36 -0
  90. data/tryouts/20_simpledb/20_objects_tryouts.rb +56 -0
  91. data/tryouts/25_ec2/10_keypairs_tryouts.rb +54 -0
  92. data/tryouts/25_ec2/20_groups_tryouts.rb +56 -0
  93. data/tryouts/25_ec2/21_groups_authorize_address_tryouts.rb +53 -0
  94. data/tryouts/25_ec2/22_groups_authorize_account_tryouts.rb +54 -0
  95. data/tryouts/25_ec2/30_addresses_tryouts.rb +42 -0
  96. data/tryouts/25_ec2/40_volumes_tryouts.rb +53 -0
  97. data/tryouts/25_ec2/50_snapshots_tryouts.rb +75 -0
  98. data/tryouts/26_ec2_instances/10_instance_tryouts.rb +107 -0
  99. data/tryouts/26_ec2_instances/50_images_tryouts.rb +7 -0
  100. data/tryouts/30_metadata/10_include_tryouts.rb +45 -0
  101. data/tryouts/30_metadata/13_object_tryouts.rb +19 -0
  102. data/tryouts/30_metadata/50_disk_tryouts.rb +115 -0
  103. data/tryouts/30_metadata/51_disk_digest_tryouts.rb +24 -0
  104. data/tryouts/30_metadata/53_disk_list_tryouts.rb +35 -0
  105. data/tryouts/30_metadata/56_disk_volume_tryouts.rb +68 -0
  106. data/tryouts/30_metadata/60_backup_tryouts.rb +101 -0
  107. data/tryouts/30_metadata/63_backup_list_tryouts.rb +38 -0
  108. data/tryouts/30_metadata/64_backup_disk_tryouts.rb +65 -0
  109. data/tryouts/30_metadata/66_backup_snapshot_tryouts.rb +76 -0
  110. data/tryouts/30_metadata/70_machine_tryouts.rb +85 -0
  111. data/tryouts/30_metadata/73_machine_list_tryouts.rb +58 -0
  112. data/tryouts/30_metadata/76_machine_instance_tryouts.rb +64 -0
  113. data/tryouts/30_metadata/77_machines_tryouts.rb +45 -0
  114. data/tryouts/40_routines/10_keypair_handler_tryouts.rb +52 -0
  115. data/tryouts/40_routines/11_group_handler_tryouts.rb +36 -0
  116. data/tryouts/80_cli/10_rudyec2_tryouts.rb +8 -0
  117. data/tryouts/80_cli/60_rudy_tryouts.rb +41 -0
  118. data/tryouts/exploration/console.rb +91 -0
  119. data/tryouts/exploration/machine.rb +23 -0
  120. data/tryouts/failer +6 -0
  121. metadata +116 -32
  122. data/bin/ird +0 -153
  123. data/lib/rudy/metadata/backups.rb +0 -67
  124. data/lib/rudy/metadata/debug.rb +0 -38
  125. data/lib/rudy/metadata/disks.rb +0 -67
  126. data/lib/rudy/metadata/objectbase.rb +0 -108
  127. data/lib/rudy/routines/helper.rb +0 -76
  128. data/lib/rudy/routines/helpers/dependshelper.rb +0 -34
  129. data/lib/rudy/routines/helpers/diskhelper.rb +0 -403
  130. data/lib/rudy/routines/helpers/scripthelper.rb +0 -197
  131. data/lib/rudy/routines/helpers/userhelper.rb +0 -37
  132. data/support/rudy-ec2-startup +0 -200
data/bin/rudy CHANGED
@@ -9,7 +9,7 @@
9
9
  #
10
10
 
11
11
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') # Put our local lib in first place
12
- #$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'drydock', 'lib')
12
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'drydock', 'lib')
13
13
 
14
14
  #$SAFE = 1 # require is unsafe in Ruby 1.9??
15
15
 
@@ -20,56 +20,92 @@ require 'rudy/cli'
20
20
  # Command-line interface for /bin/rudy
21
21
  class RudyCLI < Rudy::CLI::Base
22
22
 
23
- debug :off
24
23
  default :machines # when no command is provided
25
24
  trawler :passthrough # unknown command names will forward here.
26
25
 
27
26
  # ------------------------------------------ RUDY GLOBALS --------
28
27
  # ------------------------------------------------------------------
29
28
 
30
- global :e, :environment, String, "Connect to the specified environment (ie: #{Rudy::DEFAULT_ENVIRONMENT})"
31
- global :r, :role, String, "Connect to a machine with the specified role (ie: #{Rudy::DEFAULT_ROLE})"
32
- global :p, :position, String, "Position in the machine in its group (ie: #{Rudy::DEFAULT_POSITION})"
33
-
34
-
29
+ global :e, :environment, String, "Connect to the specified environment (e.g. #{Rudy::DEFAULT_ENVIRONMENT})"
30
+ global :r, :role, String, "Connect to a machine with the specified role (e.g. #{Rudy::DEFAULT_ROLE})"
31
+ global :p, :position, String, "Position in the machine in its group"
32
+ global :b, :bucket, String, "An S3 bucket name (used when creating images)"
33
+ global :t, :testrun, "Test run. Don't execute action (PARTIALLY SUPPORTED)."
34
+ global :P, :parallel, "Execute remote commands in parallel (PARTIALLY SUPPORTED)."
35
+ global :F, :force, "Force an action despite warnings"
36
+
37
+
35
38
  # ------------------------------------------ RUDY OBJECTS --------
36
39
  # ------------------------------------------------------------------
37
40
 
38
41
  about "View Machines"
42
+ usage "rudy"
43
+ usage "rudy machines"
44
+ usage "rudy machines -l"
45
+ usage "rudy machines -U"
46
+ usage "rudy machines -A"
47
+ usage "rudy machines -S [static ip address]"
48
+ usage "rudy machines -D"
39
49
  option :l, :all, "Display machines for all environments and roles"
40
- action :W, :wash, "Wash machine metadata."
50
+ action :W, :wash, "Wash machine metadata"
51
+ action :T, :available, "Test availablity"
52
+ action :U, :update, "Update machines based on configuration"
53
+ action :A, :associate, "Associate static IP addresses or display existing ones"
54
+ action :N, :disassociate, "Disassociate static IP addresses"
41
55
  command :machines => Rudy::CLI::Machines
42
56
  command_alias :machines, :m
43
57
 
44
58
  about "View Disks"
45
- action :W, :wash, "Wash disk metadata."
59
+ usage "rudy disks"
60
+ usage "rudy disks -l"
61
+ action :W, :wash, "Wash disk metadata"
46
62
  option :b, :backups, "Display backups"
47
63
  option :l, :all, "Display all disks"
48
64
  command :disks => Rudy::CLI::Disks
49
65
  command_alias :disks, :d
50
-
66
+
67
+ about "View Backups"
68
+ usage "rudy backups"
69
+ usage "rudy backups -l"
70
+ action :W, :wash, "Wash backup metadata"
71
+ option :l, :all, "Display all backups"
72
+ command :backups => Rudy::CLI::Backups
73
+ command_alias :backups, :b
74
+
51
75
  about "View raw metadata"
52
76
  usage "rudy metadata"
53
- usage "rudy metadata -l -o [disk|back|m]"
77
+ usage "rudy metadata -l -r [disk|back|m]"
54
78
  usage "rudy metadata -D object-id"
55
- option :o, :otype, String, "Object type. One of: disk, back, m"
79
+ option :r, :rtype, String, "Record type. One of: disk, back, m (default)"
56
80
  option :l, :all, "Display metadata for all environments and roles"
57
81
  action :D, :delete, "Delete an object"
58
82
  argv :oid
59
- command :metadata => Rudy::CLI::MetaData
83
+ command :metadata => Rudy::CLI::Metadata
60
84
 
61
- about "Log in to a machine"
62
- command :ssh => Rudy::CLI::Machines
63
-
64
- #about "Open the machine in your default browser (OSX only)"
65
- #option :s, :https, "Use HTTPS"
66
- #option :p, :port, Integer, "Port"
67
- #command :open => Rudy::CLI::Candy
85
+ about "View Network configuration (local network only)"
86
+ usage "rudy networks"
87
+ usage "rudy networks -L"
88
+ usage "rudy networks -L -i"
89
+ usage "rudy networks -L -e"
90
+ usage "rudy networks -U"
91
+ option :e, :external, "Display only external IP address"
92
+ option :i, :internal, "Display only internal IP address"
93
+ action :U, :update, "Update networks based on configuration"
94
+ action :L, :local, "Show local network configuration"
95
+ command :networks => Rudy::CLI::Networks
96
+ command_alias :networks, :n
68
97
 
69
98
 
70
99
  # ----------------------------------------- RUDY ROUTINES --------
71
100
  # ------------------------------------------------------------------
72
101
 
102
+ about "View Routines"
103
+ usage "rudy routines"
104
+ usage "rudy routines -l"
105
+ option :l, :all, "Display routines for all environments and roles"
106
+ command :routines => Rudy::CLI::Routines
107
+ command_alias :routines, :r
108
+
73
109
  # A "do nothing" routine. Passthrough simply executes a routine
74
110
  # config block. Drydock's trawler uses this for unknown commands.
75
111
  about "A passthrough for custom routines"
@@ -95,7 +131,19 @@ class RudyCLI < Rudy::CLI::Base
95
131
 
96
132
  # ------------------------------------ RUDY MISCELLANEOUS --------
97
133
  # ------------------------------------------------------------------
98
-
134
+
135
+ about "Display existing environment objects"
136
+ option :l, :all, "Include all regions"
137
+ command :status => Rudy::CLI::Status
138
+
139
+ about "Log in to a machine"
140
+ command :ssh => Rudy::CLI::Machines
141
+
142
+ #about "Open the machine in your default browser (OSX only)"
143
+ #option :s, :https, "Use HTTPS"
144
+ #option :p, :port, Integer, "Port"
145
+ #command :open => Rudy::CLI::Candy
146
+
99
147
  usage "rudy [-f config-file] config [param-name]"
100
148
  about "Check Rudy configuration."
101
149
  option :l, :all, "Display all configs for all machines"
@@ -110,29 +158,36 @@ class RudyCLI < Rudy::CLI::Base
110
158
  #option :g, :group, String, "Display configuration for a specific group"
111
159
  argv :name
112
160
  command :config => Rudy::CLI::Config
161
+ command_alias :config, :configs
113
162
 
114
163
  command :print_global => Rudy::CLI::Config
164
+ command_alias :print_global, :globals
115
165
  command_alias :print_global, :global
116
-
166
+
117
167
  about "Initialize Rudy configuration"
118
168
  command :init do |obj|
119
169
 
120
170
  Rudy::Huxtable.update_config
121
171
 
122
- unless File.exists?(Rudy::CONFIG_FILE)
172
+ unless File.exists? Rudy::CONFIG_FILE
123
173
  Rudy::Config.init_config_dir
124
174
  end
125
175
 
126
176
  begin
127
177
 
128
- unless Rudy::Huxtable.domain_exists?
178
+ if Rudy::Huxtable.domain_exists?
179
+ puts "SimpleDB domain #{Rudy::Huxtable.domain} already exists"
180
+ else
129
181
  puts "Creating SimpleDB domain #{Rudy::Huxtable.domain}"
130
182
  Rudy::Huxtable.create_domain
131
- puts "Initialized"
132
- else
133
- puts "Already Initialized"
134
183
  end
135
-
184
+
185
+ user, host = Rudy.sysinfo.user, Rudy::Huxtable.global.localhost
186
+
187
+ puts "Authorizing public keys for #{user}@#{host}"
188
+ rbox = Rye::Box.new host
189
+ rbox.authorize_keys_local
190
+
136
191
  rescue Rudy::AWS::SDB::NoSecretKey,
137
192
  Rudy::AWS::SDB::NoAccessKey,
138
193
  Rudy::NoConfig => ex
@@ -150,24 +205,7 @@ class RudyCLI < Rudy::CLI::Base
150
205
  t = obj.option.local ? Time.now : Time.now.utc
151
206
  puts '%s' % t.strftime("%Y-%m-%d %T %Z (%z)")
152
207
  end
153
-
154
- usage "rudy myaddress [-i] [-e]"
155
- about "Displays you current internal and external IP addresses"
156
- option :e, :external, "Display only external IP address"
157
- option :i, :internal, "Display only internal IP address"
158
- command :myaddress do |obj|
159
- ea = Rudy::Utils::external_ip_address || ''
160
- ia = Rudy::Utils::internal_ip_address || ''
161
- if obj.global.quiet
162
- puts ia unless obj.option.external && !obj.option.internal
163
- puts ea unless obj.option.internal && !obj.option.external
164
- else
165
- puts "%10s: %s" % ['Internal', ia] unless obj.option.external && !obj.option.internal
166
- puts "%10s: %s" % ['External', ea] unless obj.option.internal && !obj.option.external
167
- end
168
- obj.global.quiet = true # don't print elapsed time
169
- end
170
-
208
+
171
209
  usage "rudy [global options] annoy [-h -m -l] [-e]"
172
210
  about "Play around with Rudy's annoying challenges"
173
211
  option :s, :string, "A numeric challenge"
@@ -202,19 +240,14 @@ class RudyCLI < Rudy::CLI::Base
202
240
  end
203
241
  end
204
242
 
205
-
243
+ about "Display basic system information"
206
244
  command :sysinfo do
207
245
  puts Rudy.sysinfo.to_yaml
208
246
  end
209
247
  end
210
248
 
211
- # We call Drydock specifically otherwise it will run at_exit. Rye also
212
- # uses at_exit for shutting down the ssh-agent. Ruby executes at_exit
213
- # blocks in reverse order so if Drydock is required first, it's block
214
- # will run after Rye shuts down the ssh-agent.
215
249
  begin
216
250
  Drydock.run!(ARGV, STDIN) if Drydock.run? && !Drydock.has_run?
217
-
218
251
  rescue Drydock::ArgError, Drydock::OptError => ex
219
252
  STDERR.puts ex.message
220
253
  STDERR.puts ex.usage
@@ -223,12 +256,10 @@ rescue Drydock::InvalidArgument => ex
223
256
  rescue Rudy::Error => ex
224
257
  STDERR.puts ex.message
225
258
  STDERR.puts ex.backtrace if Drydock.debug?
226
- rescue => ex
227
- STDERR.puts "ERROR (#{ex.class.to_s}): #{ex.message}"
228
- STDERR.puts ex.backtrace if Drydock.debug?
229
259
  rescue Interrupt
230
260
  puts "#{$/}Exiting... "
231
261
  exit 1
232
- rescue SystemExit
233
- # Don't balk
262
+ rescue => ex
263
+ STDERR.puts "ERROR (#{ex.class.to_s}): #{ex.message}"
264
+ STDERR.puts ex.backtrace if Drydock.debug?
234
265
  end
data/bin/rudy-ec2 CHANGED
@@ -20,7 +20,6 @@ require 'rudy/cli'
20
20
  module RudyCLI_EC2
21
21
  extend Drydock
22
22
 
23
- debug :off
24
23
  default :instances
25
24
 
26
25
  # ----------------------------------- AMAZON EC2 COMMANDS --------
@@ -105,11 +104,6 @@ module RudyCLI_EC2
105
104
  option :o, :owner, String, "Amazon Account Number or one of: amazon, self"
106
105
  option :l, :all, "Display all registered machine images (warning: slow)"
107
106
  #option :p, :private, "Private images only"
108
- option :b, :bucket, String, "The name of the bucket that will store the image"
109
- option :n, :name, String, "The name of the image file (to create)"
110
- option :u, :user, String, "Username to connect as (used for creating an image)"
111
- action :C, :create, "Create an image"
112
- #action :P, :prepare, "Prepare a running instance to be used as an image"
113
107
  action :R, :register, "Register an image"
114
108
  action :D, :destroy, "Deregister an image (does not remove image files from S3)"
115
109
  argv :ami
@@ -142,14 +136,14 @@ module RudyCLI_EC2
142
136
  command_alias :instances, :in
143
137
  command_alias :instances, :i
144
138
 
145
- about "Amazon EC2 KeyPairs"
139
+ about "Amazon EC2 EC2::Keypairs"
146
140
  usage "rudy-ec2 keypairs"
147
141
  usage "rudy-ec2 keypairs -C name"
148
142
  usage "rudy-ec2 keypairs -D name"
149
143
  action :D, :destroy, "Unregister keypair from EC2 (this is permanent!)"
150
144
  action :C, :create, "Create and register a keypair with EC2"
151
145
  argv :name
152
- command :keypairs => Rudy::CLI::AWS::EC2::KeyPairs
146
+ command :keypairs => Rudy::CLI::AWS::EC2::Keypairs
153
147
  command_alias :keypairs, :keypair
154
148
  command_alias :keypairs, :k
155
149
 
@@ -211,12 +205,6 @@ module RudyCLI_EC2
211
205
 
212
206
  end
213
207
 
214
- #puts Rudy::Utils.banner("THIS IS RUBY #{RUBY_VERSION}") if Drydock.debug?
215
-
216
- # We call Drydock specifically otherwise it will run at_exit. Rye also
217
- # uses at_exit for shutting down the ssh-agent. Ruby executes at_exit
218
- # blocks in reverse order so if Drydock is required first, it's block
219
- # will run after Rye shuts down the ssh-agent.
220
208
  begin
221
209
  Drydock.run!(ARGV, STDIN) if Drydock.run? && !Drydock.has_run?
222
210
  rescue Drydock::ArgError, Drydock::OptError => ex
@@ -233,8 +221,6 @@ rescue => ex
233
221
  rescue Interrupt
234
222
  puts "#{$/}Exiting... "
235
223
  exit 1
236
- rescue SystemExit
237
- # Don't balk
238
224
  end
239
225
 
240
226
 
data/bin/rudy-s3 CHANGED
@@ -44,18 +44,10 @@ module RudyCLI_S3
44
44
  # ------------------------------------------------------------------
45
45
 
46
46
  default :buckets
47
- debug :off
48
-
49
47
 
50
48
  end
51
49
 
52
50
 
53
- #puts Rudy::Utils.banner("THIS IS RUBY #{RUBY_VERSION}") if Drydock.debug?
54
-
55
- # We call Drydock specifically otherwise it will run at_exit. Rye also
56
- # uses at_exit for shutting down the ssh-agent. Ruby executes at_exit
57
- # blocks in reverse order so if Drydock is required first, it's block
58
- # will run after Rye shuts down the ssh-agent.
59
51
  begin
60
52
  Drydock.run!(ARGV, STDIN) if Drydock.run? && !Drydock.has_run?
61
53
  rescue Drydock::ArgError, Drydock::OptError => ex
@@ -72,7 +64,5 @@ rescue => ex
72
64
  rescue Interrupt
73
65
  puts "#{$/}Exiting... "
74
66
  exit 1
75
- rescue SystemExit
76
- # Don't balk
77
67
  end
78
68
 
data/bin/rudy-sdb CHANGED
@@ -28,24 +28,25 @@ module RudyCLI_SDB
28
28
  action :D, :destroy, "Destroy a domain"
29
29
  argv :name
30
30
  command :domains => Rudy::CLI::AWS::SDB::Domains
31
+ command_alias :domains, :domain
32
+
33
+ about "Displays objects contained in a SimpleDB domain"
34
+ argv :name, :key
35
+ command :objects => Rudy::CLI::AWS::SDB::Objects
36
+ command_alias :objects, :object
37
+
38
+ about "Execute a SimpleDB select query"
39
+ argv :query
40
+ command :query => Rudy::CLI::AWS::SDB::Select
31
41
 
32
42
 
33
43
  # -------------------------------- RUDY-SDB MISCELLANEOUS --------
34
44
  # ------------------------------------------------------------------
35
45
 
36
46
  default :domains
37
- debug :off
38
-
39
-
40
- end
41
-
42
47
 
43
- #puts Rudy::Utils.banner("THIS IS RUBY #{RUBY_VERSION}") if Drydock.debug?
48
+ end
44
49
 
45
- # We call Drydock specifically otherwise it will run at_exit. Rye also
46
- # uses at_exit for shutting down the ssh-agent. Ruby executes at_exit
47
- # blocks in reverse order so if Drydock is required first, it's block
48
- # will run after Rye shuts down the ssh-agent.
49
50
  begin
50
51
  Drydock.run!(ARGV, STDIN) if Drydock.run? && !Drydock.has_run?
51
52
  rescue Drydock::ArgError, Drydock::OptError => ex
@@ -62,7 +63,5 @@ rescue => ex
62
63
  rescue Interrupt
63
64
  puts "#{$/}Exiting... "
64
65
  exit 1
65
- rescue SystemExit
66
- # Don't balk
67
66
  end
68
67
 
data/lib/rudy.rb CHANGED
@@ -4,32 +4,35 @@ unless defined?(RUDY_HOME)
4
4
  RUDY_LIB = File.join(File.dirname(__FILE__), '..', 'lib')
5
5
  end
6
6
 
7
- local_libs = %w{net-ssh net-scp amazon-ec2 aws-s3 caesars drydock rye storable sysinfo annoy}
8
- #local_libs.each { |dir| $:.unshift File.join(RUDY_HOME, '..', dir, 'lib') }
7
+ local_libs = %w{net-ssh net-scp aws-s3 caesars drydock rye storable sysinfo annoy gibbler}
8
+ local_libs.each { |dir| $:.unshift File.join(RUDY_HOME, '..', dir, 'lib') }
9
9
  #require 'rubygems'
10
10
 
11
+ begin; require 'json'; rescue LoadError; end # Silence!
12
+
11
13
  require 'digest/md5'
12
14
  require 'stringio'
13
15
  require 'ostruct'
14
16
  require 'yaml'
15
- require 'json'
16
17
  require 'logger'
17
18
  require 'socket'
19
+ require 'resolv'
18
20
  require 'timeout'
21
+ require 'gibbler'
19
22
  require 'tempfile'
20
23
  require 'rudy/mixins'
24
+ require 'gibbler/aliases'
21
25
  require 'storable'
22
26
  require 'sysinfo'
27
+ require 'attic'
23
28
  require 'annoy'
24
29
  require 'rye'
25
30
 
26
-
27
-
28
31
  # = Rudy
29
32
  #
30
33
  #
31
34
  # Rudy is a development and deployment tool for the Amazon Elastic Compute Cloud
32
- # (EC2). <a href="http://solutious.com/products/rudy/getting-started.html">Getting Started</a> today!
35
+ # (EC2). <a href="http://solutious.com/projects/rudy/getting-started">Getting Started</a> today!
33
36
  #
34
37
  #
35
38
  module Rudy
@@ -38,8 +41,8 @@ module Rudy
38
41
  module VERSION #:nodoc:
39
42
  unless defined?(MAJOR)
40
43
  MAJOR = 0.freeze
41
- MINOR = 8.freeze
42
- TINY = 5.freeze
44
+ MINOR = 9.freeze
45
+ TINY = 0.freeze
43
46
  end
44
47
  def self.to_s; [MAJOR, MINOR, TINY].join('.'); end
45
48
  def self.to_f; self.to_s.to_f; end
@@ -48,7 +51,7 @@ module Rudy
48
51
  unless defined? Rudy::DOMAIN # We can assume all constants are defined
49
52
 
50
53
  @@quiet = false
51
- @@yes = false
54
+ @@auto = false
52
55
  @@debug = false
53
56
  @@sysinfo = SysInfo.new.freeze
54
57
 
@@ -59,109 +62,74 @@ module Rudy
59
62
 
60
63
  CONFIG_DIR = File.join(@@sysinfo.home, '.rudy').freeze
61
64
  CONFIG_FILE = File.join(Rudy::CONFIG_DIR, 'config').freeze
65
+ SSH_KEY_DIR = File.expand_path('~/.ssh').freeze
62
66
 
63
- DEFAULT_REGION = :'us-east-1'.freeze
64
67
  DEFAULT_ZONE = :'us-east-1b'.freeze
65
- DEFAULT_ENVIRONMENT = :'stage'.freeze
66
- DEFAULT_ROLE = :'app'.freeze
67
- DEFAULT_POSITION = '01'.freeze
68
-
69
- DEFAULT_USER = :'rudy'.freeze
70
-
68
+ DEFAULT_REGION = DEFAULT_ZONE.to_s.gsub(/[a-z]$/, '').to_sym.freeze
69
+ DEFAULT_ENVIRONMENT = :stage.freeze
70
+ DEFAULT_ROLE = :app.freeze
71
+
71
72
  DEFAULT_EC2_HOST = "ec2.amazonaws.com"
72
73
  DEFAULT_EC2_PORT = 443
73
74
 
74
75
  MAX_INSTANCES = 5.freeze
75
76
 
76
- SUPPORTED_SCM_NAMES = [:svn, :git].freeze
77
-
78
77
  ID_MAP = {
79
- :disk => 'disk',
80
- :instance => 'i',
81
- :backup => 'back',
82
- :machine => 'm',
83
- :volume => 'vol',
84
- :snapshot => 'snap',
85
- :kernel => 'aki',
86
- :image => 'ami',
87
- :ram => 'ari',
88
- :log => 'log',
89
- :key => 'key',
90
- :awspk => 'pk',
91
- :awscert => 'cert',
78
+ :instance => 'i',
79
+ :machine => 'm',
92
80
  :reservation => 'r',
93
- :dns_public => 'ec2',
94
- :dns_private => 'domU',
81
+ :pkey => 'pk',
82
+ :volume => 'vol',
83
+ :kernel => 'aki',
84
+ :image => 'ami',
85
+ :ramdisk => 'ari',
86
+ :group => 'grp',
87
+ :log => 'log',
88
+ :key => 'key',
89
+ :dns_public => 'ec2',
90
+ :disk => 'disk',
91
+ :backup => 'back',
92
+ :snapshot => 'snap',
93
+ :cert => 'cert',
94
+ :dns_private => 'domU'
95
95
  }.freeze
96
96
 
97
97
  end
98
98
 
99
- def Rudy.debug?; @@debug == true; end
100
99
  def Rudy.quiet?; @@quiet == true; end
101
- def Rudy.yes?; @@yes == true; end
102
- def Rudy.enable_debug; @@debug = true; end
103
100
  def Rudy.enable_quiet; @@quiet = true; end
104
- def Rudy.enable_yes; @@yes = true; end
105
- def Rudy.disable_debug; @@debug = false; end
106
101
  def Rudy.disable_quiet; @@quiet = false; end
107
- def Rudy.disable_yes; @@yes = false; end
102
+
103
+ def Rudy.auto?; @@auto == true; end
104
+ def Rudy.enable_auto; @@auto = true; end
105
+ def Rudy.disable_auto; @@auto = false; end
106
+
107
+ def Rudy.debug?; @@debug == true; end
108
+ def Rudy.enable_debug; @@debug = true; end
109
+ def Rudy.disable_debug; @@debug = false; end
110
+
108
111
 
109
112
  def Rudy.sysinfo; @@sysinfo; end
110
113
  def sysinfo; @@sysinfo; end
111
114
 
112
- class Error < RuntimeError
113
- def initialize(obj=nil); @obj = obj; end
114
- def message; "#{self.class}: #{@obj}"; end
115
- end
116
- class InsecureKeyPermissions < Rudy::Error
117
- def message
118
- lines = ["Insecure file permissions for #{@obj}"]
119
- lines << "Try: chmod 600 #{@obj}"
120
- lines.join($/)
121
- end
122
- end
123
-
124
- #--
125
- # TODO: Update exception Syntax based on:
126
- # http://blog.rubybestpractices.com/posts/gregory/anonymous_class_hacks.html
127
- #++
128
- class NoConfig < Rudy::Error
129
- def message; "No configuration found!"; end
130
- end
131
- class NoGlobal < Rudy::Error
132
- def message; "No globals defined!"; end
133
- end
134
- class NoMachinesConfig < Rudy::Error
135
- def message; "No machines configuration. Check your configs!"; end
136
- end
137
- class NoRoutinesConfig < Rudy::Error
138
- def message; "No routines configuration. Check your configs!"; end
139
- end
140
- class ServiceUnavailable < Rudy::Error
141
- def message; "#{@obj} is not available. Check your internets!"; end
142
- end
143
- class MachineGroupAlreadyRunning < Rudy::Error
144
- def message; "Machine group #{@obj} is already running."; end
145
- end
146
- class MachineGroupNotRunning < Rudy::Error
147
- def message; "Machine group #{@obj} is not running."; end
148
- end
149
- class MachineGroupNotDefined < Rudy::Error
150
- def message; "#{@obj} is not defined in machines config."; end
151
- end
152
- class PrivateKeyFileExists < Rudy::Error
153
- def message; "Private key #{@obj} already exists."; end
154
- end
155
- class PrivateKeyNotFound < Rudy::Error
156
- def message; "Private key file #{@obj} not found."; end
115
+ end
116
+
117
+ if Rudy.sysinfo.vm == :java
118
+ require 'java'
119
+ module Java
120
+ include_class java.net.Socket unless defined?(Java::Socket)
121
+ include_class java.net.InetSocketAddress unless defined?(Java::InetSocketAddress)
157
122
  end
158
123
  end
159
124
 
160
- require 'rudy/utils' # The
161
- require 'rudy/global' # order
162
- require 'rudy/config' # of
163
- require 'rudy/huxtable' # requires
164
- require 'rudy/aws' # is
165
- require 'rudy/metadata' # important
166
- require 'rudy/machines'
125
+ require 'rudy/exceptions'
126
+ require 'rudy/utils' # The
127
+ require 'rudy/global' # order
128
+ require 'rudy/config' # of
129
+ require 'rudy/huxtable' # requires
130
+ require 'rudy/aws' # is
131
+ require 'rudy/metadata' # super
132
+ require 'rudy/machines' # important.
133
+ require 'rudy/backups'
134
+ require 'rudy/disks'
167
135
  require 'rudy/routines'