stem 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,4 +16,5 @@ require 'stem/tag'
16
16
 
17
17
  module Stem
18
18
  autoload :Family, 'stem/family'
19
+ class Deprecated < StandardError; end
19
20
  end
@@ -33,13 +33,17 @@ module Stem
33
33
  end
34
34
 
35
35
  def capture(instance_id)
36
- Stem::Image.create(name, instance_id, tags)
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,
@@ -4,21 +4,10 @@ module Stem
4
4
  extend self
5
5
 
6
6
  def create name, instance, tags = {}
7
- image_id = swirl.call("CreateImage", "Name" => name, "InstanceId" => instance)["imageId"]
8
- unless tags.empty?
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
- image_id
10
+ swirl.call("CreateImage", "Name" => name, "InstanceId" => instance)["imageId"]
22
11
  end
23
12
 
24
13
  def deregister image
@@ -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
- response = swirl.call "RunInstances", opt
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
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: stem
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.0
5
+ version: 0.8.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Peter van Hardenberg