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 +1 -1
- data/lib/help/state_transition_helper.rb +16 -3
- metadata +1 -1
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.
|
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("
|
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]}", "
|
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"
|