rudy 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +28 -5
- data/README.rdoc +1 -1
- data/Rudyfile +51 -19
- data/bin/ird +153 -0
- data/bin/rudy +18 -23
- data/bin/rudy-ec2 +5 -10
- data/bin/rudy-s3 +1 -3
- data/bin/rudy-sdb +0 -2
- data/examples/README.md +10 -0
- data/examples/debian-sinatra-passenger/commands.rb +19 -0
- data/examples/debian-sinatra-passenger/machines.rb +32 -0
- data/examples/debian-sinatra-passenger/routines.rb +30 -0
- data/examples/debian-sinatra-thin/commands.rb +17 -0
- data/examples/debian-sinatra-thin/machines.rb +35 -0
- data/examples/debian-sinatra-thin/routines.rb +72 -0
- data/lib/rudy.rb +8 -17
- data/lib/rudy/aws.rb +1 -2
- data/lib/rudy/aws/ec2/address.rb +0 -1
- data/lib/rudy/aws/ec2/snapshot.rb +11 -0
- data/lib/rudy/aws/s3.rb +6 -3
- data/lib/rudy/cli.rb +12 -2
- data/lib/rudy/cli/aws/ec2/candy.rb +19 -48
- data/lib/rudy/cli/aws/ec2/images.rb +109 -122
- data/lib/rudy/cli/aws/s3/buckets.rb +1 -2
- data/lib/rudy/cli/config.rb +13 -0
- data/lib/rudy/cli/disks.rb +24 -1
- data/lib/rudy/cli/routines.rb +10 -11
- data/lib/rudy/config.rb +6 -9
- data/lib/rudy/config/objects.rb +4 -0
- data/lib/rudy/global.rb +4 -5
- data/lib/rudy/huxtable.rb +23 -8
- data/lib/rudy/machines.rb +11 -4
- data/lib/rudy/metadata.rb +8 -94
- data/lib/rudy/metadata/backup.rb +113 -0
- data/lib/rudy/metadata/backups.rb +65 -0
- data/lib/rudy/{disks.rb → metadata/disk.rb} +36 -69
- data/lib/rudy/metadata/disks.rb +67 -0
- data/lib/rudy/metadata/objectbase.rb +104 -0
- data/lib/rudy/mixins.rb +2 -0
- data/lib/rudy/routines.rb +173 -88
- data/lib/rudy/routines/helpers/dependshelper.rb +34 -0
- data/lib/rudy/routines/helpers/diskhelper.rb +174 -5
- data/lib/rudy/routines/helpers/scmhelper.rb +2 -2
- data/lib/rudy/routines/helpers/scripthelper.rb +11 -4
- data/lib/rudy/routines/passthrough.rb +3 -1
- data/lib/rudy/routines/reboot.rb +75 -0
- data/lib/rudy/routines/startup.rb +3 -3
- data/lib/rudy/scm/git.rb +17 -17
- data/lib/rudy/scm/svn.rb +46 -5
- data/lib/rudy/utils.rb +3 -2
- data/rudy.gemspec +24 -46
- data/test/30_sdb_metadata/10_disks_test.rb +5 -5
- metadata +36 -68
- data/lib/annoy.rb +0 -298
- data/lib/console.rb +0 -404
- data/lib/escape.rb +0 -305
- data/lib/rudy/backup.rb +0 -135
- data/lib/storable.rb +0 -292
- data/lib/sysinfo.rb +0 -285
- data/lib/tryouts.rb +0 -33
- data/vendor/highline-1.5.1/CHANGELOG +0 -222
- data/vendor/highline-1.5.1/INSTALL +0 -35
- data/vendor/highline-1.5.1/LICENSE +0 -7
- data/vendor/highline-1.5.1/README +0 -63
- data/vendor/highline-1.5.1/Rakefile +0 -82
- data/vendor/highline-1.5.1/TODO +0 -6
- data/vendor/highline-1.5.1/examples/ansi_colors.rb +0 -38
- data/vendor/highline-1.5.1/examples/asking_for_arrays.rb +0 -18
- data/vendor/highline-1.5.1/examples/basic_usage.rb +0 -75
- data/vendor/highline-1.5.1/examples/color_scheme.rb +0 -32
- data/vendor/highline-1.5.1/examples/limit.rb +0 -12
- data/vendor/highline-1.5.1/examples/menus.rb +0 -65
- data/vendor/highline-1.5.1/examples/overwrite.rb +0 -19
- data/vendor/highline-1.5.1/examples/page_and_wrap.rb +0 -322
- data/vendor/highline-1.5.1/examples/password.rb +0 -7
- data/vendor/highline-1.5.1/examples/trapping_eof.rb +0 -22
- data/vendor/highline-1.5.1/examples/using_readline.rb +0 -17
- data/vendor/highline-1.5.1/lib/highline.rb +0 -758
- data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +0 -120
- data/vendor/highline-1.5.1/lib/highline/compatibility.rb +0 -17
- data/vendor/highline-1.5.1/lib/highline/import.rb +0 -43
- data/vendor/highline-1.5.1/lib/highline/menu.rb +0 -395
- data/vendor/highline-1.5.1/lib/highline/question.rb +0 -463
- data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +0 -193
- data/vendor/highline-1.5.1/setup.rb +0 -1360
- data/vendor/highline-1.5.1/test/tc_color_scheme.rb +0 -56
- data/vendor/highline-1.5.1/test/tc_highline.rb +0 -823
- data/vendor/highline-1.5.1/test/tc_import.rb +0 -54
- data/vendor/highline-1.5.1/test/tc_menu.rb +0 -429
- data/vendor/highline-1.5.1/test/ts_all.rb +0 -15
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
module Rudy; module Routines;
|
3
|
+
module DependsHelper
|
4
|
+
include Rudy::Routines::HelperBase # TODO: use execute_rbox_command
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def has_depends?(timing, routine)
|
8
|
+
(!routine.is_a?(Caesars::Hash) || routine[timing].is_a?(Caesars::Hash))
|
9
|
+
end
|
10
|
+
|
11
|
+
# Returns an Array of the dependent routines for the given +timing+ (before/after)
|
12
|
+
def get(timing, routine)
|
13
|
+
return if !(routine.is_a?(Caesars::Hash) || routine[timing].is_a?(Caesars::Hash))
|
14
|
+
|
15
|
+
# This will produce an Array containing the routines to run. The
|
16
|
+
# elements are the valid routine names.
|
17
|
+
# NOTE: The "timing" elements are removed from the routines hash.
|
18
|
+
dependencies = []
|
19
|
+
routine[timing].each_pair do |n,v|
|
20
|
+
next unless v.nil? # this skips all "script" blocks
|
21
|
+
raise "#{timing}: #{n} is not a known routine" unless valid_routine?(n)
|
22
|
+
routine[timing].delete(n)
|
23
|
+
dependencies << n
|
24
|
+
end
|
25
|
+
|
26
|
+
# We need to return only the keys b/c the values are nil
|
27
|
+
dependencies = nil if dependencies.empty?
|
28
|
+
dependencies
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end; end
|
@@ -28,8 +28,10 @@ module Rudy; module Routines;
|
|
28
28
|
# We give it a funny name so we can delete it.
|
29
29
|
def @rbox.rudy_mkfs(*args); cmd('mkfs', args); end
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
unless disks?(routine)
|
32
|
+
STDERR.puts "[nothing to do]"
|
33
|
+
return
|
34
|
+
end
|
33
35
|
|
34
36
|
modified = []
|
35
37
|
routine.disks.each_pair do |action, disks|
|
@@ -45,11 +47,96 @@ module Rudy; module Routines;
|
|
45
47
|
|
46
48
|
end
|
47
49
|
|
50
|
+
def snapshot(disks)
|
51
|
+
rdisk = Rudy::Disks.new
|
52
|
+
rback = Rudy::Backups.new
|
53
|
+
|
54
|
+
disks.each_pair do |path, props|
|
55
|
+
adisk = Rudy::MetaData::Disk.new(path, props[:size], props[:device], @machine.position)
|
56
|
+
disk = rdisk.get(adisk.name)
|
57
|
+
if disk == nil
|
58
|
+
puts "Not found: #{adisk.name}".color(:red)
|
59
|
+
return
|
60
|
+
end
|
61
|
+
back = disk.backup
|
62
|
+
puts "Created backup: #{back.name}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def restore(disks)
|
67
|
+
rdisk = Rudy::Disks.new
|
68
|
+
rback = Rudy::Backups.new
|
69
|
+
|
70
|
+
disks.each_pair do |path, props|
|
71
|
+
disk = Rudy::MetaData::Disk.new(path, props[:size], props[:device], @machine.position)
|
72
|
+
|
73
|
+
olddisk = rdisk.get(disk.name)
|
74
|
+
back = nil
|
75
|
+
if olddisk && olddisk.exists?
|
76
|
+
olddisk.update
|
77
|
+
puts "Disk found: #{olddisk.name}. Skipping...".color(:red)
|
78
|
+
return
|
79
|
+
else
|
80
|
+
disk.fstype = props[:fstype] || 'ext3'
|
81
|
+
back = (rback.list(nil, nil, props) || []).first
|
82
|
+
raise "No backup found" unless back
|
83
|
+
puts "Found backup #{back.name} "
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
unless disk.exists? # Checks the EBS volume
|
89
|
+
msg = "Creating volume from snapshot (#{back.awsid})... "
|
90
|
+
disk.create(back.size, @@global.zone, back.awsid)
|
91
|
+
Rudy::Utils.waiter(2, 60, STDOUT, msg) {
|
92
|
+
disk.available?
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
msg = "Attaching #{disk.awsid} to #{@machine.awsid}... "
|
97
|
+
disk.attach(@machine.awsid)
|
98
|
+
Rudy::Utils.waiter(2, 10, STDOUT, msg) {
|
99
|
+
disk.attached?
|
100
|
+
}
|
101
|
+
|
102
|
+
sleep 2
|
103
|
+
|
104
|
+
begin
|
105
|
+
@rbox.mkdir(:p, disk.path)
|
106
|
+
|
107
|
+
print "Mounting at #{disk.path}... "
|
108
|
+
|
109
|
+
ret = @rbox.mount(:t, disk.fstype, disk.device, disk.path)
|
110
|
+
print_response ret
|
111
|
+
if ret.exit_code > 0
|
112
|
+
STDERR.puts "Error creating disk".color(:red)
|
113
|
+
return
|
114
|
+
else
|
115
|
+
puts "done"
|
116
|
+
end
|
117
|
+
disk.mounted = true
|
118
|
+
disk.save
|
119
|
+
|
120
|
+
rescue Net::SSH::AuthenticationFailed, Net::SSH::HostKeyMismatch => ex
|
121
|
+
STDERR.puts "Error creating disk".color(:red)
|
122
|
+
STDERR.puts ex.message.color(:red)
|
123
|
+
rescue Rye::CommandNotFound => ex
|
124
|
+
puts " CommandNotFound: #{ex.message}".color(:red)
|
125
|
+
|
126
|
+
rescue
|
127
|
+
STDERR.puts "Error creating disk" .color(:red)
|
128
|
+
Rudy::Utils.bug
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
48
135
|
def create(disks)
|
49
136
|
rdisk = Rudy::Disks.new
|
50
137
|
|
51
138
|
disks.each_pair do |path, props|
|
52
|
-
disk = Rudy::Disk.new(path, props[:size], props[:device], @machine.position)
|
139
|
+
disk = Rudy::MetaData::Disk.new(path, props[:size], props[:device], @machine.position)
|
53
140
|
olddisk = rdisk.get(disk.name)
|
54
141
|
if olddisk && olddisk.exists?
|
55
142
|
olddisk.update
|
@@ -122,12 +209,94 @@ module Rudy; module Routines;
|
|
122
209
|
|
123
210
|
end
|
124
211
|
end
|
212
|
+
|
213
|
+
def mount(disks)
|
214
|
+
rdisk = Rudy::Disks.new
|
215
|
+
disks.each_pair do |path, props|
|
216
|
+
adisk = Rudy::MetaData::Disk.new(path, props[:size], props[:device], @machine.position)
|
217
|
+
disk = rdisk.get(adisk.name)
|
218
|
+
if disk == nil
|
219
|
+
puts "Not found: #{adisk.name}".color(:red)
|
220
|
+
return
|
221
|
+
end
|
222
|
+
|
223
|
+
msg = "Attaching #{disk.awsid} to #{@machine.awsid}... "
|
224
|
+
disk.attach(@machine.awsid)
|
225
|
+
Rudy::Utils.waiter(2, 10, STDOUT, msg) {
|
226
|
+
disk.attached?
|
227
|
+
}
|
228
|
+
|
229
|
+
sleep 2
|
230
|
+
|
231
|
+
begin
|
232
|
+
@rbox.mkdir(:p, disk.path)
|
233
|
+
|
234
|
+
print "Mounting at #{disk.path}... "
|
125
235
|
|
236
|
+
ret = @rbox.mount(:t, disk.fstype, disk.device, disk.path)
|
237
|
+
print_response ret
|
238
|
+
if ret.exit_code > 0
|
239
|
+
STDERR.puts "Error creating disk".color(:red)
|
240
|
+
return
|
241
|
+
else
|
242
|
+
puts "done"
|
243
|
+
end
|
244
|
+
disk.mounted = true
|
245
|
+
disk.save
|
246
|
+
|
247
|
+
rescue Net::SSH::AuthenticationFailed, Net::SSH::HostKeyMismatch => ex
|
248
|
+
STDERR.puts "Error creating disk".color(:red)
|
249
|
+
STDERR.puts ex.message.color(:red)
|
250
|
+
rescue Rye::CommandNotFound => ex
|
251
|
+
puts " CommandNotFound: #{ex.message}".color(:red)
|
252
|
+
|
253
|
+
rescue
|
254
|
+
STDERR.puts "Error creating disk" .color(:red)
|
255
|
+
Rudy::Utils.bug
|
256
|
+
end
|
257
|
+
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
|
262
|
+
def umount(disks)
|
263
|
+
rdisk = Rudy::Disks.new
|
264
|
+
disks.each_pair do |path, props|
|
265
|
+
adisk = Rudy::MetaData::Disk.new(path, props[:size], props[:device], @machine.position)
|
266
|
+
disk = rdisk.get(adisk.name)
|
267
|
+
if disk == nil
|
268
|
+
puts "Not found: #{adisk.name}".color(:red)
|
269
|
+
return
|
270
|
+
end
|
271
|
+
|
272
|
+
if disk.mounted?
|
273
|
+
print "Unmounting #{disk.path}..."
|
274
|
+
execute_rbox_command { @rbox.umount(disk.path) }
|
275
|
+
puts " done"
|
276
|
+
sleep 0.5
|
277
|
+
end
|
278
|
+
|
279
|
+
sleep 2
|
280
|
+
|
281
|
+
if disk.attached?
|
282
|
+
msg = "Detaching #{disk.awsid}..."
|
283
|
+
disk.detach
|
284
|
+
Rudy::Utils.waiter(2, 60, STDOUT, msg) {
|
285
|
+
disk.available?
|
286
|
+
}
|
287
|
+
sleep 0.5
|
288
|
+
end
|
289
|
+
|
290
|
+
|
291
|
+
end
|
292
|
+
end
|
293
|
+
alias_method :unmount, :umount
|
294
|
+
|
126
295
|
def destroy(disks)
|
127
296
|
rdisk = Rudy::Disks.new
|
128
297
|
|
129
298
|
disks.each_pair do |path, props|
|
130
|
-
adisk = Rudy::Disk.new(path, props[:size], props[:device], @machine.position)
|
299
|
+
adisk = Rudy::MetaData::Disk.new(path, props[:size], props[:device], @machine.position)
|
131
300
|
disk = rdisk.get(adisk.name)
|
132
301
|
if disk == nil
|
133
302
|
puts "Not found: #{adisk.name}".color(:red)
|
@@ -157,6 +326,6 @@ module Rudy; module Routines;
|
|
157
326
|
|
158
327
|
end
|
159
328
|
end
|
160
|
-
|
329
|
+
|
161
330
|
end
|
162
331
|
end;end
|
@@ -10,8 +10,8 @@ module Rudy; module Routines;
|
|
10
10
|
scmnames = SUPPORTED_SCM_NAMES & routine.keys # Find intersections.
|
11
11
|
return false if scmnames.empty? # Nothing to do.
|
12
12
|
scmnames.each do |scm|
|
13
|
-
routine[scm].values.each do |
|
14
|
-
raise "Bad #{scm} config" if !
|
13
|
+
routine[scm].values.each do |t| # Each SCM should have a
|
14
|
+
raise "Bad #{scm} config" if !t.kind_of?(Hash) # Hash config. Otherwise
|
15
15
|
end # it's misconfigured.
|
16
16
|
end
|
17
17
|
true
|
@@ -74,6 +74,11 @@ module Rudy; module Routines;
|
|
74
74
|
def execute_command?(timing, routine)
|
75
75
|
hasconf = (routine.is_a?(Caesars::Hash) && routine.has_key?(timing))
|
76
76
|
return false unless hasconf
|
77
|
+
unless routine[timing].kind_of?(Hash)
|
78
|
+
STDERR.puts "No user supplied for #{timing} block".color(:red)
|
79
|
+
exit 12 unless keep_going?
|
80
|
+
return false
|
81
|
+
end
|
77
82
|
routine[timing].each_pair do |user,proc|
|
78
83
|
#p [timing, user, proc].join(', ')
|
79
84
|
if proc.nil? || !proc.is_a?(Proc)
|
@@ -99,7 +104,8 @@ module Rudy; module Routines;
|
|
99
104
|
Rudy::Utils.write_to_file(tf.path, sconf.to_hash.to_yaml, 'w')
|
100
105
|
end
|
101
106
|
|
102
|
-
|
107
|
+
# Do we need to run this again? It's called in generic_routine_runner
|
108
|
+
##if execute_command?(timing, routine) # i.e. before_local?
|
103
109
|
|
104
110
|
# We need to explicitly add the rm command for rbox so we
|
105
111
|
# can delete the script config file when we're done. This
|
@@ -179,9 +185,10 @@ module Rudy; module Routines;
|
|
179
185
|
|
180
186
|
# Return the borrowed rbox instance to the user it was provided with
|
181
187
|
rbox.switch_user original_user
|
182
|
-
|
183
|
-
|
184
|
-
|
188
|
+
|
189
|
+
##else
|
190
|
+
## puts "Nothing to do"
|
191
|
+
##end
|
185
192
|
|
186
193
|
tf.delete # delete local copy of script config
|
187
194
|
|
@@ -28,7 +28,9 @@ module Rudy; module Routines;
|
|
28
28
|
rmach = Rudy::Machines.new
|
29
29
|
raise Rudy::PrivateKeyNotFound, root_keypairpath unless has_keypair?(:root)
|
30
30
|
raise MachineGroupNotDefined, current_machine_group unless known_machine_group?
|
31
|
-
|
31
|
+
if !@@global.offline && !rmach.running?
|
32
|
+
raise MachineGroupNotRunning, current_machine_group
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
36
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Rudy; module Routines;
|
4
|
+
class Reboot < Rudy::Routines::Base
|
5
|
+
|
6
|
+
def init(*args)
|
7
|
+
@routine = fetch_routine_config(:reboot)
|
8
|
+
end
|
9
|
+
|
10
|
+
# * +each_mach+ is an optional block which is executed between
|
11
|
+
# disk creation and the after scripts. The will receives two
|
12
|
+
# arguments: instances of Rudy::Machine and Rye::Box.
|
13
|
+
def execute(&each_mach)
|
14
|
+
routine_separator(:reboot)
|
15
|
+
unless @routine
|
16
|
+
STDERR.puts "[this is a generic reboot routine]"
|
17
|
+
@routine = {}
|
18
|
+
end
|
19
|
+
machines = []
|
20
|
+
generic_machine_runner(:list) do |machine,rbox|
|
21
|
+
puts $/, "Rebooting...", $/
|
22
|
+
rbox.disconnect
|
23
|
+
machine.restart
|
24
|
+
sleep 4
|
25
|
+
msg = preliminary_separator("Checking if instance is running...")
|
26
|
+
Rudy::Utils.waiter(3, 120, STDOUT, msg, 0) {
|
27
|
+
machine.running?
|
28
|
+
}
|
29
|
+
|
30
|
+
# Add instance info to machine and save it. This is really important
|
31
|
+
# for the initial startup so the metadata is updated right away. But
|
32
|
+
# it's also important to call here because if a routine was executed
|
33
|
+
# and an unexpected exception occurs before this update is executed
|
34
|
+
# the machine metadata won't contain the DNS information. Calling it
|
35
|
+
# here ensure that the metadata is always up-to-date.
|
36
|
+
machine.update
|
37
|
+
|
38
|
+
sleep 4
|
39
|
+
|
40
|
+
msg = preliminary_separator("Waiting for SSH daemon...")
|
41
|
+
Rudy::Utils.waiter(3, 120, STDOUT, msg, 0) {
|
42
|
+
Rudy::Utils.service_available?(machine.dns_public, 22)
|
43
|
+
}
|
44
|
+
|
45
|
+
# NOTE: THIS IS INCOMPLETE
|
46
|
+
|
47
|
+
sleep 1 # Avoid IOError: closed stream on SSH
|
48
|
+
|
49
|
+
|
50
|
+
if Rudy::Routines::DiskHelper.disks?(@routine) # disk
|
51
|
+
puts task_separator("DISKS")
|
52
|
+
if rbox.ostype == "sunos"
|
53
|
+
puts "Sorry, Solaris is not supported yet!"
|
54
|
+
else
|
55
|
+
Rudy::Routines::DiskHelper.execute(@routine, machine, rbox)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
machines << machine
|
60
|
+
end
|
61
|
+
machines
|
62
|
+
end
|
63
|
+
|
64
|
+
# Called by generic_machine_runner
|
65
|
+
def raise_early_exceptions
|
66
|
+
rmach = Rudy::Machines.new
|
67
|
+
# There's no keypair check here because Rudy::Machines will attempt
|
68
|
+
# to create one.
|
69
|
+
raise MachineGroupNotDefined, current_machine_group unless known_machine_group?
|
70
|
+
raise MachineGroupNotRunning, current_machine_group unless rmach.running?
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end; end
|
@@ -18,7 +18,6 @@ module Rudy; module Routines;
|
|
18
18
|
end
|
19
19
|
machines = []
|
20
20
|
generic_machine_runner(:create) do |machine,rbox|
|
21
|
-
puts $/, "Starting up...", $/
|
22
21
|
machines << machine
|
23
22
|
end
|
24
23
|
machines
|
@@ -27,9 +26,10 @@ module Rudy; module Routines;
|
|
27
26
|
# Called by generic_machine_runner
|
28
27
|
def raise_early_exceptions
|
29
28
|
rmach = Rudy::Machines.new
|
30
|
-
# There's no keypair check here because Rudy::Machines will
|
31
|
-
# to create one.
|
29
|
+
# There's no keypair check here because Rudy::Machines will create one
|
32
30
|
raise MachineGroupNotDefined, current_machine_group unless known_machine_group?
|
31
|
+
# We don't check @@global.offline b/c we can't create EC2 instances
|
32
|
+
# without an internet connection. Use passthrough for routine tests.
|
33
33
|
raise MachineGroupAlreadyRunning, current_machine_group if rmach.running?
|
34
34
|
end
|
35
35
|
|
data/lib/rudy/scm/git.rb
CHANGED
@@ -17,7 +17,7 @@ module Rudy
|
|
17
17
|
attr_reader :rtag
|
18
18
|
attr_reader :user
|
19
19
|
attr_reader :pkey
|
20
|
-
attr_reader :
|
20
|
+
attr_reader :changes
|
21
21
|
|
22
22
|
# * +args+ a hash of params from the git block in the routines config
|
23
23
|
#
|
@@ -27,11 +27,11 @@ module Rudy
|
|
27
27
|
:remote => :origin,
|
28
28
|
:branch => :master,
|
29
29
|
:user => :root,
|
30
|
-
:
|
30
|
+
:changes => :enforce,
|
31
31
|
:path => nil
|
32
32
|
}.merge(args)
|
33
33
|
@remote, @branch, @path = args[:remote], args[:branch], args[:path]
|
34
|
-
@user, @pkey, @
|
34
|
+
@user, @pkey, @changes = args[:user], args[:privatekey], args[:changes]
|
35
35
|
@repo = Repo.new(Dir.pwd) if GIT.working_copy?
|
36
36
|
end
|
37
37
|
|
@@ -99,19 +99,19 @@ module Rudy
|
|
99
99
|
rbox.upload(@pkey, ".ssh/#{key}")
|
100
100
|
end
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
102
|
+
## NOTE: The following are two attempts at telling git which
|
103
|
+
## private key to use. Both fail. The only thing I could get
|
104
|
+
## to work is modifying the ~/.ssh/config file.
|
105
|
+
##
|
106
|
+
## This runs fine, but "git clone" doesn't care.
|
107
|
+
## git config --global --replace-all http.sslKey /home/delano/.ssh/id_rsa
|
108
|
+
## rbox.git('config', '--global', '--replace-all', 'http.sslKey', "#{homedir}/.ssh/#{key}")
|
109
|
+
##
|
110
|
+
## "git clone" doesn't care about this either. Note that both these
|
111
|
+
## config attempts come directly from the git-config man page:
|
112
|
+
## http://www.kernel.org/pub/software/scm/git/docs/git-config.html
|
113
|
+
## export GIT_SSL_KEY=/home/delano/.ssh/id_rsa
|
114
|
+
## rbox.setenv("GIT_SSL_KEY", "#{homedir}/.ssh/#{key}")
|
115
115
|
|
116
116
|
if rbox.file_exists?('.ssh/config')
|
117
117
|
rbox.cp('.ssh/config', ".ssh/config-previous")
|
@@ -198,7 +198,7 @@ module Rudy
|
|
198
198
|
|
199
199
|
def raise_early_exceptions
|
200
200
|
raise NotAWorkingCopy, :git unless working_copy?
|
201
|
-
raise DirtyWorkingCopy, :git unless @
|
201
|
+
raise DirtyWorkingCopy, :git unless @changes.to_s == 'ignore' || clean_working_copy?
|
202
202
|
raise NoRemoteURI, "remote.#{@remote}.url not set" if get_remote_uri.nil?
|
203
203
|
raise NoRemotePath, :git if @path.nil?
|
204
204
|
raise PrivateKeyNotFound, @pkey if @pkey && !File.exists?(@pkey)
|