CloudyScripts 1.5.17 → 1.5.18

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'rake/testtask'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = 'CloudyScripts'
15
- s.version = '1.5.17'
15
+ s.version = '1.5.18'
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
18
18
  s.summary = 'Scripts to facilitate programming for infrastructure clouds.'
@@ -103,6 +103,21 @@ class RemoteCommandHandler
103
103
  !drive_mounted?(path)
104
104
  end
105
105
 
106
+ # Copy directory using basic cp
107
+ # exclude_path: a space separated list of directory
108
+ def local_rcopy(source_path, dest_path, exclude_path = nil)
109
+ e = ""
110
+ if exclude_path.nil? || exclude_path.empty?
111
+ e = "cp -Rpv #{source_path} #{dest_path}"
112
+ else
113
+ # only one level of exclusion
114
+ exclusion_regexp = exclude_path.gsub(' ', '|')
115
+ e = "for dir in $(ls -d #{source_path}* | grep -E -v '#{exclusion_regexp}'); do cp -Rpv $dir #{dest_path}; done;"
116
+ end
117
+ @logger.debug "going to execute #{e}"
118
+ remote_exec_helper(e, nil, nil, false)
119
+ end
120
+
106
121
  # Copy directory using options -avHx
107
122
  def local_rsync(source_path, dest_path, exclude_path = nil)
108
123
  exclude = ""
@@ -151,6 +166,7 @@ class RemoteCommandHandler
151
166
  # When #raise_exception is set, an exception will be raised instead of
152
167
  # returning false.
153
168
  def remote_execute(exec_string, push_data = nil, raise_exception = false)
169
+ #XXX: command line: echo -e 'y' | mkfs -t ext3 /dev/sdf
154
170
  exec_string = "echo #{push_data} >tmp.txt; #{exec_string} <tmp.txt; rm -f tmp.txt" unless push_data == nil
155
171
  stdout = []
156
172
  stderr = []
@@ -213,13 +229,13 @@ class RemoteCommandHandler
213
229
  end
214
230
  ch.on_extended_data do |ch, type, data|
215
231
  stderr << data unless data == nil || stderr == nil
216
- result = false
232
+ #result = false
217
233
  end
218
234
  ch.on_eof do |ch|
219
- @logger.debug("RemoteCommandHandler.on_eof:remote end is done sending data") if debug
235
+ @logger.debug("RemoteCommandHandler.on_eof: remote end is done sending data") if debug
220
236
  end
221
237
  ch.on_close do |ch|
222
- @logger.debug("RemoteCommandHandler.on_close:remote end is closing!") if debug
238
+ @logger.debug("RemoteCommandHandler.on_close: remote end is closing!") if debug
223
239
  end
224
240
  ch.on_open_failed do |ch, code, desc|
225
241
  @logger.debug("RemoteCommandHandler.on_open_failed: code=#{code} desc=#{desc}") if debug
@@ -229,6 +245,17 @@ class RemoteCommandHandler
229
245
  sleep(1)
230
246
  ch.send_data("\n")
231
247
  end
248
+ ch.on_request "exit-status" do |ch, data|
249
+ returned_code = data.read_long
250
+ @logger.debug("process terminated with exit-status: #{returned_code}")
251
+ if returned_code != 0
252
+ @logger.error("Remote command execution failed with code: #{returned_code}")
253
+ result = false
254
+ end
255
+ end
256
+ ch.on_request "exit-signal" do |ch, data|
257
+ @logger.debug("process terminated with exit-signal: #{data.read_string}")
258
+ end
232
259
  else
233
260
  stderr << "the remote command could not be invoked!" unless stderr == nil
234
261
  result = false
@@ -242,7 +242,7 @@ module StateTransitionHelper
242
242
  res = ec2_handler().describe_volumes(:volume_id => volume_id)
243
243
  state = res['volumeSet']['item'][0]['status']
244
244
  @logger.debug "storage attaching: #{state}"
245
- if state == 'in-use'
245
+ if state == 'in-use'
246
246
  done = true
247
247
  end
248
248
  end
@@ -351,7 +351,10 @@ module StateTransitionHelper
351
351
  def create_fs(dns_name, device)
352
352
  post_message("going to create filesystem on #{dns_name} to #{device}...")
353
353
  @logger.debug "create filesystem on #{dns_name} to #{device}"
354
- remote_handler().create_filesystem("ext3", device)
354
+ status = remote_handler().create_filesystem("ext3", device)
355
+ if status == false
356
+ raise Exception.new("failed to create ext3 filesystem on #{device} device on #{dns_name}")
357
+ end
355
358
  post_message("filesystem system successfully created")
356
359
  end
357
360
 
@@ -403,8 +406,24 @@ module StateTransitionHelper
403
406
  post_message("going to start copying files to #{destination_path}. This may take quite a time...")
404
407
  @logger.debug "start copying to #{destination_path}"
405
408
  start = Time.new.to_i
406
- remote_handler().local_rsync("/", "#{destination_path}", "#{destination_path}")
407
- remote_handler().local_rsync("/dev/", "#{destination_path}/dev/")
409
+ if remote_handler().tools_installed?("rsync")
410
+ @logger.debug "use rsync command line"
411
+ status = remote_handler().local_rsync("/", "#{destination_path}", "#{destination_path}")
412
+ status = remote_handler().local_rsync("/dev/", "#{destination_path}/dev/")
413
+ if status == false
414
+ raise Exception.new("failed to copy distribution remotely using rsync")
415
+ end
416
+ else
417
+ @logger.debug "use cp command line"
418
+ status = remote_handler().local_rcopy("/", "#{destination_path}", "/proc /sys /dev /mnt")
419
+ if status == false
420
+ raise Exception.new("failed to copy distribution remotely using cp")
421
+ end
422
+ status = remote_handler().mkdir("#{destination_path}/proc")
423
+ status = remote_handler().mkdir("#{destination_path}/sys")
424
+ status = remote_handler().mkdir("#{destination_path}/mnt")
425
+ status = remote_handler().mkdir("#{destination_path}/dev")
426
+ end
408
427
  endtime = Time.new.to_i
409
428
  @logger.info "copy took #{(endtime-start)}s"
410
429
  post_message("copying is done (took #{endtime-start})s")
@@ -2,6 +2,7 @@ require "help/script_execution_state"
2
2
  require "scripts/ec2/ec2_script"
3
3
  require "help/remote_command_handler"
4
4
  #require "help/dm_crypt_helper"
5
+ require "help/ec2_helper"
5
6
  require "AWS"
6
7
 
7
8
  # Creates a bootable EBS storage from an existing AMI.
@@ -108,7 +109,8 @@ class Ami2EbsConversion < Ec2Script
108
109
  # File system created. Mount it.
109
110
  class FileSystemCreated < Ami2EbsConversionState
110
111
  def enter
111
- @context[:mount_dir] = "/mnt/tmp_#{@context[:volume_id]}"
112
+ #@context[:mount_dir] = "/mnt/tmp_#{@context[:volume_id]}"
113
+ @context[:mount_dir] = "/ebs_#{@context[:volume_id]}"
112
114
  mount_fs(@context[:mount_dir], @context[:temp_device_name])
113
115
  FileSystemMounted.new(@context)
114
116
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 5
8
- - 17
9
- version: 1.5.17
8
+ - 18
9
+ version: 1.5.18
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matthias Jung
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-19 00:00:00 +02:00
17
+ date: 2010-10-06 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency