judo 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/bin/judo CHANGED
@@ -12,6 +12,13 @@ class CLI < Thor
12
12
  end
13
13
  end
14
14
 
15
+ desc "dump", "start one or more servers"
16
+ def dump
17
+ require 'pp'
18
+ pp Judo::Config.sdb.select("SELECT * FROM judo_servers")[:items]
19
+ pp Judo::Config.sdb.select("SELECT * FROM judo_config")[:items]
20
+ end
21
+
15
22
  desc "ssh [NAMES]", "ssh to a specified server or first available"
16
23
  def ssh(*names)
17
24
  servers(*names) do |server|
@@ -123,11 +130,7 @@ class CLI < Thor
123
130
  desc "console [NAMES]", "get console output for server or first available"
124
131
  def console(*names)
125
132
  servers(*names) do |server|
126
- if server.running?
127
- puts "Not running: #{server.name}"
128
- else
129
- puts server.console_output if server.running?
130
- end
133
+ puts server.console_output
131
134
  end
132
135
  end
133
136
 
data/lib/config.rb CHANGED
@@ -15,7 +15,7 @@ module Judo
15
15
  end
16
16
 
17
17
  def check_version
18
- fail "judo db is newer than the current gem - upgrade judo and try again" if get_db_version > db_version
18
+ abort "judo db is newer than the current gem - upgrade judo and try again" if get_db_version > db_version
19
19
  end
20
20
 
21
21
  def repo_dir
@@ -77,13 +77,12 @@ module Judo
77
77
  end
78
78
 
79
79
  def get_sdb(aws_id, aws_key)
80
- puts "GET SDB #{aws_id} #{aws_key}"
81
80
  Aws::SdbInterface.new(aws_id, aws_key, :logger => Logger.new(nil))
82
81
  end
83
82
 
84
83
  def sdb
85
84
  @sdb ||= get_sdb(access_id, access_secret)
86
- @version_ok ||= check_version
85
+ # @version_ok ||= check_version
87
86
  @sdb
88
87
  end
89
88
 
@@ -92,7 +91,7 @@ module Judo
92
91
  end
93
92
 
94
93
  def s3_url(k)
95
- s3.get_object_url(judo_config["s3_bucket"], k,Time.now.to_i + 100_000_000)
94
+ s3.get_object_url(judo_config["s3_bucket"], k, Time.now.to_i + 100_000_000)
96
95
  end
97
96
 
98
97
  def s3_put(k, file)
data/lib/group.rb CHANGED
@@ -54,7 +54,6 @@ module Judo
54
54
 
55
55
  def version
56
56
  @version ||= (Judo::Config.sdb.get_attributes("judo_config", "group_versions")[:attributes][@name] || ["0"]).first.to_i
57
- @version ||= (Judo::Config.sdb.get_attributes("judo_config", "group_versions")[:attributes][@name] || ["0"]).first.to_i
58
57
  end
59
58
 
60
59
  def set_version(new_version)
@@ -132,7 +131,7 @@ module Judo
132
131
  end
133
132
 
134
133
  def keypair_file
135
- (attachments.select { |a| File.basename(config["keypair"]) }) || fail("no keypair_file specified")
134
+ extract_file(:keypair, config["key_name"] + ".pem" , {}).first
136
135
  end
137
136
 
138
137
  def attachments
data/lib/server.rb CHANGED
@@ -10,8 +10,8 @@
10
10
  ### [X] compile and put in s3
11
11
  ### [X] attach and increment version number
12
12
  ### [X] list version number on "judo list"
13
- ### [ ] update kuzushi to pull down a compiled tar.gz
14
- ### [ ] error if version is blank
13
+ ### [X] update kuzushi to pull down a compiled tar.gz
14
+ ### [X] error if version is blank
15
15
  ### [ ] two phase delete (1 hr)
16
16
  ### [-] refactor availability_zone (2 hrs)
17
17
  ### [ ] pick availability zone from config "X":"Y" or "X":["Y","Z"]
@@ -24,6 +24,10 @@
24
24
  ### [ ] user a logger service (1 hr)
25
25
  ### [ ] write specs (5 hr)
26
26
 
27
+ ### Error Handling
28
+ ### [ ] no availability zone before making disks
29
+ ### [ ] security group does not exists
30
+
27
31
  ### Do Later
28
32
  ### [ ] use amazon's new conditional write tools so we never have problems from concurrent updates
29
33
  ### [ ] is thor really what we want to use here?
@@ -46,33 +50,6 @@ module Judo
46
50
  @group = group
47
51
  end
48
52
 
49
- ### Getting things in and out of SimpleDB - would be nice if it were a plugin so we could use another store if need db (couchdb/mongo/sql)
50
-
51
- def self.migrate
52
- require 'pp'
53
- x = {}
54
- Judo::Config.sdb.delete_domain("judo_servers")
55
- Judo::Config.sdb.create_domain("judo_servers")
56
- Judo::Config.sdb.delete_domain("judo_config")
57
- Judo::Config.sdb.create_domain("judo_config")
58
- Judo::Config.sdb.select("SELECT * FROM sumo_server").items.each do |chunk|
59
- chunk.each do |uid,item|
60
- name = item["name"] || "missing_#{rand(2**32).to_s(36)}"
61
- group = (item["group"] || "default")
62
- data = {
63
- "group" => (item["group"] || "default" ), "name" => name,
64
- "secret" => item["secret"], "elastic_ip" => item["elastic_ip"],
65
- "volumes" => (item["volumes_flat"] || JSON.parse(item["volumes_json"] || "[]").map { |k,v| "#{k}:#{v}" }),
66
- "instance_id" => item["instance_id"], "virgin" => item["virgin"]
67
- }.delete_if { |k,v| v == [] or v == nil or v == [nil] }
68
- pp data
69
- Judo::Config.sdb.put_attributes("judo_servers", name, data, :replace)
70
- Judo::Config.sdb.put_attributes("judo_config", "groups", group => name)
71
- end
72
- end
73
- "ok"
74
- end
75
-
76
53
  def domain
77
54
  "judo_servers"
78
55
  end
@@ -106,7 +83,8 @@ module Judo
106
83
  end
107
84
 
108
85
  def version_desc
109
- if version.to_i == group.version.to_i
86
+ return "" unless running?
87
+ if version == group.version
110
88
  "v#{version}"
111
89
  else
112
90
  "v#{version}/#{group.version}"
@@ -114,7 +92,7 @@ module Judo
114
92
  end
115
93
 
116
94
  def version
117
- get "version"
95
+ get("version").to_i
118
96
  end
119
97
 
120
98
  def virgin?
@@ -192,7 +170,7 @@ module Judo
192
170
  begin
193
171
  if config["elastic_ip"] and not elastic_ip
194
172
  ### EC2 allocate_address
195
- task("Adding an elastic ip") do
173
+ task("Adding an elastic ip") do
196
174
  ip = Judo::Config.ec2.allocate_address
197
175
  add_ip(ip)
198
176
  end
@@ -265,6 +243,7 @@ module Judo
265
243
 
266
244
  def start
267
245
  abort "Already running" if running?
246
+ abort "No config has been commited yet, type 'judo commit'" unless group.version > 0
268
247
  task("Starting server #{name}") { launch_ec2 }
269
248
  task("Acquire hostname") { wait_for_hostname }
270
249
  task("Wait for ssh") { wait_for_ssh }
@@ -290,7 +269,7 @@ module Judo
290
269
  ## EC2 terminate_isntaces
291
270
  task("Terminating instance") { Config.ec2.terminate_instances([ instance_id ]) }
292
271
  task("Wait for volumes to detach") { wait_for_volumes_detached } if volumes.size > 0
293
- remove "instance_id"
272
+ remove "instance_id"
294
273
  end
295
274
 
296
275
  def launch_ec2
@@ -305,7 +284,6 @@ module Judo
305
284
  :user_data => user_data).first
306
285
 
307
286
  update "instance_id" => result[:aws_instance_id], "virgin" => false, "version" => group.version
308
- # remove "virgin"
309
287
  end
310
288
 
311
289
  def security_groups
@@ -313,7 +291,7 @@ module Judo
313
291
  end
314
292
 
315
293
  def console_output
316
- ### EC2 get_console_output
294
+ abort "not running" unless running?
317
295
  Config.ec2.get_console_output(instance_id)[:aws_output]
318
296
  end
319
297
 
@@ -458,12 +436,13 @@ apt-get update
458
436
  apt-get install ruby rubygems ruby-dev irb libopenssl-ruby libreadline-ruby -y
459
437
  gem install kuzushi --no-rdoc --no-ri
460
438
  GEM_BIN=`ruby -r rubygems -e "puts Gem.bindir"`
461
- $GEM_BIN/kuzushi #{virgin? && "init" || "start"} #{url}
439
+ echo "$GEM_BIN/kuzushi #{virgin? && "init" || "start"} '#{url}'" > /var/log/kuzushi.log
440
+ $GEM_BIN/kuzushi #{virgin? && "init" || "start"} '#{url}' >> /var/log/kuzushi.log 2>&1
462
441
  USER_DATA
463
442
  end
464
443
 
465
444
  def url
466
- group.s3_url
445
+ @url ||= group.s3_url
467
446
  end
468
447
 
469
448
  def validate
data/lib/setup.rb CHANGED
@@ -27,14 +27,9 @@ DEFAULT
27
27
  input.empty? and default or input
28
28
  end
29
29
 
30
- def failure(msg)
31
- puts msg
32
- exit 1
33
- end
34
-
35
30
  def check_setup
36
- failure "you are already inside a judo repository" if Judo::Config.find_judo_dir(Dir.pwd)
37
- failure "./.git not found - judo configurations must be kept in a git repo. type 'git init' to setup the git repo." unless File.exists? "./.git"
31
+ abort "you are already inside a judo repository" if Judo::Config.find_judo_dir(Dir.pwd)
32
+ abort "./.git not found - judo configurations must be kept in a git repo. type 'git init' to setup the git repo." unless File.exists? "./.git"
38
33
  end
39
34
 
40
35
  def init
@@ -71,7 +66,7 @@ DEFAULT
71
66
  sdb.create_domain("judo_servers")
72
67
  sdb.create_domain("judo_config")
73
68
  olddb = sdb.get_attributes("judo_config", "judo")[:attributes]["dbversion"]
74
- failure "There is an existing judo database of a newer version - upgrade judo and try again" if olddb and olddb.first.to_i > Judo::Config.db_version
69
+ abort "There is an existing judo database of a newer version - upgrade judo and try again" if olddb and olddb.first.to_i > Judo::Config.db_version
75
70
  sdb.put_attributes("judo_config", "judo", { "dbversion" => Judo::Config.db_version }, :replace)
76
71
  end
77
72
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
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-03-03 00:00:00 -08:00
17
+ date: 2010-03-11 00:00:00 -05:00
18
18
  default_executable: judo
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency