judo 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,7 +64,7 @@ default group will look something like this.
64
64
  $ cat default/config.json
65
65
  {
66
66
  "key_name":"judo14",
67
- "instance_size":"m1.small",
67
+ "instance_type":"m1.small",
68
68
  "ami32":"ami-bb709dd2", // public ubuntu 9.10 ami - 32 bit
69
69
  "ami64":"ami-55739e3c", // public ubuntu 9.10 ami - 64 bit
70
70
  "user":"ubuntu",
@@ -72,7 +72,7 @@ default group will look something like this.
72
72
  "availability_zone":"us-east-1d"
73
73
  }
74
74
 
75
- Any changes you make to these files does not stick until you've committed them.
75
+ Any changes you make to these files do not stick until you've committed them.
76
76
  To commit a group do the following.
77
77
 
78
78
  $ judo commit :default
@@ -96,7 +96,7 @@ You can stop all the servers in the :default group with:
96
96
 
97
97
  You could also have typed:
98
98
 
99
- $ judo stop my_server_1 my_server_2
99
+ $ judo stop my_server_1 my_server_2
100
100
 
101
101
  ## COMMANDS
102
102
 
@@ -126,7 +126,7 @@ Creates N new servers where N is an integer. These servers have generic names
126
126
  (group.N). Note: servers with generic names AND no external resources (like
127
127
  EBS Volumes or Elastic IPs) will be destroyed when stopped.
128
128
 
129
- $ judo destroy NAME
129
+ $ judo destroy NAME
130
130
 
131
131
  Destroy the named server. De-allocates any elastic IP's and destroys the EBS
132
132
  volumes.
@@ -208,7 +208,7 @@ A memcached server:
208
208
  "elastic_ip" : true,
209
209
  // only need 1 package
210
210
  "packages" : "memcached",
211
- "instance_size" : "m1.xlarge",
211
+ "instance_type" : "m1.xlarge",
212
212
  "files" : [
213
213
  { "file" : "/etc/memcached.conf",
214
214
  "template" : "memcached.conf.erb" },
@@ -239,7 +239,7 @@ A redis server with a 2 disk xfs raid 0:
239
239
  // dont repeat yourself - import the basic config
240
240
  "import" : "default",
241
241
  "elastic_ip" : true,
242
- "instance_size" : "m2.xlarge",
242
+ "instance_type" : "m2.xlarge",
243
243
  "local_packages" : { "package" : "redis-server_1.2.5-1", "source" : "http://http.us.debian.org/debian/pool/main/r/redis/" },
244
244
  "volumes" : [{ "device" : "/dev/sde1",
245
245
  "media" : "ebs",
@@ -274,26 +274,26 @@ default config. The system is expecting a registered keypair in this case
274
274
  named "keypair123" with a "keypair123.pem" file located in a subfolder named
275
275
  "keypairs".
276
276
 
277
- "instance_size":"m1.small",
277
+ "instance_type":"m1.small",
278
278
 
279
279
  Specify the instance size for the server type here. See:
280
280
  http://aws.amazon.com/ec2/instance-types/
281
281
 
282
- "ami32":"ami-bb709dd2",
283
- "ami64":"ami-55739e3c",
284
- "user":"ubuntu",
282
+ "ami32":"ami-bb709dd2",
283
+ "ami64":"ami-55739e3c",
284
+ "user":"ubuntu",
285
285
 
286
286
  This is where you specify the AMI's to use. The defaults (above) are the
287
287
  ubuntu 9.10 public AMI's. The "user" value is which user has the keypair
288
288
  bound to it for ssh'ing into the server.
289
289
 
290
- "security_group":"judo",
290
+ "security_group":"judo",
291
291
 
292
292
  What security group to launch the server in. A judo group is created for you
293
293
  which only has port 22 access. Manually create new security groups as needed
294
294
  and name them here.
295
295
 
296
- "availability_zone":"us-east-1d"
296
+ "availability_zone":"us-east-1d"
297
297
 
298
298
  What zone to launch the server in.
299
299
 
@@ -309,7 +309,9 @@ This command is very import and allows you inherit the configurations and files
309
309
  from other groups. If you wanted to make a group called 'mysql' that was
310
310
  exactly like the default group except it installed the mysql package and ran on
311
311
  a m2.4xlarge instance type you could specify it like this:
312
- { "import : "default", "packages" : [ "mysql" ], "instance_size" : "m2.4xlarge" }
312
+
313
+ { "import : "default", "packages" : [ "mysql" ], "instance_type" : "m2.4xlarge" }
314
+
313
315
  and save yourself a lot of typing. You could further subclass by making a new
314
316
  group and importing this config.
315
317
 
@@ -493,7 +495,7 @@ was run on this specific server boot check the first line of kuzushi.log.
493
495
  ubuntu:~$ sudo head -n 1 /var/log/kuzushi.log
494
496
 
495
497
 
496
- == Meta
498
+ ## Meta
497
499
 
498
500
  Created by Orion Henry and Adam Wiggins. Forked from the gem 'sumo'.
499
501
 
data/TODO CHANGED
@@ -1,23 +1,21 @@
1
1
  ### NEEDED for new gem launch
2
2
 
3
3
  ### [ ] ubuntu 10.04
4
- ### [ ] allocate elastic_ip first
5
4
  ### [ ] snapshot percent complete in do_snapshots()
6
5
  ### [ ] judo swap (x) (y) -> swaps elastic IP's and name
7
6
  ### [ ] snapshots/init/virgin
8
7
  ### [ ] bind kuzushi gem version version
9
8
  ### [ ] should be able to do ALL actions except commit without the repo!
10
9
  ### [ ] ssh - put pem into s3
11
- ### [ ] store s3 bucket in config
12
- ### [ ] store things in s3 by sha1sum
13
- ### [ ] ebs backed root disk
14
- ### [ ] clone from ebs snapshot on start
15
- ### [ ] implement start/stop
10
+ ### [ ] store s3 bucket in config
11
+ ### [ ] saw a timeout on volume allocation - make sure we build in re-tries - need to allocate the server all together as much as possible
12
+ ### [ ] round robin or specified availability_zone
16
13
 
14
+ ### MAYBE
15
+ ### [ ] store things in s3 by sha1sum
16
+ ### [ ] ebs backed root disk + start/stop
17
17
  ### [ ] implement auto security_group creation and setup (6 hrs)
18
-
19
- ### [ ] judo does not work with ruby 1.8.6 - :(
20
- ### [ ] saw a timeout on volume allocation - make sure we build in re-tries - need to allocate the server all together as much as possible
18
+ ### [ ] fix ruby 1.8.6 - test 1.9.1
21
19
 
22
20
  ### [ ] two phase delete (1 hr)
23
21
  ### [-] refactor availability_zone (2 hrs)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.3.0
data/bin/judo CHANGED
@@ -63,14 +63,29 @@ banner
63
63
  opts.on( '-f', '--force', 'Force a stop or restart (immediately force detach volumes)' ) do
64
64
  options[:force] = true
65
65
  end
66
+ opts.on( '-d', '--domain DOMAIN', 'Specify a judo domain within an AWS account' ) do |domain|
67
+ options[:domain] = domain
68
+ end
66
69
  opts.on( '-r', '--repo DIR', 'Specify the location of the repo dir' ) do |dir|
67
70
  options[:repo] = dir
68
71
  end
72
+ opts.on( '-D', '--data DATA', 'Specify an instance specific string to be used during boot on create or launch' ) do |data|
73
+ options[:data] = data
74
+ end
75
+ opts.on( '-t', '--type TYPE', 'Specify an instance type different from the config on server start' ) do |type|
76
+ options[:instance_type] = type
77
+ end
78
+ opts.on( '-B', '--boot BOOT', 'Instance specific string (like --data) but for this boot only' ) do |data|
79
+ options[:boot] = data
80
+ end
81
+ opts.on( '-i', '--ip IP', 'Specify an exsiting elastic_ip address on server creation' ) do |ip|
82
+ options[:elastic_ip] = ip
83
+ end
69
84
  opts.on( '-a', '--accessid ID', 'Specify the AWS access ID' ) do |id|
70
85
  options[:access_id] = id
71
86
  end
72
87
  opts.on( '-s', '--secret KEY', 'Specify the AWS access secret key' ) do |key|
73
- options[:access_key] = key
88
+ options[:access_secret] = key
74
89
  end
75
90
  opts.on( '-b', '--bucket BUCKET', 'Specify the AWS S3 bucket to use' ) do |bucket|
76
91
  options[:bucket] = bucket
@@ -106,11 +121,11 @@ begin
106
121
  when "console" then find_servers(judo, ARGV) { |s| puts s.console_output }
107
122
  when "commit" then find_groups(judo, ARGV) { |g| g.compile }
108
123
  when "ssh" then find_servers(judo, ARGV) { |s| s.connect_ssh }
109
- when "start" then find_servers(judo, ARGV) { |s| s.start(options[:version]) }
110
- when "restart" then find_servers(judo, ARGV) { |s| s.restart(options[:force]) }
111
- when "stop" then find_servers(judo, ARGV) { |s| s.stop(options[:force]) }
124
+ when "start" then find_servers(judo, ARGV) { |s| s.start(options) }
125
+ when "restart" then find_servers(judo, ARGV) { |s| s.restart(options) }
126
+ when "stop" then find_servers(judo, ARGV) { |s| s.stop(options) }
112
127
  when "create" then mk_servers(judo, ARGV) { |s| s.create(options) }
113
- when "launch" then mk_servers(judo, ARGV) { |s| s.create(options); s.start }
128
+ when "launch" then mk_servers(judo, ARGV) { |s| s.create(options); s.start(options) }
114
129
  when "snapshots" then do_snapshots(judo, ARGV)
115
130
  when "swapip" then
116
131
  servers = find_servers(judo, ARGV)
@@ -33,6 +33,7 @@ module Judo
33
33
  @bucket_name = options[:bucket]
34
34
  @access_id = options[:access_id]
35
35
  @access_secret = options[:access_secret]
36
+ @domain = options[:domain]
36
37
  end
37
38
 
38
39
  def volumes
@@ -60,8 +61,24 @@ module Judo
60
61
  end
61
62
  end
62
63
 
63
- def self.domain
64
- "judo_config"
64
+ def sdb_domain(name)
65
+ if @domain
66
+ "#{@domain}_#{name}"
67
+ else
68
+ name
69
+ end
70
+ end
71
+
72
+ def server_domain
73
+ sdb_domain("judo_servers")
74
+ end
75
+
76
+ def snapshot_domain
77
+ sdb_domain("judo_snapshots")
78
+ end
79
+
80
+ def base_domain
81
+ sdb_domain("judo_config")
65
82
  end
66
83
 
67
84
  def self.default_options(pwd, dir = find_judo_dir(pwd))
@@ -72,6 +89,7 @@ module Judo
72
89
  :judo_dir => dir,
73
90
  :group => group_config ? File.basename(File.dirname(group_config)) : nil,
74
91
  :repo => repo_dir,
92
+ :domain => (config["domain"] || ENV['JUDO_DOMAIN']),
75
93
  :bucket => (config["s3_bucket"] || ENV['JUDO_BUCKET']),
76
94
  :access_id => (config["access_id"] || ENV['AWS_ACCESS_KEY_ID']),
77
95
  :access_secret => (config["access_secret"] || ENV['AWS_SECRET_ACCESS_KEY'])
@@ -80,7 +98,8 @@ module Judo
80
98
  {
81
99
  :access_id => ENV['AWS_ACCESS_KEY_ID'],
82
100
  :access_secret => ENV['AWS_SECRET_ACCESS_KEY'],
83
- :bucket => ENV['JUDO_BUCKET']
101
+ :bucket => ENV['JUDO_BUCKET'],
102
+ :domain => ENV['JUDO_DOMAIN'],
84
103
  }.delete_if { |key,value| value.nil? }
85
104
  end
86
105
 
@@ -102,7 +121,7 @@ module Judo
102
121
 
103
122
  def fetch_snapshots_state
104
123
  s = {}
105
- sdb.select("select * from #{Judo::Snapshot.domain}")[:items].each do |group|
124
+ sdb.select("select * from `#{snapshot_domain}`")[:items].each do |group|
106
125
  group.each do |key,val|
107
126
  s[key] = val
108
127
  end
@@ -112,7 +131,7 @@ module Judo
112
131
 
113
132
  def fetch_servers_state
114
133
  s = {}
115
- sdb.select("select * from #{Judo::Server.domain}")[:items].each do |group|
134
+ sdb.select("select * from `#{server_domain}`")[:items].each do |group|
116
135
  group.each do |key,val|
117
136
  s[key] = val
118
137
  end
@@ -191,11 +210,11 @@ module Judo
191
210
  end
192
211
 
193
212
  def groups_config
194
- @groups_config ||= sdb.get_attributes("judo_config", "groups")[:attributes]
213
+ @groups_config ||= sdb.get_attributes(base_domain, "groups")[:attributes]
195
214
  end
196
215
 
197
216
  def group_versions
198
- @group_version ||= sdb.get_attributes("judo_config", "group_versions")[:attributes]
217
+ @group_version ||= sdb.get_attributes(base_domain, "group_versions")[:attributes]
199
218
  end
200
219
 
201
220
  def ip_to_judo(ip)
@@ -215,15 +234,23 @@ module Judo
215
234
  end
216
235
 
217
236
  def s3_url(k)
218
- Aws::S3Generator::Key.new(bucket, k).get
237
+ Aws::S3Generator::Key.new(bucket, s3_key(k)).get
219
238
  end
220
239
 
221
240
  def s3_get(k)
222
- bucket.get(k)
241
+ bucket.get( s3_key(k))
223
242
  end
224
243
 
225
244
  def s3_put(k, file)
226
- bucket.put(k, file)
245
+ bucket.put( s3_key(k), file)
246
+ end
247
+
248
+ def s3_key(k)
249
+ if @domain
250
+ "#{@domain}/#{k}"
251
+ else
252
+ k
253
+ end
227
254
  end
228
255
 
229
256
  def repo
@@ -252,14 +279,14 @@ module Judo
252
279
  case get_db_version
253
280
  when 0
254
281
  task("Upgrading Judo: Creating Snapshots SDB Domain") do
255
- sdb.create_domain(Judo::Server.domain)
256
- sdb.create_domain(Judo::Snapshot.domain)
257
- sdb.create_domain(Judo::Snapshot.domain)
282
+ sdb.create_domain(server_domain)
283
+ sdb.create_domain(base_domain)
284
+ sdb.create_domain(snapshot_domain)
258
285
  set_db_version(2)
259
286
  end
260
287
  when 1
261
288
  task("Upgrading Judo: Creating Snapshots SDB Domain") do
262
- sdb.create_domain(Judo::Snapshot.domain)
289
+ sdb.create_domain(snapshot_domain)
263
290
  set_db_version(2)
264
291
  end
265
292
  else
@@ -269,15 +296,18 @@ module Judo
269
296
 
270
297
  def set_db_version(new_version)
271
298
  @db_version = new_version
272
- sdb.put_attributes("judo_config", "judo", { "dbversion" => new_version }, :replace)
299
+ sdb.put_attributes(base_domain, "judo", { "dbversion" => new_version }, :replace)
273
300
  end
274
301
 
275
302
  def get_db_version
276
- @db_version ||= sdb.get_attributes("judo_config", "judo")[:attributes]["dbversion"].first.to_i
303
+ @db_version ||= (sdb.get_attributes(base_domain, "judo")[:attributes]["dbversion"] || []).first.to_i
277
304
  end
278
305
 
279
306
  def check_version
280
- upgrade_db if get_db_version != db_version
307
+ upgrade_db if get_db_version != db_version
308
+ rescue Aws::AwsError => e
309
+ setup_sdb
310
+ upgrade_db
281
311
  end
282
312
 
283
313
  def setup
@@ -294,7 +324,7 @@ module Judo
294
324
 
295
325
  def setup_sdb
296
326
  task("Trying to connect to SimpleDB") do
297
- sdb.create_domain(Judo::Base.domain)
327
+ sdb.create_domain(base_domain)
298
328
  end
299
329
  end
300
330
 
@@ -316,7 +346,7 @@ module Judo
316
346
  task("writing .judo/config.yml") do
317
347
  Dir.chdir(repo) do
318
348
  system "mkdir .judo"
319
- File.open(".judo/config.yml","w") do |f|
349
+ File.open(".judo/config.yml","w") do |f|
320
350
  f.write({ "access_id" => access_id, "access_secret" => access_secret, "s3_bucket" => bucket_name }.to_yaml)
321
351
  end
322
352
  end
@@ -346,7 +376,7 @@ module Judo
346
376
  <<DEFAULT
347
377
  {
348
378
  "key_name":"#{@keypair}",
349
- "instance_size":"m1.small",
379
+ "instance_type":"m1.small",
350
380
  "ami32":"ami-bb709dd2", // public ubuntu 9.10 ami - 32 bit
351
381
  "ami64":"ami-55739e3c", // public ubuntu 9.10 ami - 64 bit
352
382
  "user":"ubuntu",
@@ -31,7 +31,7 @@ module Judo
31
31
  end
32
32
 
33
33
  def set_version
34
- @base.sdb.put_attributes("judo_config", "group_versions", { name => version }, :replace)
34
+ @base.sdb.put_attributes(@base.base_domain, "group_versions", { name => version }, :replace)
35
35
  end
36
36
 
37
37
  def compile
@@ -137,7 +137,7 @@ module Judo
137
137
 
138
138
  def parent
139
139
  @parent ||= @base.groups.detect { |p| p.name == raw_config["import"] }
140
- raise JudoError, "Parent group #{raw_config["import"]} must be commited" if raw_config["import"] and @parent.nil?
140
+ (@parent ||= Judo::Group.new(@base, raw_config["import"], 0 )) if raw_config["import"] ## make a mock incase the parent was never committed
141
141
  @parent
142
142
  end
143
143
 
@@ -145,8 +145,8 @@ module Judo
145
145
  servers.each { |s| s.destroy }
146
146
  @base.task("Destring #{self}") do
147
147
  @base.groups.delete(self)
148
- @base.sdb.delete_attributes("judo_config", "groups", [ name ])
149
- @base.sdb.delete_attributes("judo_config", "group_versions", [ name ])
148
+ @base.sdb.delete_attributes(@base.base_domain, "groups", [ name ])
149
+ @base.sdb.delete_attributes(@base.base_domain, "group_versions", [ name ])
150
150
  end
151
151
  end
152
152
 
@@ -169,7 +169,7 @@ module Judo
169
169
  end
170
170
 
171
171
  def delete_server(server)
172
- sdb.delete_attributes("judo_config", "groups", name => server.name)
172
+ sdb.delete_attributes(@base.base_domain, "groups", name => server.name)
173
173
  end
174
174
 
175
175
  def to_s
@@ -1,6 +1,6 @@
1
1
  module Judo
2
2
  class Server
3
- attr_accessor :name
3
+ attr_accessor :name, :group_name
4
4
 
5
5
  def initialize(base, name, group, version = nil)
6
6
  @base = base
@@ -9,10 +9,12 @@ module Judo
9
9
  end
10
10
 
11
11
  def create(options)
12
- raise JudoError, "no group specified" unless @group_name
12
+ raise JudoError, "no group specified" unless group_name
13
13
 
14
- snapshots = options[:snapshots]
15
- note = options[:note]
14
+ snapshots = options[:snapshots]
15
+ note = options[:note] ## a user defined note field
16
+ data = options[:data] ## instance specific data passed in JUDO_DATA
17
+ ip = options[:elastic_ip] ## if the ip was allocated beforehand
16
18
 
17
19
  version = options[:version]
18
20
  version ||= group.version
@@ -25,8 +27,11 @@ module Judo
25
27
  raise JudoError, "there is already a server named #{name}" if @base.servers.detect { |s| s.name == @name and s != self}
26
28
 
27
29
  task("Creating server #{name}") do
28
- update "name" => name, "group" => @group_name, "note" => note, "virgin" => true, "secret" => rand(2 ** 128).to_s(36), "version" => version
29
- @base.sdb.put_attributes("judo_config", "groups", @group_name => name)
30
+ update "name" => name, "group" => group_name,
31
+ "note" => note, "virgin" => true,
32
+ "secret" => new_secret, "version" => version,
33
+ "data" => data, "elastic_ip" => ip
34
+ @base.sdb.put_attributes(@base.base_domain, "groups", group_name => name)
30
35
  end
31
36
 
32
37
  allocate_disk(snapshots)
@@ -36,11 +41,11 @@ module Judo
36
41
  end
37
42
 
38
43
  def group
39
- @group ||= @base.groups.detect { |g| g.name == @group_name }
44
+ @group ||= @base.groups.detect { |g| g.name == group_name }
40
45
  end
41
46
 
42
47
  def fetch_state
43
- @base.sdb.get_attributes(self.class.domain, name)[:attributes]
48
+ @base.sdb.get_attributes(@base.server_domain, name)[:attributes]
44
49
  end
45
50
 
46
51
  def state
@@ -51,6 +56,10 @@ module Judo
51
56
  state[key] && [state[key]].flatten.first
52
57
  end
53
58
 
59
+ def data
60
+ get "data"
61
+ end
62
+
54
63
  def instance_id
55
64
  get "instance_id"
56
65
  end
@@ -60,10 +69,10 @@ module Judo
60
69
  end
61
70
 
62
71
  def size_desc
63
- if not running? or ec2_instance_type == instance_size
64
- instance_size
72
+ if not running? or ec2_instance_type == instance_type
73
+ instance_type
65
74
  else
66
- "#{ec2_instance_type}/#{instance_size}"
75
+ "#{ec2_instance_type}/#{instance_type}"
67
76
  end
68
77
  end
69
78
 
@@ -119,39 +128,36 @@ module Judo
119
128
  Hash[ (state["volumes"] || []).map { |a| a.split(":") } ]
120
129
  end
121
130
 
122
- def self.domain
123
- "judo_servers"
124
- end
125
-
126
131
  def update(attrs)
127
- @base.sdb.put_attributes(self.class.domain, name, attrs, :replace)
132
+ @base.sdb.put_attributes(@base.server_domain, name, attrs, :replace)
128
133
  state.merge! attrs
129
134
  end
130
135
 
131
136
  def add(key, value)
132
- @base.sdb.put_attributes(self.class.domain, name, { key => value })
137
+ @base.sdb.put_attributes(@base.server_domain, name, { key => value })
133
138
  (state[key] ||= []) << value
134
139
  end
135
140
 
136
141
  def remove(key, value = nil)
137
142
  if value
138
- @base.sdb.delete_attributes(self.class.domain, name, key => value)
143
+ @base.sdb.delete_attributes(@base.server_domain, name, key => value)
139
144
  state[key] - [value]
140
145
  else
141
- @base.sdb.delete_attributes(self.class.domain, name, [ key ])
146
+ @base.sdb.delete_attributes(@base.server_domain, name, [ key ])
142
147
  state.delete(key)
143
148
  end
144
149
  end
145
150
 
146
151
  def delete
147
152
  group.delete_server(self) if group
148
- @base.sdb.delete_attributes(self.class.domain, name)
153
+ @base.sdb.delete_attributes(@base.server_domain, name)
149
154
  end
150
155
 
151
156
  ######## end simple DB access #######
152
157
 
153
- def instance_size
154
- config["instance_size"]
158
+ def instance_type
159
+ ## need instance_size to be backward compatible - needed for configs made before v 0.3.0
160
+ get("instance_type") || config["instance_type"] || config["instance_size"]
155
161
  end
156
162
 
157
163
  def config
@@ -159,7 +165,7 @@ module Judo
159
165
  end
160
166
 
161
167
  def to_s
162
- "#{name}:#{@group_name}"
168
+ "#{name}:#{group_name}"
163
169
  end
164
170
 
165
171
  def allocate_disk(snapshots)
@@ -275,18 +281,22 @@ module Judo
275
281
  ["pending", "running", "shutting_down", "degraded"].include?(ec2_state)
276
282
  end
277
283
 
278
- def start(new_version = nil)
284
+ def start(options = {})
285
+ new_version = options[:version]
286
+ set_instance_type(options[:instance_type]) if options[:instance_type]
287
+
279
288
  invalid "Already running" if running?
280
289
  invalid "No config has been commited yet, type 'judo commit'" unless group.version > 0
281
- task("Updating server version") { update_version(new_version) } if new_version
282
- task("Starting server #{name}") { launch_ec2 }
290
+
291
+ task("Updating server version") { update_version(options[:version]) } if options[:version]
292
+ task("Starting server #{name}") { launch_ec2(options[:boot]) }
283
293
  task("Wait for server") { wait_for_running } if elastic_ip or has_volumes?
284
294
  task("Attaching ip") { attach_ip } if elastic_ip
285
295
  task("Attaching volumes") { attach_volumes } if has_volumes?
286
296
  end
287
297
 
288
- def restart(force = false)
289
- stop(force) if running?
298
+ def restart(options = {})
299
+ stop(options) if running?
290
300
  start
291
301
  end
292
302
 
@@ -310,7 +320,8 @@ module Judo
310
320
  end
311
321
  end
312
322
 
313
- def stop(force = false)
323
+ def stop(options = {})
324
+ force = options[:force]
314
325
  invalid "not running" unless running?
315
326
  ## EC2 terminate_isntaces
316
327
  task("Terminating instance") { @base.ec2.terminate_instances([ instance_id ]) }
@@ -319,14 +330,14 @@ module Judo
319
330
  remove "instance_id"
320
331
  end
321
332
 
322
- def launch_ec2
333
+ def launch_ec2(boot = nil)
323
334
  # validate
324
335
 
325
336
  ## EC2 launch_instances
326
- ud = user_data
337
+ ud = user_data(boot)
327
338
  debug(ud)
328
339
  result = @base.ec2.launch_instances(ami,
329
- :instance_type => config["instance_size"],
340
+ :instance_type => instance_type,
330
341
  :availability_zone => config["availability_zone"],
331
342
  :key_name => config["key_name"],
332
343
  :group_ids => security_groups,
@@ -353,7 +364,7 @@ module Judo
353
364
  end
354
365
 
355
366
  def ia32?
356
- ["m1.small", "c1.medium"].include?(instance_size)
367
+ ["m1.small", "c1.medium"].include?(instance_type)
357
368
  end
358
369
 
359
370
  def ia64?
@@ -480,13 +491,15 @@ module Judo
480
491
  @base.servers_state.delete(name)
481
492
  end
482
493
 
483
- def user_data
494
+ def user_data(judo_boot = nil)
484
495
  <<USER_DATA
485
496
  #!/bin/sh
486
497
 
487
498
  export DEBIAN_FRONTEND="noninteractive"
488
499
  export DEBIAN_PRIORITY="critical"
489
500
  export JUDO_ID='#{name}'
501
+ export JUDO_BOOT='#{judo_boot}'
502
+ export JUDO_DATA='#{data}'
490
503
  export SECRET='#{secret}'
491
504
  apt-get update
492
505
  apt-get install ruby rubygems ruby-dev irb libopenssl-ruby libreadline-ruby -y
@@ -527,7 +540,7 @@ USER_DATA
527
540
  ip2 = other.elastic_ip
528
541
  raise JudoError, "Server must have an elastic IP to swap" unless ip1 and ip2
529
542
 
530
- task("Swapping Ip Addresses") do
543
+ task("Swapping Ip Addresses") do
531
544
  @base.ec2.disassociate_address(ip1)
532
545
  @base.ec2.disassociate_address(ip2)
533
546
 
@@ -543,5 +556,9 @@ USER_DATA
543
556
  [group.name, name] <=> [s.group.name, s.name]
544
557
  end
545
558
 
559
+ def new_secret
560
+ rand(2 ** 128).to_s(36)
561
+ end
562
+
546
563
  end
547
564
  end
@@ -17,7 +17,7 @@ module Judo
17
17
  end
18
18
 
19
19
  def fetch_state
20
- @base.sdb.get_attributes(self.class.domain, name)[:attributes]
20
+ @base.sdb.get_attributes(@base.snapshot_domain, name)[:attributes]
21
21
  end
22
22
 
23
23
  def state
@@ -43,7 +43,7 @@ module Judo
43
43
  devs = server.volumes.map do |dev,vol|
44
44
  "#{dev}:#{@base.ec2.create_snapshot(vol)[:aws_id]}"
45
45
  end
46
- @base.sdb.put_attributes(self.class.domain, name, { "version" => server.version, "devs" => devs, "server" => server.name, "group" => server.group.name }, :replace)
46
+ @base.sdb.put_attributes(@base.snapshot_domain, name, { "version" => server.version, "devs" => devs, "server" => server.name, "group" => server.group.name }, :replace)
47
47
  server.add "snapshots", name
48
48
  end
49
49
  end
@@ -56,7 +56,7 @@ module Judo
56
56
  end
57
57
 
58
58
  def delete
59
- @base.sdb.delete_attributes(self.class.domain, name)
59
+ @base.sdb.delete_attributes(@base.snapshot_domain, name)
60
60
  server.remove "snapshots", name
61
61
  end
62
62
 
@@ -98,7 +98,7 @@ module Judo
98
98
  end
99
99
 
100
100
  def fetch_state
101
- @base.sdb.get_attributes(self.class.domain, name)[:attributes]
101
+ @base.sdb.get_attributes(@base.snapshot_domain, name)[:attributes]
102
102
  end
103
103
  end
104
104
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 4
9
- version: 0.2.4
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Orion Henry
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-17 00:00:00 -04:00
17
+ date: 2010-05-18 00:00:00 -04:00
18
18
  default_executable: judo
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency