stem 0.4.8 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
data/lib/stem/image.rb CHANGED
@@ -12,7 +12,7 @@ module Stem
12
12
  begin
13
13
  Tag::create(image_id, tags)
14
14
  rescue Swirl::InvalidRequest => e
15
- if i < 1 && e.message =~ /does not exist/
15
+ if i < 5 && e.message =~ /does not exist/
16
16
  i += 1
17
17
  retry
18
18
  end
@@ -27,8 +27,9 @@ module Stem
27
27
  end
28
28
 
29
29
  def named name
30
- i = swirl.call "DescribeImages", "Owner" => "self"
31
- ami = i["imagesSet"].select {|m| m["name"] == name }.map { |m| m["imageId"] }.first
30
+ opts = get_filter_opts("name" => name).merge("Owner" => "self")
31
+ i = swirl.call("DescribeImages", opts)["imagesSet"].first
32
+ i ? i["imageId"] : nil
32
33
  end
33
34
 
34
35
  def tagged tags
data/lib/stem/instance.rb CHANGED
@@ -50,7 +50,18 @@ module Stem
50
50
  response = swirl.call "RunInstances", opt
51
51
  instance_id = response["instancesSet"].first["instanceId"]
52
52
 
53
- Tag::create(instance_id, config['tags']) if config['tags'] && !config['tags'].empty?
53
+ if config['tags'] && !config['tags'].empty?
54
+ i = 0
55
+ begin
56
+ Tag::create(instance_id, config['tags'])
57
+ rescue Swirl::InvalidRequest => e
58
+ if i < 5 && e.message =~ /does not exist/
59
+ i += 1
60
+ retry
61
+ end
62
+ raise e
63
+ end
64
+ end
54
65
  instance_id
55
66
  end
56
67
 
data/lib/stem/userdata.rb CHANGED
@@ -17,6 +17,8 @@ module Stem
17
17
  process_erb(opts[:erb_binding])
18
18
  process_mustache(opts[:mustache_vars])
19
19
  raise "must contain a userdata.sh" unless File.exists?("userdata.sh")
20
+ # Set constant timestamps for all files to guarantee hashing consistency
21
+ set_all_timestamps(tmp_path, "200210272016")
20
22
  make_zip_shell
21
23
  end
22
24
  end
@@ -62,6 +64,18 @@ exec bash userdata.sh
62
64
  header + %x{tar --exclude \\*.stem -cv . | bzip2 --best -}
63
65
  end
64
66
 
67
+ def set_all_timestamps(file_or_dir, time)
68
+ Dir.foreach(file_or_dir) do |item|
69
+ path = file_or_dir + '/' + item
70
+ if File.directory?(path) && item != '.'
71
+ next if item == '..'
72
+ set_all_timestamps(path, time)
73
+ else
74
+ `touch -t #{time} #{path}`
75
+ end
76
+ end
77
+ end
78
+
65
79
  end
66
80
  end
67
81
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stem
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 8
10
- version: 0.4.8
9
+ - 9
10
+ version: 0.4.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter van Hardenberg