CloudyScripts 0.0.12 → 0.0.13

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 = '0.0.12'
15
+ s.version = '0.0.13'
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.'
@@ -68,12 +68,25 @@ module StateTransitionHelper
68
68
  def launch_instance
69
69
  @context[:script].post_message("starting up instance to execute the script (AMI = #{@context[:ami_id]}) ...")
70
70
  @logger.debug "start up AMI #{@context[:ami_id]}"
71
+ # find out the image architecture first
72
+ image_props = @context[:ec2_api_handler].describe_images(:image_id => @context[:ami_id])
73
+ architecture = image_props['imagesSet']['item'][0]['architecture']
74
+ instance_type = "m1.small"
75
+ if architecture != "i386"
76
+ instance_type = "m1.large"
77
+ end
78
+ arch_log_msg = "Architecture of image #{@context[:ami_id]} is #{architecture}. Use instance_type #{instance_type}."
79
+ @logger.info arch_log_msg
80
+ @context[:script].post_message(arch_log_msg)
81
+ # now start it
71
82
  res = @context[:ec2_api_handler].run_instances(:image_id => @context[:ami_id],
72
- :security_group => @context[:security_group_name], :key_name => @context[:key_name])
83
+ :security_group => @context[:security_group_name], :key_name => @context[:key_name],
84
+ :instance_type => instance_type
85
+ )
73
86
  instance_id = res['instancesSet']['item'][0]['instanceId']
74
87
  @context[:instance_id] = instance_id
75
88
  @logger.info "started instance #{instance_id}"
76
- @context[:script].post_message("started instance #{instance_id}. wait until it is ready...")
89
+ @context[:script].post_message("Started instance #{instance_id}. wait until it is ready...")
77
90
  #availability_zone , key_name/group_name
78
91
  started = false
79
92
  while started == false
@@ -340,7 +353,7 @@ module StateTransitionHelper
340
353
  @context[:script].post_message("going to start copying files to #{@context[:path]}. This may take quite a time...")
341
354
  @logger.debug "start copying to #{@context[:path]}"
342
355
  start = Time.new.to_i
343
- @context[:remote_command_handler].rsync("/", "#{@context[:path]}", "/mnt/")
356
+ @context[:remote_command_handler].rsync("/", "#{@context[:path]}", "#{@context[:path]}")
344
357
  @context[:remote_command_handler].rsync("/dev/", "#{@context[:path]}/dev/")
345
358
  endtime = Time.new.to_i
346
359
  @logger.info "copy took #{(endtime-start)}s"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CloudyScripts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Jung