solutious-rudy 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +19 -1
- data/README.rdoc +66 -35
- data/Rakefile +1 -0
- data/Rudyfile +97 -6
- data/bin/ird +7 -4
- data/bin/rudy +120 -212
- data/bin/rudy-ec2 +240 -0
- data/bin/rudy-s3 +76 -0
- data/bin/rudy-sdb +67 -0
- data/lib/annoy.rb +61 -18
- data/lib/console.rb +10 -5
- data/lib/rudy/aws/ec2/address.rb +76 -40
- data/lib/rudy/aws/ec2/group.rb +138 -78
- data/lib/rudy/aws/ec2/image.rb +134 -12
- data/lib/rudy/aws/ec2/instance.rb +116 -89
- data/lib/rudy/aws/ec2/keypair.rb +26 -14
- data/lib/rudy/aws/ec2/snapshot.rb +23 -12
- data/lib/rudy/aws/ec2/volume.rb +198 -202
- data/lib/rudy/aws/ec2/zone.rb +77 -0
- data/lib/rudy/aws/ec2.rb +56 -25
- data/lib/rudy/aws/s3.rb +54 -0
- data/lib/rudy/aws/sdb/error.rb +46 -0
- data/lib/rudy/aws/sdb.rb +298 -0
- data/lib/rudy/aws.rb +29 -57
- data/lib/rudy/{metadata/backup.rb → backup.rb} +8 -8
- data/lib/rudy/cli/aws/ec2/addresses.rb +105 -0
- data/lib/rudy/cli/aws/ec2/candy.rb +208 -0
- data/lib/rudy/cli/aws/ec2/groups.rb +121 -0
- data/lib/rudy/cli/aws/ec2/images.rb +196 -0
- data/lib/rudy/cli/aws/ec2/instances.rb +194 -0
- data/lib/rudy/cli/aws/ec2/keypairs.rb +53 -0
- data/lib/rudy/cli/aws/ec2/snapshots.rb +49 -0
- data/lib/rudy/cli/aws/ec2/volumes.rb +104 -0
- data/lib/rudy/cli/aws/ec2/zones.rb +22 -0
- data/lib/rudy/cli/aws/s3/buckets.rb +50 -0
- data/lib/rudy/cli/aws/s3/store.rb +22 -0
- data/lib/rudy/cli/aws/sdb/domains.rb +41 -0
- data/lib/rudy/cli/{deploy.rb → candy.rb} +2 -6
- data/lib/rudy/cli/config.rb +25 -20
- data/lib/rudy/cli/disks.rb +18 -108
- data/lib/rudy/cli/machines.rb +94 -0
- data/lib/rudy/cli/routines.rb +47 -70
- data/lib/rudy/cli.rb +104 -89
- data/lib/rudy/config/objects.rb +5 -43
- data/lib/rudy/config.rb +8 -24
- data/lib/rudy/disks.rb +248 -0
- data/lib/rudy/global.rb +121 -0
- data/lib/rudy/huxtable.rb +232 -147
- data/lib/rudy/machines.rb +245 -0
- data/lib/rudy/metadata.rb +136 -0
- data/lib/rudy/routines/helpers/diskhelper.rb +101 -0
- data/lib/rudy/routines/helpers/scripthelper.rb +91 -0
- data/lib/rudy/routines/release.rb +27 -8
- data/lib/rudy/routines/shutdown.rb +47 -32
- data/lib/rudy/routines/startup.rb +47 -37
- data/lib/rudy/routines.rb +30 -37
- data/lib/rudy/scm/svn.rb +1 -1
- data/lib/rudy/utils.rb +262 -4
- data/lib/rudy.rb +76 -248
- data/lib/storable.rb +19 -16
- data/lib/sysinfo.rb +1 -1
- data/rudy.gemspec +88 -68
- data/support/rudy-ec2-startup +5 -5
- data/test/05_config/00_setup_test.rb +3 -7
- data/test/20_sdb/00_setup_test.rb +2 -17
- data/test/20_sdb/10_domains_test.rb +18 -16
- data/test/25_ec2/00_setup_test.rb +5 -10
- data/test/25_ec2/10_keypairs_test.rb +13 -5
- data/test/25_ec2/20_groups_test.rb +48 -56
- data/test/25_ec2/30_addresses_test.rb +13 -10
- data/test/25_ec2/40_volumes_test.rb +11 -8
- data/test/25_ec2/50_snapshots_test.rb +17 -12
- data/test/26_ec2_instances/00_setup_test.rb +3 -8
- data/test/26_ec2_instances/10_instances_test.rb +21 -19
- data/test/30_sdb_metadata/00_setup_test.rb +2 -9
- data/test/30_sdb_metadata/10_disks_test.rb +47 -37
- data/test/30_sdb_metadata/20_backups_test.rb +9 -9
- data/test/helper.rb +5 -3
- data/vendor/highline-1.5.1/CHANGELOG +222 -0
- data/vendor/highline-1.5.1/INSTALL +35 -0
- data/vendor/highline-1.5.1/LICENSE +7 -0
- data/vendor/highline-1.5.1/README +63 -0
- data/vendor/highline-1.5.1/Rakefile +82 -0
- data/vendor/highline-1.5.1/TODO +6 -0
- data/vendor/highline-1.5.1/examples/ansi_colors.rb +38 -0
- data/vendor/highline-1.5.1/examples/asking_for_arrays.rb +18 -0
- data/vendor/highline-1.5.1/examples/basic_usage.rb +75 -0
- data/vendor/highline-1.5.1/examples/color_scheme.rb +32 -0
- data/vendor/highline-1.5.1/examples/limit.rb +12 -0
- data/vendor/highline-1.5.1/examples/menus.rb +65 -0
- data/vendor/highline-1.5.1/examples/overwrite.rb +19 -0
- data/vendor/highline-1.5.1/examples/page_and_wrap.rb +322 -0
- data/vendor/highline-1.5.1/examples/password.rb +7 -0
- data/vendor/highline-1.5.1/examples/trapping_eof.rb +22 -0
- data/vendor/highline-1.5.1/examples/using_readline.rb +17 -0
- data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +120 -0
- data/vendor/highline-1.5.1/lib/highline/compatibility.rb +17 -0
- data/vendor/highline-1.5.1/lib/highline/import.rb +43 -0
- data/vendor/highline-1.5.1/lib/highline/menu.rb +395 -0
- data/vendor/highline-1.5.1/lib/highline/question.rb +463 -0
- data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +193 -0
- data/vendor/highline-1.5.1/lib/highline.rb +758 -0
- data/vendor/highline-1.5.1/setup.rb +1360 -0
- data/vendor/highline-1.5.1/test/tc_color_scheme.rb +56 -0
- data/vendor/highline-1.5.1/test/tc_highline.rb +823 -0
- data/vendor/highline-1.5.1/test/tc_import.rb +54 -0
- data/vendor/highline-1.5.1/test/tc_menu.rb +429 -0
- data/vendor/highline-1.5.1/test/ts_all.rb +15 -0
- metadata +81 -69
- data/lib/aws_sdb/error.rb +0 -42
- data/lib/aws_sdb/service.rb +0 -215
- data/lib/aws_sdb.rb +0 -3
- data/lib/rudy/aws/simpledb.rb +0 -71
- data/lib/rudy/cli/addresses.rb +0 -85
- data/lib/rudy/cli/backups.rb +0 -175
- data/lib/rudy/cli/domains.rb +0 -17
- data/lib/rudy/cli/groups.rb +0 -77
- data/lib/rudy/cli/images.rb +0 -111
- data/lib/rudy/cli/instances.rb +0 -142
- data/lib/rudy/cli/keypairs.rb +0 -47
- data/lib/rudy/cli/manager.rb +0 -51
- data/lib/rudy/cli/release.rb +0 -174
- data/lib/rudy/cli/volumes.rb +0 -121
- data/lib/rudy/command/addresses.rb +0 -69
- data/lib/rudy/command/backups.rb +0 -65
- data/lib/rudy/command/disks-old.rb +0 -322
- data/lib/rudy/command/disks.rb +0 -9
- data/lib/rudy/command/domains.rb +0 -34
- data/lib/rudy/command/groups.rb +0 -118
- data/lib/rudy/command/instances.rb +0 -278
- data/lib/rudy/command/keypairs.rb +0 -149
- data/lib/rudy/command/manager.rb +0 -65
- data/lib/rudy/command/volumes.rb +0 -127
- data/lib/rudy/metadata/disk.rb +0 -149
- data/lib/rudy/metadata/machine.rb +0 -34
- data/lib/rudy/routines/disk_handler.rb +0 -190
- data/lib/rudy/routines/script_runner.rb +0 -65
- data/test/50_commands/00_setup_test.rb +0 -11
- data/test/50_commands/10_keypairs_test.rb +0 -79
- data/test/50_commands/20_groups_test.rb +0 -77
- data/test/50_commands/40_volumes_test.rb +0 -55
- data/test/50_commands/50_instances_test.rb +0 -110
- data/tryouts/console_tryout.rb +0 -91
- data/tryouts/disks.rb +0 -55
- data/tryouts/nested_methods.rb +0 -36
- data/tryouts/session_tryout.rb +0 -46
data/lib/rudy/cli/release.rb
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Rudy
|
4
|
-
module CLI
|
5
|
-
class Release < Rudy::CLI::Base
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def release_valid?
|
11
|
-
|
12
|
-
relroutine = @config.routines.find_deferred(@global.environment, @global.role, :release)
|
13
|
-
raise "No release routines defined for #{machine_group}" if relroutine.nil?
|
14
|
-
|
15
|
-
raise "No EC2 .pem keys provided" unless has_pem_keys?
|
16
|
-
raise "No SSH key provided for #{@global.user} in #{machine_group}!" unless has_keypair?
|
17
|
-
raise "No SSH key provided for root in #{machine_group}!" unless has_keypair?(:root)
|
18
|
-
|
19
|
-
@list = @ec2.instances.list(machine_group)
|
20
|
-
unless @list.empty?
|
21
|
-
msg = "#{machine_group} is in use, probably with another release. #{$/}"
|
22
|
-
msg << 'Sort it out and run "rudy shutdown" before continuing.'
|
23
|
-
raise msg
|
24
|
-
end
|
25
|
-
|
26
|
-
@scm, @scm_params = find_scm(:release)
|
27
|
-
|
28
|
-
raise "No SCM defined for release routine" unless @scm
|
29
|
-
raise "#{Dir.pwd} is not a working copy" unless @scm.working_copy?(Dir.pwd)
|
30
|
-
raise "There are local changes. Please revert or check them in." unless @scm.everything_checked_in?
|
31
|
-
raise "Invalid base URI (#{@scm_params[:base]})." unless @scm.valid_uri?(@scm_params[:base])
|
32
|
-
|
33
|
-
true
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
def rerelease_valid?
|
39
|
-
relroutine = @config.routines.find_deferred(@global.environment, @global.role, :rerelease)
|
40
|
-
raise "No rerelease routines defined for #{machine_group}" if relroutine.nil?
|
41
|
-
|
42
|
-
raise "No EC2 .pem keys provided" unless has_pem_keys?
|
43
|
-
raise "No SSH key provided for #{@global.user} in #{machine_group}!" unless has_keypair?
|
44
|
-
raise "No SSH key provided for root in #{machine_group}!" unless has_keypair?(:root)
|
45
|
-
|
46
|
-
@list = @ec2.instances.list(machine_group)
|
47
|
-
if @list.empty?
|
48
|
-
msg = "There are no machines running in #{machine_group}. #{$/}"
|
49
|
-
msg << 'You must run "rudy release" before you can rerelease.'
|
50
|
-
raise msg
|
51
|
-
end
|
52
|
-
|
53
|
-
@scm, @scm_params = find_scm(:rerelease)
|
54
|
-
|
55
|
-
raise "No SCM defined for release routine" unless @scm
|
56
|
-
raise "#{Dir.pwd} is not a working copy" unless @scm.working_copy?(Dir.pwd)
|
57
|
-
raise "There are local changes. Please revert or check them in." unless @scm.everything_checked_in?
|
58
|
-
raise "Invalid base URI (#{@scm_params[:base]})." unless @scm.valid_uri?(@scm_params[:base])
|
59
|
-
|
60
|
-
true
|
61
|
-
end
|
62
|
-
|
63
|
-
def rerelease
|
64
|
-
puts "Updating release from working copy".bright
|
65
|
-
|
66
|
-
tag, revision = @scm.local_info
|
67
|
-
puts "tag: #{tag}"
|
68
|
-
puts "rev: #{revision}"
|
69
|
-
|
70
|
-
execute_disk_routines(@list.values, :rerelease)
|
71
|
-
|
72
|
-
if @scm
|
73
|
-
|
74
|
-
puts "Running SCM command".bright
|
75
|
-
ssh do |session|
|
76
|
-
cmd = "svn #{@scm_params[:command]}"
|
77
|
-
puts "#{cmd}"
|
78
|
-
session.exec!("cd #{@scm_params[:path]}")
|
79
|
-
session.exec!(cmd)
|
80
|
-
puts "#{@scm_params[:command]} complete"
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
execute_routines(@list.values, :rerelease, :after)
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
# <li>Creates a release tag based on the working copy on your machine</li>
|
90
|
-
# <li>Starts a new stage instance</li>
|
91
|
-
# <li>Executes release routines</li>
|
92
|
-
def release
|
93
|
-
# TODO: store metadata about release with local username and hostname
|
94
|
-
puts "Creating release from working copy".bright
|
95
|
-
|
96
|
-
exit unless Annoy.are_you_sure?(:low)
|
97
|
-
|
98
|
-
tag = @scm.create_release(@global.local_user, @option.msg)
|
99
|
-
puts "Done! (#{tag})"
|
100
|
-
|
101
|
-
if @option.switch
|
102
|
-
puts "Switching working copy to new tag".bright
|
103
|
-
@scm.switch_working_copy(tag)
|
104
|
-
end
|
105
|
-
|
106
|
-
@option.image ||= machine_image
|
107
|
-
|
108
|
-
switch_user("root")
|
109
|
-
|
110
|
-
puts "Starting #{machine_group}".bright
|
111
|
-
|
112
|
-
instances = @ec2.instances.create(@option.image, machine_group.to_s, File.basename(keypairpath), machine_data.to_yaml, @global.zone)
|
113
|
-
inst = instances.first
|
114
|
-
|
115
|
-
if @option.address ||= machine_address
|
116
|
-
puts "Associating #{@option.address} to #{inst[:aws_instance_id]}".bright
|
117
|
-
@ec2.addresses.associate(inst[:aws_instance_id], @option.address)
|
118
|
-
end
|
119
|
-
|
120
|
-
wait_for_machine(inst[:aws_instance_id])
|
121
|
-
inst = @ec2.instances.get(inst[:aws_instance_id])
|
122
|
-
|
123
|
-
#inst = @ec2.instances.list(machine_group).values
|
124
|
-
|
125
|
-
|
126
|
-
execute_disk_routines(inst, :release)
|
127
|
-
|
128
|
-
if @scm
|
129
|
-
|
130
|
-
puts "Running SCM command".bright
|
131
|
-
ssh do |session|
|
132
|
-
cmd = "svn #{@scm_params[:command]} #{tag} #{@scm_params[:path]}"
|
133
|
-
puts "#{cmd}"
|
134
|
-
session.exec!(cmd)
|
135
|
-
puts "#{@scm_params[:command]} complete"
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
execute_routines(inst, :release, :after)
|
141
|
-
|
142
|
-
print_instance inst
|
143
|
-
|
144
|
-
puts "Done!"
|
145
|
-
end
|
146
|
-
|
147
|
-
|
148
|
-
def find_scm(routine)
|
149
|
-
env, rol, att = @global.environment, @global.role
|
150
|
-
|
151
|
-
# Look for the source control engine, checking all known scm values.
|
152
|
-
# The available one will look like [environment][role][release][svn]
|
153
|
-
params = nil
|
154
|
-
scm_name = nil
|
155
|
-
SUPPORTED_SCM_NAMES.each do |v|
|
156
|
-
scm_name = v
|
157
|
-
params = @config.routines.find(env, rol, routine, scm_name)
|
158
|
-
break if params
|
159
|
-
end
|
160
|
-
|
161
|
-
if params
|
162
|
-
klass = eval "Rudy::SCM::#{scm_name.to_s.upcase}"
|
163
|
-
scm = klass.new(:base => params[:base])
|
164
|
-
end
|
165
|
-
|
166
|
-
[scm, params]
|
167
|
-
|
168
|
-
end
|
169
|
-
private :find_scm
|
170
|
-
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
data/lib/rudy/cli/volumes.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Rudy
|
4
|
-
module CLI
|
5
|
-
class Volumes < Rudy::CLI::Base
|
6
|
-
|
7
|
-
|
8
|
-
def destroy_volume_valid?
|
9
|
-
raise "You must supply a volume ID. See rudy volume -h" unless @argv.volid
|
10
|
-
|
11
|
-
@rvol = Rudy::Volumes.new(:config => @config, :global => @global)
|
12
|
-
|
13
|
-
@volume = @rvol.get(@argv.volid)
|
14
|
-
|
15
|
-
raise "Volume #{@argv.volid} does not exist" unless @volume
|
16
|
-
|
17
|
-
raise "Volume #{@argv.volid} is still in-use" if @volume.in_use?
|
18
|
-
raise "Volume #{@argv.volid} is still attached" if @volume.attached?
|
19
|
-
|
20
|
-
true
|
21
|
-
end
|
22
|
-
|
23
|
-
def destroy_volume
|
24
|
-
puts "Destroy Volume".bright, $/
|
25
|
-
|
26
|
-
puts "Destroying #{@volume.awsid}"
|
27
|
-
exit unless Annoy.are_you_sure?(:medium)
|
28
|
-
|
29
|
-
ret = @rvol.destroy(@volume.awsid)
|
30
|
-
raise "Failed" unless ret
|
31
|
-
|
32
|
-
vol = @rvol.get(@volume.awsid)
|
33
|
-
|
34
|
-
puts vol.to_s
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
def volume_create_valid?
|
39
|
-
raise "You must supply a volume size. See rudy volume -h" unless @option.size
|
40
|
-
raise "You have no zone configured. Check #{RUDY_CONFIG_FILE}." unless @global.zone
|
41
|
-
true
|
42
|
-
end
|
43
|
-
def volume_create
|
44
|
-
puts "Create Volume".bright
|
45
|
-
|
46
|
-
exit unless Annoy.are_you_sure?(:medium)
|
47
|
-
|
48
|
-
rvol = Rudy::Volumes.new(:config => @config, :global => @global)
|
49
|
-
vol = rvol.create(@option.size, @global.zone, @option.snapshot)
|
50
|
-
|
51
|
-
puts vol.to_s
|
52
|
-
end
|
53
|
-
|
54
|
-
def volume_attach_valid?
|
55
|
-
raise "You must supply a volume ID. See rudy volume -h" unless @argv.volid
|
56
|
-
raise "You must supply an instance ID. See rudy volume -h" unless @argv.instid
|
57
|
-
|
58
|
-
@rvol = Rudy::Volumes.new(:config => @config, :global => @global)
|
59
|
-
@rmach = Rudy::Instances.new(:config => @config, :global => @global)
|
60
|
-
raise "Volume #{@argv.volid} does not exist" unless @rvol.exists?(@argv.volid)
|
61
|
-
raise "Instance #{@argv.instid} does not exist" unless @rmach.exists?(@argv.instid)
|
62
|
-
|
63
|
-
true
|
64
|
-
end
|
65
|
-
def volume_attach
|
66
|
-
puts "Attach Volume".bright, $/
|
67
|
-
|
68
|
-
@option.device ||= "/dev/sdh"
|
69
|
-
|
70
|
-
puts "Attaching #{@argv.volid} to #{@argv.instid} on #{@option.device}"
|
71
|
-
exit unless Annoy.are_you_sure?(:low)
|
72
|
-
|
73
|
-
ret = @rvol.attach(@argv.volid, @argv.instid, @option.device)
|
74
|
-
raise "Attach failed" unless ret
|
75
|
-
volume = @rvol.get(@argv.volid)
|
76
|
-
puts volume.to_s
|
77
|
-
end
|
78
|
-
|
79
|
-
def volume_detach_valid?
|
80
|
-
raise "You must supply a volume ID. See rudy volume -h" unless @argv.volid
|
81
|
-
|
82
|
-
@rvol = Rudy::Volumes.new(:config => @config, :global => @global)
|
83
|
-
|
84
|
-
@volume = @rvol.get(@argv.volid)
|
85
|
-
|
86
|
-
raise "Volume #{@argv.volid} does not exist" unless @volume
|
87
|
-
|
88
|
-
#raise "Volume #{@argv.volid} is in use" unless @volume.in_use?
|
89
|
-
raise "Volume #{@argv.volid} is not attached" unless @volume.attached?
|
90
|
-
|
91
|
-
true
|
92
|
-
end
|
93
|
-
def volume_detach
|
94
|
-
puts "Detach Volume".bright, $/
|
95
|
-
|
96
|
-
puts "Detaching #{@volume.awsid} from #{@volume.instid}"
|
97
|
-
exit unless Annoy.are_you_sure?(:low)
|
98
|
-
|
99
|
-
ret = @rvol.detach(@volume.awsid)
|
100
|
-
raise "Detach failed" unless ret
|
101
|
-
volume = @rvol.get(@volume.awsid)
|
102
|
-
puts volume.to_s
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
def volume
|
107
|
-
puts "Volumes".bright, $/
|
108
|
-
|
109
|
-
rvol = Rudy::Volumes.new(:config => @config, :global => @global)
|
110
|
-
volumes = rvol.list || []
|
111
|
-
volumes.each do |volume|
|
112
|
-
puts '-'*60
|
113
|
-
puts volume.to_s
|
114
|
-
end
|
115
|
-
puts "No volumes" if volumes.empty?
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
@@ -1,69 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Rudy
|
4
|
-
class Addresses
|
5
|
-
include Rudy::Huxtable
|
6
|
-
|
7
|
-
def create
|
8
|
-
address = @@ec2.addresses.create
|
9
|
-
raise ErrorCreatingAddress unless address.is_a?(Rudy::AWS::EC2::Address)
|
10
|
-
address
|
11
|
-
end
|
12
|
-
|
13
|
-
def destroy(address)
|
14
|
-
address = address
|
15
|
-
@@ec2.addresses.destroy(address)
|
16
|
-
end
|
17
|
-
|
18
|
-
def assign(address, instance)
|
19
|
-
raise "Not an instance object" unless instance.is_a?(Rudy::AWS::EC2::Instance)
|
20
|
-
raise "Address not available for this account" unless @@ec2.addresses.valid?(address)
|
21
|
-
@@ec2.addresses.associate(instance.awsid, address)
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
# Lists the addresses registered with Amazon
|
26
|
-
def list(n=nil, &each_object)
|
27
|
-
n = [n].flatten.compact
|
28
|
-
addresses = @@ec2.addresses.list(n)
|
29
|
-
addresses.each { |n,kp| each_object.call(kp) } if each_object
|
30
|
-
addresses || []
|
31
|
-
end
|
32
|
-
|
33
|
-
def get(n=nil)
|
34
|
-
raise "Address cannot be nil" if n.nil?
|
35
|
-
@@ec2.addresses.get(n)
|
36
|
-
end
|
37
|
-
|
38
|
-
def associated?(n=nil)
|
39
|
-
raise "Address cannot be nil" if n.nil?
|
40
|
-
@@ec2.addresses.associated?(n)
|
41
|
-
end
|
42
|
-
|
43
|
-
def list_as_hash(n=nil, &each_object)
|
44
|
-
n &&= [n].flatten.compact
|
45
|
-
addresses = @@ec2.addresses.list_as_hash(n)
|
46
|
-
addresses.each_pair { |n,kp| each_object.call(kp) } if each_object
|
47
|
-
addresses || {}
|
48
|
-
end
|
49
|
-
|
50
|
-
def exists?(n=nil)
|
51
|
-
n ||= name(n)
|
52
|
-
@@ec2.addresses.exists?(n)
|
53
|
-
end
|
54
|
-
|
55
|
-
def any?(n=nil)
|
56
|
-
n ||= name(n)
|
57
|
-
@@ec2.addresses.any?
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
module Rudy
|
66
|
-
class Addresses
|
67
|
-
class ErrorCreatingAddress < RuntimeError; end
|
68
|
-
end
|
69
|
-
end
|
data/lib/rudy/command/backups.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Rudy
|
4
|
-
class Backups
|
5
|
-
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
__END__
|
11
|
-
|
12
|
-
|
13
|
-
# From Rudy::MetaData::Backup
|
14
|
-
|
15
|
-
def Backup.for_disk(sdb, disk, max=50)
|
16
|
-
list = Backup.list(sdb, disk.zone, disk.environment, disk.role, disk.position, disk.path) || []
|
17
|
-
list[0..(max-1)]
|
18
|
-
end
|
19
|
-
|
20
|
-
def Backup.get(sdb, name)
|
21
|
-
object = sdb.get_attributes(RUDY_DOMAIN, name)
|
22
|
-
raise "Object #{name} does not exist!" unless object.has_key?(:attributes) && !object[:attributes].empty?
|
23
|
-
self.from_hash(object[:attributes])
|
24
|
-
end
|
25
|
-
|
26
|
-
def Backup.save(sdb, obj, replace = :replace)
|
27
|
-
sdb.store(RUDY_DOMAIN, obj.name, obj.to_hash, replace)
|
28
|
-
end
|
29
|
-
|
30
|
-
def Backup.list(sdb, zon, env=nil, rol=nil, pos=nil, path=nil, date=nil)
|
31
|
-
query = "select * from #{RUDY_DOMAIN} where "
|
32
|
-
query << "rtype = '#{rtype}' "
|
33
|
-
query << " and zone = '#{zon}'" if zon
|
34
|
-
query << " and environment = '#{env}'" if env
|
35
|
-
query << " and role = '#{rol}'" if rol
|
36
|
-
query << " and position = '#{pos}'" if pos
|
37
|
-
query << " and path = '#{path}'" if path
|
38
|
-
query << " and date = '#{date}'" if date
|
39
|
-
query << " and unixtime != '0' order by unixtime desc"
|
40
|
-
list = []
|
41
|
-
sdb.select(query).each do |obj|
|
42
|
-
list << self.from_hash(obj)
|
43
|
-
end
|
44
|
-
list
|
45
|
-
end
|
46
|
-
|
47
|
-
def Backup.find_most_recent(zon, env, rol, pos, path)
|
48
|
-
criteria = [zon, env, rol, pos, path]
|
49
|
-
(Rudy::MetaData::Backup.list(@sdb, *criteria) || []).first
|
50
|
-
end
|
51
|
-
|
52
|
-
def Backup.destroy(sdb, name)
|
53
|
-
back = Backup.get(sdb, name) # get raises an exception if the disk doesn't exist
|
54
|
-
sdb.destroy(RUDY_DOMAIN, name)
|
55
|
-
true # wtf: RightAws::SimpleDB doesn't tell us whether it succeeds. We'll assume!
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def Backup.is_defined?(sdb, backup)
|
61
|
-
query = backup.to_query()
|
62
|
-
puts query
|
63
|
-
!sdb.select(query).empty?
|
64
|
-
end
|
65
|
-
|