stem 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/stem.rb +1 -0
- data/lib/stem/family/member.rb +5 -1
- data/lib/stem/image.rb +3 -14
- data/lib/stem/instance.rb +5 -16
- metadata +1 -1
data/lib/stem.rb
CHANGED
data/lib/stem/family/member.rb
CHANGED
@@ -33,13 +33,17 @@ module Stem
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def capture(instance_id)
|
36
|
-
Stem::Image.create(name, instance_id
|
36
|
+
Stem::Image.create(name, instance_id)
|
37
37
|
end
|
38
38
|
|
39
39
|
def name
|
40
40
|
[family, timestamp.gsub(':', '_'), architecture].join('-')
|
41
41
|
end
|
42
42
|
|
43
|
+
def tag(ami_id)
|
44
|
+
Stem::Tag.create(ami_id, tags)
|
45
|
+
end
|
46
|
+
|
43
47
|
def tags
|
44
48
|
{
|
45
49
|
:created => timestamp,
|
data/lib/stem/image.rb
CHANGED
@@ -4,21 +4,10 @@ module Stem
|
|
4
4
|
extend self
|
5
5
|
|
6
6
|
def create name, instance, tags = {}
|
7
|
-
|
8
|
-
|
9
|
-
# We'll retry this once if necessary due to consistency issues on the AWS side
|
10
|
-
i = 0
|
11
|
-
begin
|
12
|
-
Tag::create(image_id, tags)
|
13
|
-
rescue Swirl::InvalidRequest => e
|
14
|
-
if i < 5 && e.message =~ /does not exist/
|
15
|
-
i += 1
|
16
|
-
retry
|
17
|
-
end
|
18
|
-
raise e
|
19
|
-
end
|
7
|
+
unless tags == {}
|
8
|
+
raise Stem::Deprecated.new "Tags should be created separately due to AWS eventual consistency issues"
|
20
9
|
end
|
21
|
-
|
10
|
+
swirl.call("CreateImage", "Name" => name, "InstanceId" => instance)["imageId"]
|
22
11
|
end
|
23
12
|
|
24
13
|
def deregister image
|
data/lib/stem/instance.rb
CHANGED
@@ -5,6 +5,10 @@ module Stem
|
|
5
5
|
|
6
6
|
def launch config, userdata = nil
|
7
7
|
throw "No config provided" unless config
|
8
|
+
if config['tags'] && config['tags'] != {}
|
9
|
+
raise Stem::Deprecated.new "Tags should be created separately due to AWS eventual consistency issues"
|
10
|
+
end
|
11
|
+
|
8
12
|
config = aggregate_hash_options_for_ami!(config)
|
9
13
|
ami = config["ami"]
|
10
14
|
|
@@ -37,22 +41,7 @@ module Stem
|
|
37
41
|
opt.merge!({ "UserData" => Base64.encode64(userdata)})
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
|
-
instance_id = response["instancesSet"].first["instanceId"]
|
42
|
-
|
43
|
-
if config['tags'] && !config['tags'].empty?
|
44
|
-
i = 0
|
45
|
-
begin
|
46
|
-
Tag::create(instance_id, config['tags'])
|
47
|
-
rescue Swirl::InvalidRequest => e
|
48
|
-
if i < 5 && e.message =~ /does not exist/
|
49
|
-
i += 1
|
50
|
-
retry
|
51
|
-
end
|
52
|
-
raise e
|
53
|
-
end
|
54
|
-
end
|
55
|
-
instance_id
|
44
|
+
swirl.call("RunInstances", opt)["instancesSet"].first["instanceId"]
|
56
45
|
end
|
57
46
|
|
58
47
|
def restart instance_id
|