judo 0.2.0 → 0.2.1
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.
- data/TODO +2 -2
- data/VERSION +1 -1
- data/bin/judo +11 -2
- data/lib/judo/base.rb +8 -5
- data/lib/judo/commandline_helpers.rb +1 -1
- data/lib/judo/server.rb +20 -3
- data/lib/judo/snapshot.rb +4 -4
- metadata +2 -2
data/TODO
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
### NEEDED for new gem launch
|
|
2
2
|
|
|
3
|
-
### [ ]
|
|
3
|
+
### [ ] snapshot complete in do_snapshots()
|
|
4
4
|
### [ ] judo swap (x) (y) -> swaps elastic IP's and name
|
|
5
|
-
### [ ]
|
|
5
|
+
### [ ] snapshots/init/virgin
|
|
6
6
|
|
|
7
7
|
### [ ] judo does not work with ruby 1.8.6 - :(
|
|
8
8
|
### [ ] saw a timeout on volume allocation - make sure we build in re-tries - need to allocate the server all together as much as possible
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.1
|
data/bin/judo
CHANGED
|
@@ -35,6 +35,8 @@ Usage: judo launch [options] SERVER ...
|
|
|
35
35
|
judo clone [options] SNAPSHOT SERVER ## create a new server from a snapshot
|
|
36
36
|
judo erase [options] SNAPSHOT ## erase an old snapshot
|
|
37
37
|
|
|
38
|
+
judo swapip [options] SERVER SERVER ## swap elastic IP's on the two servers
|
|
39
|
+
|
|
38
40
|
judo info [options] [SERVER ...]
|
|
39
41
|
judo console [options] [SERVER ...] ## shows AWS console output
|
|
40
42
|
judo ssh [options] [SERVER ...] ## ssh's into the server
|
|
@@ -76,6 +78,9 @@ banner
|
|
|
76
78
|
opts.on( '-g', '--group GROUP', 'Specify the default group of the repo dir' ) do |group|
|
|
77
79
|
options[:group] = group
|
|
78
80
|
end
|
|
81
|
+
opts.on( '-n', '--note NOTE', 'Add a note to a server as you create or launch it') do |note|
|
|
82
|
+
options[:note] = note
|
|
83
|
+
end
|
|
79
84
|
opts.on( '-v', '--version VERSION', 'Update the servers config version on create/start/launch' ) do |version|
|
|
80
85
|
options[:version] = version
|
|
81
86
|
end
|
|
@@ -103,9 +108,13 @@ begin
|
|
|
103
108
|
when "start" then find_servers(judo, ARGV) { |s| s.start(options[:version]) }
|
|
104
109
|
when "restart" then find_servers(judo, ARGV) { |s| s.restart(options[:force]) }
|
|
105
110
|
when "stop" then find_servers(judo, ARGV) { |s| s.stop(options[:force]) }
|
|
106
|
-
when "create" then mk_servers(judo, ARGV) { |s| s.create(
|
|
107
|
-
when "launch" then mk_servers(judo, ARGV) { |s| s.create(
|
|
111
|
+
when "create" then mk_servers(judo, ARGV) { |s| s.create(options) }
|
|
112
|
+
when "launch" then mk_servers(judo, ARGV) { |s| s.create(options); s.start }
|
|
108
113
|
when "snapshots" then do_snapshots(judo, ARGV)
|
|
114
|
+
when "swapip" then
|
|
115
|
+
servers = find_servers(judo, ARGV)
|
|
116
|
+
raise JudoError, "usage: judo swapip SERVER SERVER" unless servers.size == 2
|
|
117
|
+
servers[0].swapip(servers[1])
|
|
109
118
|
when "erase" then
|
|
110
119
|
raise JudoError, "usage: judo erase SNAPSHOT" unless ARGV.size == 1
|
|
111
120
|
snapshot_name = ARGV.shift
|
data/lib/judo/base.rb
CHANGED
|
@@ -68,13 +68,16 @@ module Judo
|
|
|
68
68
|
:judo_dir => dir,
|
|
69
69
|
:group => group_config ? File.basename(File.dirname(group_config)) : nil,
|
|
70
70
|
:repo => repo_dir,
|
|
71
|
-
:bucket => config["s3_bucket"],
|
|
72
|
-
:access_id => config["access_id"],
|
|
73
|
-
:access_secret => config["access_secret"]
|
|
71
|
+
:bucket => (config["s3_bucket"] || ENV['JUDO_BUCKET']),
|
|
72
|
+
:access_id => (config["access_id"] || ENV['AWS_ACCESS_KEY_ID']),
|
|
73
|
+
:access_secret => (config["access_secret"] || ENV['AWS_SECRET_ACCESS_KEY'])
|
|
74
74
|
}.delete_if { |key,value| value.nil? }
|
|
75
75
|
rescue Object => e
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
{
|
|
77
|
+
:access_id => ENV['AWS_ACCESS_KEY_ID'],
|
|
78
|
+
:access_secret => ENV['AWS_SECRET_ACCESS_KEY'],
|
|
79
|
+
:bucket => ENV['JUDO_BUCKET']
|
|
80
|
+
}.delete_if { |key,value| value.nil? }
|
|
78
81
|
end
|
|
79
82
|
|
|
80
83
|
def self.find_judo_dir(check)
|
data/lib/judo/server.rb
CHANGED
|
@@ -171,7 +171,7 @@ module Judo
|
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
def clone_snapshots(snapshots)
|
|
174
|
-
snapshots.each do |device,snap_id|
|
|
174
|
+
snapshots.each do |device,snap_id|
|
|
175
175
|
task("Creating EC2 Volume #{device} from #{snap_id}") do
|
|
176
176
|
volume_id = @base.ec2.create_volume(snap_id, nil, config["availability_zone"])[:aws_id]
|
|
177
177
|
add_volume(volume_id, device)
|
|
@@ -303,7 +303,7 @@ module Judo
|
|
|
303
303
|
end
|
|
304
304
|
|
|
305
305
|
def force_detach_volumes
|
|
306
|
-
volumes.each do |device,volume_id|
|
|
306
|
+
volumes.each do |device,volume_id|
|
|
307
307
|
task("Force detaching #{volume_id}") do
|
|
308
308
|
@base.ec2.detach_volume(volume_id, instance_id, device, true) rescue nil
|
|
309
309
|
end
|
|
@@ -382,7 +382,7 @@ module Judo
|
|
|
382
382
|
|
|
383
383
|
def wait_for_volumes_detached
|
|
384
384
|
begin
|
|
385
|
-
Timeout::timeout(
|
|
385
|
+
Timeout::timeout(60) do
|
|
386
386
|
loop do
|
|
387
387
|
break if ec2_volumes.reject { |v| v[:aws_status] == "available" }.empty?
|
|
388
388
|
sleep 2
|
|
@@ -540,6 +540,23 @@ USER_DATA
|
|
|
540
540
|
snap.create
|
|
541
541
|
end
|
|
542
542
|
|
|
543
|
+
def swapip(other)
|
|
544
|
+
ip1 = elastic_ip
|
|
545
|
+
ip2 = other.elastic_ip
|
|
546
|
+
raise JudoError, "Server must have an elastic IP to swap" unless ip1 and ip2
|
|
547
|
+
|
|
548
|
+
task("Swapping Ip Addresses") do
|
|
549
|
+
@base.ec2.disassociate_address(ip1)
|
|
550
|
+
@base.ec2.disassociate_address(ip2)
|
|
551
|
+
|
|
552
|
+
@base.ec2.associate_address(instance_id, ip2)
|
|
553
|
+
@base.ec2.associate_address(other.instance_id, ip1)
|
|
554
|
+
|
|
555
|
+
update "elastic_ip" => ip2
|
|
556
|
+
other.update "elastic_ip" => ip1
|
|
557
|
+
end
|
|
558
|
+
end
|
|
559
|
+
|
|
543
560
|
def <=>(s)
|
|
544
561
|
[group.name, name] <=> [s.group.name, s.name]
|
|
545
562
|
end
|
data/lib/judo/snapshot.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Judo
|
|
2
2
|
class Snapshot
|
|
3
|
-
attr_accessor :name, :server_name
|
|
3
|
+
attr_accessor :name, :server_name
|
|
4
4
|
|
|
5
5
|
def self.domain
|
|
6
6
|
"judo_snapshots"
|
|
@@ -39,7 +39,7 @@ module Judo
|
|
|
39
39
|
def create
|
|
40
40
|
raise JudoError,"snapshot already exists" unless state.empty?
|
|
41
41
|
raise JudoError,"server has no disks to clone: #{server.volumes}" if server.volumes.empty?
|
|
42
|
-
task("Snapshotting #{server.name}") do
|
|
42
|
+
@base.task("Snapshotting #{server.name}") do
|
|
43
43
|
devs = server.volumes.map do |dev,vol|
|
|
44
44
|
"#{dev}:#{@base.ec2.create_snapshot(vol)[:aws_id]}"
|
|
45
45
|
end
|
|
@@ -66,9 +66,9 @@ module Judo
|
|
|
66
66
|
|
|
67
67
|
def destroy
|
|
68
68
|
devs.each do |dev,snapshot_id|
|
|
69
|
-
task("Deleting
|
|
69
|
+
@base.task("Deleting snapshot #{snapshot_id}") do
|
|
70
70
|
begin
|
|
71
|
-
@base.ec2.delete_snapshot(snapshot_id)
|
|
71
|
+
@base.ec2.delete_snapshot(snapshot_id)
|
|
72
72
|
rescue Object => e
|
|
73
73
|
puts "Error destrotying snapshot #{e.message}"
|
|
74
74
|
end
|