CloudyScripts 2.14.54 → 2.14.58

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,7 +12,8 @@ require 'rake/testtask'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = 'CloudyScripts'
15
- s.version = '2.14.54' #<number cloud-stacks supported>.<number cloud-scripts>.<counting releases>
15
+ #s.version = '2.14.54' #<number cloud-stacks supported>.<number cloud-scripts>.<counting releases>
16
+ s.version = '2.14.58' #<number cloud-stacks supported>.<number cloud-scripts>.<counting releases>
16
17
  s.has_rdoc = true
17
18
  s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
18
19
  s.summary = 'Scripts to facilitate programming for infrastructure clouds.'
@@ -60,6 +60,10 @@ class RemoteCommandHandler
60
60
  remote_execute("ls #{path}")
61
61
  end
62
62
 
63
+ def file_size(file)
64
+ get_output("ls -lh #{file} | cut -d ' ' -f 5").strip
65
+ end
66
+
63
67
  # Returns the result of uname -a (Linux)
64
68
  def retrieve_os()
65
69
  get_output("uname -r").strip
@@ -251,14 +255,23 @@ class RemoteCommandHandler
251
255
 
252
256
  # dump and compress a device in a file locally
253
257
  def local_dump_and_compress(source_device, target_filename)
254
- e = "sh -c 'dd if=#{source_device} | gzip > #{target_filename}'"
258
+ #e = "sh -c 'dd if=#{source_device} | gzip > #{target_filename}'"
259
+ e = "sh -c 'dd if=#{source_device} bs=512k | gzip -1 > #{target_filename}'"
255
260
  @logger.debug "going to execute #{e}"
256
261
  status = remote_exec_helper(e, nil, nil, true)
257
262
  end
258
263
 
259
- # idecompress and a file to a device locally
264
+ # dump a file to a device locally
260
265
  def local_decompress_and_dump(source_filename, target_device)
261
- e = "sh -c 'gunzip -c #{source_filename} | dd of=#{target_device}'"
266
+ #e = "sh -c 'gunzip -c #{source_filename} | dd of=#{target_device}'"
267
+ e = "sh -c 'gunzip -1 -c #{source_filename} | dd of=#{target_device} bs=512k'"
268
+ @logger.debug "going to execute #{e}"
269
+ status = remote_exec_helper(e, nil, nil, true)
270
+ end
271
+
272
+ # dump a device in a local file or a dump local file to a device
273
+ def local_dump(source_device, target_filename)
274
+ e = "sh -c 'dd if=#{source_device} of=#{target_filename} bs=1M'"
262
275
  @logger.debug "going to execute #{e}"
263
276
  status = remote_exec_helper(e, nil, nil, true)
264
277
  end
@@ -358,6 +358,7 @@ module StateTransitionHelper
358
358
  def create_volume_from_snapshot(snapshot_id, availability_zone)
359
359
  post_message("going to create a new EBS volume from the specified snapshot...")
360
360
  @logger.debug "create volume in zone #{availability_zone}"
361
+ start_time = Time.new.to_i
361
362
  res = ec2_handler().create_volume(:snapshot_id => snapshot_id, :availability_zone => availability_zone)
362
363
  volume_id = res['volumeId']
363
364
  started = false
@@ -371,7 +372,9 @@ module StateTransitionHelper
371
372
  started = true
372
373
  end
373
374
  end
374
- post_message("EBS volume #{volume_id} is ready")
375
+ end_time = Time.new.to_i
376
+ @logger.info "create volume from snapshot took #{(end_time-start_time)}s"
377
+ post_message("EBS volume #{volume_id} is ready (took #{end_time-start_time}s)")
375
378
  return volume_id
376
379
  end
377
380
 
@@ -382,7 +385,7 @@ module StateTransitionHelper
382
385
  # * temp_device_name => device name to be used for attaching (e.g. /dev/sdj1)
383
386
  def attach_volume(volume_id, instance_id, temp_device_name, timeout = 240)
384
387
  post_message("going to attach volume #{volume_id} to instance #{instance_id} on device #{temp_device_name}...")
385
- @logger.info "attach volume #{volume_id} to instance #{instance_id} on device #{temp_device_name} (using a timeout of #{timeout})s"
388
+ @logger.info "attach volume #{volume_id} to instance #{instance_id} on device #{temp_device_name} (using a timeout of #{timeout}s)"
386
389
  ec2_handler().attach_volume(:volume_id => volume_id,
387
390
  :instance_id => instance_id,
388
391
  :device => temp_device_name
@@ -422,7 +425,7 @@ module StateTransitionHelper
422
425
  # * instance_id => EC2 ID for the instance to detach from
423
426
  def detach_volume(volume_id, instance_id, timeout = 240)
424
427
  post_message("going to detach volume #{volume_id} from instance #{instance_id}...")
425
- @logger.info "detach volume #{volume_id} from instance #{instance_id} (using a timeout of #{timeout})s"
428
+ @logger.info "detach volume #{volume_id} from instance #{instance_id} (using a timeout of #{timeout}s)"
426
429
  ec2_handler().detach_volume(:volume_id => volume_id,
427
430
  :instance_id => instance_id
428
431
  )
@@ -469,6 +472,7 @@ module StateTransitionHelper
469
472
  def create_snapshot(volume_id, description = "")
470
473
  post_message("going to create a snapshot for volume #{volume_id}...")
471
474
  @logger.debug "create snapshot for volume #{volume_id}"
475
+ start_time = Time.new.to_i
472
476
  res = ec2_handler().create_snapshot(:volume_id => volume_id,
473
477
  :description => description)
474
478
  snapshot_id = res['snapshotId']
@@ -483,7 +487,9 @@ module StateTransitionHelper
483
487
  done = true
484
488
  end
485
489
  end
486
- post_message("snapshot is done with ID=#{snapshot_id}")
490
+ end_time = Time.new.to_i
491
+ @logger.info "create snapshot took #{(end_time-start_time)}s"
492
+ post_message("snapshot is done with ID=#{snapshot_id} (took #{(end_time-start_time)}s)")
487
493
  return snapshot_id
488
494
  end
489
495
 
@@ -914,7 +920,7 @@ module StateTransitionHelper
914
920
  # dump and compress a device using dd and gzip
915
921
  def local_dump_and_compress_device_to_file(source_device, target_filename)
916
922
  post_message("going to start dumping and compressing source device '#{source_device}' to '#{target_filename}' file. This may take quite a time...")
917
- @logger.debug "start dumping and compressing '#{source_device}' to '#{target_filename}'"
923
+ @logger.info "start dumping and compressing '#{source_device}' to '#{target_filename}'"
918
924
  start_time = Time.new.to_i
919
925
  if remote_handler().tools_installed?("dd") && remote_handler().tools_installed?("gzip")
920
926
  @logger.debug "use dd and gzip command line"
@@ -928,14 +934,37 @@ module StateTransitionHelper
928
934
  raise Exception.new("dd and/or gzip tools not installed")
929
935
  end
930
936
  end_time = Time.new.to_i
931
- @logger.info "dump and compress took #{(end_time-start_time)}s"
932
- post_message("dumping and compressing done (took #{end_time-start_time})s")
937
+ filesize = remote_handler().file_size(target_filename)
938
+ @logger.info "dump and compress to a #{filesize} file took #{(end_time-start_time)}s"
939
+ post_message("dumping and compressing to a #{filesize} file done (took #{end_time-start_time}s)")
940
+ end
941
+
942
+ # dump a device using dd
943
+ def local_dump_device_to_file(source_device, target_filename)
944
+ post_message("going to start dumping source device '#{source_device}' to '#{target_filename}' file. This may take quite a time...")
945
+ @logger.info "start dumping '#{source_device}' to '#{target_filename}'"
946
+ start_time = Time.new.to_i
947
+ if remote_handler().tools_installed?("dd")
948
+ @logger.debug "use dd command line"
949
+ status = remote_handler().local_dump(source_device, target_filename)
950
+ if status == false
951
+ @logger.error "failed to dump device"
952
+ raise Exception.new("failed to dump device")
953
+ end
954
+ else
955
+ @logger.error "dd tool not installed"
956
+ raise Exception.new("dd tool not installed")
957
+ end
958
+ end_time = Time.new.to_i
959
+ filesize = remote_handler().file_size(target_filename)
960
+ @logger.info "dump to a #{filesize} file took #{(end_time-start_time)}s"
961
+ post_message("dumping to a #{filesize} file done (took #{end_time-start_time}s)")
933
962
  end
934
963
 
935
964
  # decompress and dump a file using gunzip and dd
936
965
  def local_decompress_and_dump_file_to_device(source_filename, target_device)
937
966
  post_message("going to start decompressing and dumping file '#{source_filename}' to '#{target_device}' target device. This may take quite a time...")
938
- @logger.debug "start decompressing and dumping '#{source_filename}' to '#{target_device}'"
967
+ @logger.info "start decompressing and dumping '#{source_filename}' to '#{target_device}'"
939
968
  start_time = Time.new.to_i
940
969
  if remote_handler().tools_installed?("dd") && remote_handler().tools_installed?("gunzip")
941
970
  @logger.debug "use dd and gzip command line"
@@ -949,27 +978,52 @@ module StateTransitionHelper
949
978
  raise Exception.new("dd and/or gunzip tools not installed")
950
979
  end
951
980
  end_time = Time.new.to_i
952
- @logger.info "decompress and dump filetook #{(end_time-start_time)}s"
953
- post_message("decompressing and dumping done (took #{end_time-start_time})s")
981
+ filesize = remote_handler().file_size(source_filename)
982
+ @logger.info "decompress and dump file of #{filesize} took #{(end_time-start_time)}s"
983
+ post_message("decompressing and dumping file of #{filesize} done (took #{end_time-start_time}s)")
984
+ end
985
+
986
+ # dump a file using dd
987
+ def local_dump_file_to_device(source_filename, target_device)
988
+ post_message("going to start dumping file '#{source_filename}' to '#{target_device}' target device. This may take quite a time...")
989
+ @logger.info "start dumping '#{source_filename}' to '#{target_device}'"
990
+ start_time = Time.new.to_i
991
+ if remote_handler().tools_installed?("dd")
992
+ @logger.debug "use dd command line"
993
+ status = remote_handler().local_dump(source_filename, target_device)
994
+ if status == false
995
+ @logger.error "failed to dump file"
996
+ raise Exception.new("failed to dump file")
997
+ end
998
+ else
999
+ @logger.error "dd tool not installed"
1000
+ raise Exception.new("dd tool not installed")
1001
+ end
1002
+ end_time = Time.new.to_i
1003
+ filesize = remote_handler().file_size(source_filename)
1004
+ @logger.info "dump file of #{filesize} took #{(end_time-start_time)}s"
1005
+ post_message("dumping file of #{filesize} done (took #{end_time-start_time}s)")
954
1006
  end
955
1007
 
956
1008
  def disable_ssh_tty(host)
957
1009
  post_message("going to disable SSH tty on #{host}...")
958
- @logger.debug "disable SSH tty on #{host}"
1010
+ @logger.info "disable SSH tty on #{host}"
959
1011
  remote_handler().disable_sudoers_requiretty()
960
1012
  post_message("SSH tty disabled")
961
1013
  end
962
1014
 
963
1015
  def enable_ssh_tty(host)
964
1016
  post_message("going to enable SSH tty on #{host}...")
965
- @logger.debug "enable SSH tty on #{host}"
1017
+ @logger.info "enable SSH tty on #{host}"
966
1018
  remote_handler().enable_sudoers_requiretty()
967
1019
  post_message("SSH tty enabled")
968
1020
  end
969
1021
 
970
1022
  def remote_copy(user_name, keyname, source_dir, dest_machine, dest_user, dest_dir)
971
1023
  post_message("going to remote copy all files from volume. This may take some time...")
1024
+ @logger.info "going to remote copy all files from volume. This may take some time..."
972
1025
  key_path_candidates = ["/#{user_name}/.ssh/", "/home/#{user_name}/.ssh/"]
1026
+ start_time = Time.new.to_i
973
1027
  key_path_candidates.each() {|key_path|
974
1028
  key_file = "#{key_path}#{keyname}.pem"
975
1029
  if remote_handler().file_exists?(key_path)
@@ -983,7 +1037,9 @@ module StateTransitionHelper
983
1037
  break
984
1038
  end
985
1039
  }
986
- post_message("remote copy operation done")
1040
+ end_time = Time.new.to_i
1041
+ @logger.info "remote copy operation took #{(end_time-start_time)}s"
1042
+ post_message("remote copy operation done (took #{end_time-start_time}s)")
987
1043
  end
988
1044
 
989
1045
  def upload_file(ip, user, key_data, file, target_file)
@@ -1078,6 +1134,11 @@ module StateTransitionHelper
1078
1134
  'aki-8e5ea7e7' => 'pv-grub-hd00_1.02-x86_64',
1079
1135
  'aki-805ea7e9' => 'pv-grub-hd0_1.02-i386',
1080
1136
  'aki-825ea7eb' => 'pv-grub-hd0_1.02-x86_64',
1137
+ 'aki-b6aa75df' => 'pv-grub-hd0_1.03-i386',
1138
+ 'aki-88aa75e1' => 'pv-grub-hd0_1.03-x86_64',
1139
+ 'aki-b2aa75db' => 'pv-grub-hd00_1.03-i386',
1140
+ 'aki-b4aa75dd' => 'pv-grub-hd00_1.03-x86_64',
1141
+
1081
1142
  #RHEL kernel Amazon Kernel ID
1082
1143
  'aki-36ed075f' => 'aki-rhel-i386',
1083
1144
  'aki-08ed0761' => 'aki-rhel-x86_64'
@@ -1090,9 +1151,14 @@ module StateTransitionHelper
1090
1151
  'aki-81396bc4' => 'pv-grub-hd00_1.02-x86_64',
1091
1152
  'aki-83396bc6' => 'pv-grub-hd0_1.02-i386',
1092
1153
  'aki-8d396bc8' => 'pv-grub-hd0_1.02-x86_64',
1093
- #RHEL kernel Amazon Kernel ID
1094
- 'aki-772c7f32' => 'aki-rhel-i386',
1095
- 'aki-712c7f34' => 'aki-rhel-x86_64'
1154
+ 'aki-f57e26b0' => 'pv-grub-hd0_1.03-i386',
1155
+ 'aki-f77e26b2' => 'pv-grub-hd0_1.03-x86_64',
1156
+ 'aki-e97e26ac' => 'pv-grub-hd00_1.03-i386',
1157
+ 'aki-eb7e26ae' => 'pv-grub-hd00_1.03-x86_64',
1158
+
1159
+ #RHEL kernel Amazon Kernel ID:
1160
+ 'aki-772c7f32' => 'aki-rhel-i386', # RH-pv-grub-hd0-V1.01-i386
1161
+ 'aki-712c7f34' => 'aki-rhel-x86_64' # RH-pv-grub-hd0-V1.01-x86_64
1096
1162
  },
1097
1163
  'us-west-2' => {'aki-dee26fee' => 'pv-grub-hd00-V1.01-i386',
1098
1164
  'aki-90e26fa0' => 'pv-grub-hd00-V1.01-x86_64',
@@ -1102,9 +1168,14 @@ module StateTransitionHelper
1102
1168
  'aki-94e26fa4' => 'pv-grub-hd00_1.02-x86_64',
1103
1169
  'aki-c2e26ff2' => 'pv-grub-hd0_1.02-i386',
1104
1170
  'aki-98e26fa8' => 'pv-grub-hd0_1.02-x86_64',
1171
+ 'aki-fa37baca' => 'pv-grub-hd0_1.03-i386',
1172
+ 'aki-fc37bacc' => 'pv-grub-hd0_1.03-x86_64',
1173
+ 'aki-f637bac6' => 'pv-grub-hd00_1.03-i386',
1174
+ 'aki-f837bac8' => 'pv-grub-hd00_1.03-x86_64',
1175
+
1105
1176
  #RHEL kernel Amazon Kernel ID
1106
- '' => 'aki-rhel-i386',
1107
- '' => 'aki-rhel-x86_64'
1177
+ 'aki-2efa771e' => 'aki-rhel-i386',
1178
+ 'aki-10fa7720' => 'aki-rhel-x86_64'
1108
1179
  },
1109
1180
  'eu-west-1' => {'aki-47eec433' => 'pv-grub-hd00-V1.01-i386',
1110
1181
  'aki-41eec435' => 'pv-grub-hd00-V1.01-x86_64',
@@ -1114,6 +1185,11 @@ module StateTransitionHelper
1114
1185
  'aki-60695814' => 'pv-grub-hd00_1.02-x86_64',
1115
1186
  'aki-64695810' => 'pv-grub-hd0_1.02-i386',
1116
1187
  'aki-62695816' => 'pv-grub-hd0_1.02-x86_64',
1188
+ 'aki-75665e01' => 'pv-grub-hd0_1.03-i386',
1189
+ 'aki-71665e05' => 'pv-grub-hd0_1.03-x86_64',
1190
+ 'aki-89655dfd' => 'pv-grub-hd00_1.03-i386',
1191
+ 'aki-8b655dff' => 'pv-grub-hd00_1.03-x86_64',
1192
+
1117
1193
  #RHEL kernel Amazon Kernel ID
1118
1194
  'aki-af0a3ddb' => 'aki-rhel-i386',
1119
1195
  'aki-a90a3ddd' => 'aki-rhel-x86_64'
@@ -1126,6 +1202,11 @@ module StateTransitionHelper
1126
1202
  'aki-a6225af4' => 'pv-grub-hd00_1.02-x86_64',
1127
1203
  'aki-a4225af6' => 'pv-grub-hd0_1.02-i386',
1128
1204
  'aki-aa225af8' => 'pv-grub-hd0_1.02-x86_64',
1205
+ 'aki-f81354aa' => 'pv-grub-hd0_1.03-i386',
1206
+ 'aki-fe1354ac' => 'pv-grub-hd0_1.03-x86_64',
1207
+ 'aki-f41354a6' => 'pv-grub-hd00_1.03-i386',
1208
+ 'aki-fa1354a8' => 'pv-grub-hd00_1.03-x86_64',
1209
+
1129
1210
  #RHEL kernel Amazon Kernel ID
1130
1211
  'aki-9c235ace' => 'aki-rhel-i386',
1131
1212
  'aki-82235ad0' => 'aki-rhel-x86_64'
@@ -1138,9 +1219,14 @@ module StateTransitionHelper
1138
1219
  'aki-ea5df7eb' => 'pv-grub-hd00_1.02-x86_64',
1139
1220
  'aki-ec5df7ed' => 'pv-grub-hd0_1.02-i386',
1140
1221
  'aki-ee5df7ef' => 'pv-grub-hd0_1.02-x86_64',
1222
+ 'aki-42992843' => 'pv-grub-hd0_1.03-i386',
1223
+ 'aki-44992845' => 'pv-grub-hd0_1.03-x86_64',
1224
+ 'aki-3e99283f' => 'pv-grub-hd00_1.03-i386',
1225
+ 'aki-40992841' => 'pv-grub-hd00_1.03-x86_64',
1226
+
1141
1227
  #RHEL kernel Amazon Kernel ID
1142
1228
  'aki-66c06a67' => 'aki-rhel-i386',
1143
- 'aki-68c06a69' => 'aki-rhel-x86_64'
1229
+ 'aki-68c06a69' => 'aki-rhel-x86_64'
1144
1230
  },
1145
1231
  'sa-east-1' => {'aki-803ce39d' => 'pv-grub-hd00-V1.01-i386',
1146
1232
  'aki-d03ce3cd' => 'pv-grub-hd00-V1.01-x86_64',
@@ -1150,9 +1236,14 @@ module StateTransitionHelper
1150
1236
  'aki-cc3ce3d1' => 'pv-grub-hd00_1.02-x86_64',
1151
1237
  'aki-823ce39f' => 'pv-grub-hd0_1.02-i386',
1152
1238
  'aki-d23ce3cf' => 'pv-grub-hd0_1.02-x86_64',
1239
+ 'aki-ca8f51d7' => 'pv-grub-hd0_1.03-i386',
1240
+ 'aki-c48f51d9' => 'pv-grub-hd0_1.03-x86_64',
1241
+ 'aki-ce8f51d3' => 'pv-grub-hd00_1.03-i386',
1242
+ 'aki-c88f51d5' => 'pv-grub-hd00_1.03-x86_64',
1243
+
1153
1244
  #RHEL kernel Amazon Kernel ID
1154
- '' => 'aki-rhel-i386',
1155
- '' => 'aki-rhel-x86_64'
1245
+ 'aki-1a38e707' => 'aki-rhel-i386',
1246
+ 'aki-1438e709' => 'aki-rhel-x86_64'
1156
1247
  }
1157
1248
  }
1158
1249
  target_aki = ''
@@ -86,6 +86,11 @@ class CopyMsWindowsSnapshot < Ec2Script
86
86
  if @input_params[:description] == nil || check_string_alnum(@input_params[:description])
87
87
  @input_params[:description] = "Created by Cloudy_Scripts - copy_mswindows_snapshot"
88
88
  end
89
+ if @input_params[:compression] != nil && (@input_params[:compression] =~ /^on$/i)
90
+ @input_params[:compression] = true
91
+ else
92
+ @input_params[:compression] = false
93
+ end
89
94
  end
90
95
 
91
96
  # Load the initial state for the script.
@@ -135,7 +140,8 @@ class CopyMsWindowsSnapshot < Ec2Script
135
140
  def enter()
136
141
  local_region()
137
142
  post_message("Lunching an Helper instance in source Region...")
138
- result = launch_instance(@context[:source_ami_id], @context[:source_key_name], @context[:source_security_groups])
143
+ result = launch_instance(@context[:source_ami_id], @context[:source_key_name], @context[:source_security_groups],
144
+ nil, @context[:instance_type])
139
145
  @context[:source_instance_id] = result.first
140
146
  @context[:source_dns_name] = result[1]
141
147
  @context[:source_availability_zone] = result[2]
@@ -178,7 +184,11 @@ class CopyMsWindowsSnapshot < Ec2Script
178
184
  post_message("Using AWS name source device '#{@context[:device_name]}' and OS name '#{source_device}'")
179
185
  @context[:source_device_name] = source_device
180
186
  # Step2: create and attach a temp volume of the same size to dump and compress the entire drive
181
- @context[:source_temp_volume_id] = create_volume(@context[:source_availability_zone], @context[:volume_size])
187
+ if @context[:compression]
188
+ @context[:source_temp_volume_id] = create_volume(@context[:source_availability_zone], @context[:volume_size])
189
+ else
190
+ @context[:source_temp_volume_id] = create_volume(@context[:source_availability_zone], @context[:volume_size] + 4)
191
+ end
182
192
  temp_device = @context[:temp_device_name]
183
193
  attach_volume(@context[:source_temp_volume_id], @context[:source_instance_id], temp_device)
184
194
  aws_device_letter = temp_device.split('/')[2].gsub('sd', '').gsub('xvd', '').gsub(/[0-9]/, '')
@@ -206,8 +216,13 @@ class CopyMsWindowsSnapshot < Ec2Script
206
216
  local_region()
207
217
  connect(@context[:source_dns_name], @context[:source_ssh_username], nil, @context[:source_ssh_keydata])
208
218
  mount_point = "/mnt/tmp_#{@context[:source_temp_volume_id]}"
209
- @context[:source_filename] = "#{mount_point}" + "/" + "#{@context[:snapshot_id]}" + ".gz"
210
- local_dump_and_compress_device_to_file(@context[:source_device_name], @context[:source_filename])
219
+ if @context[:compression]
220
+ @context[:source_filename] = "#{mount_point}" + "/" + "#{@context[:snapshot_id]}" + ".img.gz"
221
+ local_dump_and_compress_device_to_file(@context[:source_device_name], @context[:source_filename])
222
+ else
223
+ @context[:source_filename] = "#{mount_point}" + "/" + "#{@context[:snapshot_id]}" + ".img"
224
+ local_dump_device_to_file(@context[:source_device_name], @context[:source_filename])
225
+ end
211
226
  disconnect()
212
227
 
213
228
  BackupedDataState.new(@context)
@@ -220,7 +235,8 @@ class CopyMsWindowsSnapshot < Ec2Script
220
235
  class BackupedDataState < CopyMsWindowsSnapshotState
221
236
  def enter()
222
237
  remote_region()
223
- result = launch_instance(@context[:target_ami_id], @context[:target_key_name], @context[:target_security_groups])
238
+ result = launch_instance(@context[:target_ami_id], @context[:target_key_name], @context[:target_security_groups],
239
+ nil, @context[:instance_type])
224
240
  @context[:target_instance_id] = result.first
225
241
  @context[:target_dns_name] = result[1]
226
242
  @context[:target_availability_zone] = result[2]
@@ -239,7 +255,11 @@ class CopyMsWindowsSnapshot < Ec2Script
239
255
  def enter()
240
256
  remote_region()
241
257
  # Step1: create and attach a temp volume for receiving archive of the drive
242
- @context[:target_temp_volume_id] = create_volume(@context[:target_availability_zone], @context[:volume_size])
258
+ if @context[:compression]
259
+ @context[:target_temp_volume_id] = create_volume(@context[:target_availability_zone], @context[:volume_size])
260
+ else
261
+ @context[:target_temp_volume_id] = create_volume(@context[:target_availability_zone], @context[:volume_size] + 4)
262
+ end
243
263
  temp_device = @context[:temp_device_name]
244
264
  attach_volume(@context[:target_temp_volume_id], @context[:target_instance_id], temp_device)
245
265
  connect(@context[:target_dns_name], @context[:target_ssh_username], nil, @context[:target_ssh_keydata])
@@ -335,8 +355,13 @@ class CopyMsWindowsSnapshot < Ec2Script
335
355
  remote_region()
336
356
  connect(@context[:target_dns_name], @context[:target_ssh_username], nil, @context[:target_ssh_keydata])
337
357
  mount_point = "/mnt/tmp_#{@context[:target_temp_volume_id]}"
338
- @context[:source_filename] = "#{mount_point}" + "/" + "#{@context[:snapshot_id]}" + ".gz"
339
- local_decompress_and_dump_file_to_device(@context[:source_filename], @context[:target_device_name])
358
+ if @context[:compression]
359
+ @context[:source_filename] = "#{mount_point}" + "/" + "#{@context[:snapshot_id]}" + ".img.gz"
360
+ local_decompress_and_dump_file_to_device(@context[:source_filename], @context[:target_device_name])
361
+ else
362
+ @context[:source_filename] = "#{mount_point}" + "/" + "#{@context[:snapshot_id]}" + ".img"
363
+ local_dump_file_to_device(@context[:source_filename], @context[:target_device_name])
364
+ end
340
365
  disconnect()
341
366
 
342
367
  RestoredDataState.new(@context)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CloudyScripts
3
3
  version: !ruby/object:Gem::Version
4
- hash: 91
4
+ hash: 67
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 14
9
- - 54
10
- version: 2.14.54
9
+ - 58
10
+ version: 2.14.58
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthias Jung
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-25 00:00:00 +00:00
18
+ date: 2012-07-13 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency