ebs_snapper 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,8 +42,13 @@ class EbsSnapper::Ebs
42
42
  each_region do |r|
43
43
  r.tags.filter('resource-type', 'volume').filter('key', @tag_name).each do |tag|
44
44
  # if the tag exists, it's using the default retention (TTL)
45
+ ttl_value = @retain
46
+ if tag.value != nil && !tag.value.strip.empty?
47
+ ttl_value = tag.value.strip
48
+ end
49
+
45
50
  volumes << {
46
- :ttl => TTL.new(@retain),
51
+ :ttl => TTL.new(ttl_value),
47
52
  :region => r,
48
53
  :volume_id => tag.resource.id # volume id
49
54
  }
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module EbsSnapper
16
- VERSION = "0.0.3"
16
+ VERSION = "0.0.4"
17
17
  end
data/spec/lib/ebs_spec.rb CHANGED
@@ -40,6 +40,42 @@ describe EbsSnapper::Ebs do
40
40
  vols[0][:region].id.should == region.id
41
41
  vols[0][:volume_id].should == tag.resource.id
42
42
  vols[0][:ttl].should_not == nil
43
+
44
+ two_days_secs = EbsSnapper::Ebs::TTL.new().convert_to_seconds(0).to_i
45
+ span_begin = (Time.now.utc.to_i - two_days_secs) - 10
46
+ span_end = (Time.now.utc.to_i - two_days_secs) + 1
47
+ vols[0][:ttl].cut_off.should > span_begin
48
+ vols[0][:ttl].cut_off.should < span_end
49
+ end
50
+
51
+ it "should use retention from the tag in a volume in a region" do
52
+ ebs = EbsSnapper::Ebs.new
53
+
54
+ tag = OpenStruct.new
55
+ tag.resource = OpenStruct.new(:id => 1)
56
+ tag.value = "2.days"
57
+
58
+ tags = [tag]
59
+ tags.stub(:filter).and_return(tags)
60
+
61
+ region = OpenStruct.new
62
+ region.tags = tags
63
+ region.id = '999'
64
+
65
+ ebs.stub(:each_region).and_yield(region)
66
+
67
+ vols = ebs.tagged_volumes
68
+ vols.size.should == 1
69
+
70
+ vols[0][:region].id.should == region.id
71
+ vols[0][:volume_id].should == tag.resource.id
72
+ vols[0][:ttl].should_not == nil
73
+
74
+ two_days_secs = EbsSnapper::Ebs::TTL.new().convert_to_seconds('2.days').to_i
75
+ span_begin = (Time.now.utc.to_i - two_days_secs) - 10
76
+ span_end = (Time.now.utc.to_i - two_days_secs) + 1
77
+ vols[0][:ttl].cut_off.should > span_begin
78
+ vols[0][:ttl].cut_off.should < span_end
43
79
  end
44
80
 
45
81
  it "should pruge old timestamps" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebs_snapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
- requirement: &2157108240 !ruby/object:Gem::Requirement
16
+ requirement: &2153739880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2157108240
24
+ version_requirements: *2153739880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &2157106140 !ruby/object:Gem::Requirement
27
+ requirement: &2153739420 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2157106140
35
+ version_requirements: *2153739420
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2157104840 !ruby/object:Gem::Requirement
38
+ requirement: &2153738940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2157104840
46
+ version_requirements: *2153738940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: fakeweb
49
- requirement: &2157103500 !ruby/object:Gem::Requirement
49
+ requirement: &2153738480 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2157103500
57
+ version_requirements: *2153738480
58
58
  description: Manage snapshots of EBS volumes
59
59
  email:
60
60
  - ultradns@neustar.biz