stemcell 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/stem +6 -0
- data/lib/stemcell/version.rb +1 -1
- data/lib/stemcell.rb +23 -1
- metadata +1 -1
data/bin/stem
CHANGED
data/lib/stemcell/version.rb
CHANGED
data/lib/stemcell.rb
CHANGED
@@ -29,6 +29,22 @@ module Stemcell
|
|
29
29
|
@timeout = 120
|
30
30
|
@start_time = Time.new
|
31
31
|
|
32
|
+
@tags = {
|
33
|
+
'Name' => "#{@chef_role}-#{@git_branch}",
|
34
|
+
'Group' => "#{@chef_role}-#{@git_branch}",
|
35
|
+
'created_by' => ENV['USER'],
|
36
|
+
'stemcell' => VERSION,
|
37
|
+
}
|
38
|
+
|
39
|
+
if opts['tags']
|
40
|
+
tags = {}
|
41
|
+
opts['tags'].split(',').each do |tag_set|
|
42
|
+
key, value = tag_set.split('=')
|
43
|
+
tags[key] = value
|
44
|
+
end
|
45
|
+
@tags.merge!(tags)
|
46
|
+
end
|
47
|
+
|
32
48
|
begin
|
33
49
|
@git_key_contents = File.read(@git_key)
|
34
50
|
rescue Object => e
|
@@ -57,6 +73,7 @@ module Stemcell
|
|
57
73
|
File.open('/tmp/user-data', 'w') {|f| f.write(@user_data) }
|
58
74
|
instances = do_launch(opts)
|
59
75
|
wait(instances)
|
76
|
+
set_tags(instances)
|
60
77
|
print_run_info(instances)
|
61
78
|
return instances
|
62
79
|
end
|
@@ -101,7 +118,6 @@ module Stemcell
|
|
101
118
|
}
|
102
119
|
options.merge!({:availability_zone => opts['avilibility_zone']}) if opts['availability_zone']
|
103
120
|
options.merge!({:count => opts['count']}) if opts['count']
|
104
|
-
puts "creating instance with options:\n#{options}"
|
105
121
|
instances = @ec2_region.instances.create(options)
|
106
122
|
instances = [instances] unless instances.class == Array
|
107
123
|
instances.each do |instance|
|
@@ -110,6 +126,12 @@ module Stemcell
|
|
110
126
|
return instances
|
111
127
|
end
|
112
128
|
|
129
|
+
def set_tags(instances=[])
|
130
|
+
instances.each do |instance|
|
131
|
+
instance.tags.set(@tags)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
113
135
|
def render_template
|
114
136
|
this_file = File.expand_path __FILE__
|
115
137
|
base_dir = File.dirname this_file
|