judo 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/bin/judo +14 -0
  3. data/lib/judo/base.rb +18 -6
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.5
data/bin/judo CHANGED
@@ -85,6 +85,16 @@ banner
85
85
  opts.on( '-a', '--accessid ID', 'Specify the AWS access ID' ) do |id|
86
86
  options[:access_id] = id
87
87
  end
88
+ opts.on( '-k', '--keypair KEY', 'Speicy the AWS keypair pem file to use or \'create\'' ) do |key|
89
+ if key == 'create'
90
+ options[:key_create] = true
91
+ elsif File.basename(key) =~ /(.*)[.]pem$/
92
+ options[:key_name] = $1
93
+ options[:key_material] = File.new(key).read
94
+ else
95
+ abort "Key file must be KEY_NAME.pem"
96
+ end
97
+ end
88
98
  opts.on( '-s', '--secret KEY', 'Specify the AWS access secret key' ) do |key|
89
99
  options[:access_secret] = key
90
100
  end
@@ -129,6 +139,10 @@ begin
129
139
  when "create" then mk_servers(judo, options, ARGV)
130
140
  when "launch" then mk_servers(judo, options, ARGV) { |s| s.start(options) }
131
141
  when "snapshots" then do_snapshots(judo, ARGV)
142
+ when "config" then
143
+ puts "Judo DB Version: #{judo.db_version}"
144
+ puts "Judo Keypair: #{judo.key_name}"
145
+ puts "Judo Bucket: #{judo.bucket_name}"
132
146
  when "rename" then
133
147
  raise JudoError, "usage: judo rename SERVER SERVER" unless ARGV.size == 2
134
148
  old,new = ARGV
data/lib/judo/base.rb CHANGED
@@ -34,6 +34,9 @@ module Judo
34
34
  @access_id = options[:access_id]
35
35
  @access_secret = options[:access_secret]
36
36
  @domain = options[:domain]
37
+ @key_name = options[:key_name]
38
+ @key_material = options[:key_material]
39
+ @key_create = options[:key_create]
37
40
  end
38
41
 
39
42
  def volumes
@@ -228,16 +231,18 @@ module Judo
228
231
  end
229
232
 
230
233
  def set_keypair(key_name, material)
234
+ @key_name = key_name
235
+ @key_material = material
231
236
  s3_put("#{key_name}.pem", material)
232
237
  update "key_name" => key_name
233
238
  end
234
239
 
235
240
  def key_name
236
- get("key_name")
241
+ @key_name ||= get("key_name")
237
242
  end
238
243
 
239
244
  def key_material
240
- s3_get("#{key_name}.pem")
245
+ @key_material ||= s3_get("#{key_name}.pem")
241
246
  end
242
247
 
243
248
  def ip_to_judo(ip)
@@ -319,7 +324,7 @@ module Judo
319
324
  set_db_version(2)
320
325
  end
321
326
  else
322
- raise JduoError, "judo db is newer than the current gem - upgrade judo and try again"
327
+ raise JudoError, "judo db is newer than the current gem - upgrade judo and try again"
323
328
  end
324
329
  end
325
330
 
@@ -352,7 +357,7 @@ module Judo
352
357
  upgrade_db
353
358
  end
354
359
 
355
- def setup
360
+ def setup(options = {})
356
361
  @repo ||= "." ## use cwd as default repo dir
357
362
 
358
363
  setup_sdb
@@ -423,17 +428,24 @@ module Judo
423
428
  if name = get("bucket_name")
424
429
  puts "Bucket #{name} already set"
425
430
  else
431
+ puts "Setting bucket name #{bucket_name}"
426
432
  set_bucket_name(bucket_name)
427
433
  end
428
434
  end
429
435
 
430
436
  def setup_keypair
431
- unless key_name
432
- task("Generating an ssl keyapir") do
437
+ if @key_name and @key_material
438
+ task("Setting keypair #{@key_name}") do
439
+ set_keypair(@key_name, @key_material)
440
+ end
441
+ elsif @key_create or not key_name
442
+ task("Generating an ssl keypair") do
433
443
  name = "judo#{ec2.describe_key_pairs.map { |k| k[:aws_key_name] }.map { |k| k =~ /^judo(\d*)/; $1.to_i }.sort.last.to_i + 1}"
434
444
  material = ec2.create_key_pair(name)[:aws_material]
435
445
  set_keypair(name, material)
436
446
  end
447
+ else
448
+ puts "Keypair #{key_name} already set"
437
449
  end
438
450
  end
439
451
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 4
9
- version: 0.3.4
8
+ - 5
9
+ version: 0.3.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Orion Henry