ebs_snapper 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # EbsSnapper
2
2
 
3
- Take snapshots of EBS volumes and keep them for a period of time. We use it take nightly snapshots and retain them for a several days before they are purged.
3
+ Take snapshots of EBS volumes and keep them for a period of time.
4
+ We use this to take nightly snapshots and retain them for several days before being purged.
4
5
 
5
6
 
6
7
 
@@ -32,7 +32,7 @@ class EbsSnapper::Ebs
32
32
  # now snapshot the list
33
33
  tagged_volumes.each do |vol_info|
34
34
  snapshot_volume(vol_info[:region], vol_info[:volume_id])
35
- purge_old_snapshots(vol_info[:region], vol_info[:volume_id])
35
+ purge_old_snapshots(vol_info[:ttl], vol_info[:region], vol_info[:volume_id])
36
36
  end
37
37
  end
38
38
 
@@ -69,7 +69,7 @@ class EbsSnapper::Ebs
69
69
  region.snapshots.filter('volume-id', vol_id).filter('tag-key', @tag_name).each do |snapshot|
70
70
  unless snapshot.status == :pending
71
71
  ts = snapshot.tags[@tag_name]
72
- if ts > 0 && ttl.purge?(ts)
72
+ if ttl.purge?(ts)
73
73
  @logger.info {"Purging #{vol_id} snapshot: #{snapshot}"}
74
74
  snapshot.delete
75
75
  end
@@ -98,7 +98,8 @@ class EbsSnapper::Ebs
98
98
  end
99
99
 
100
100
  def purge?(timestamp)
101
- timestamp < @cut_off
101
+ ts = timestamp.to_i
102
+ ts > 0 && (ts < @cut_off)
102
103
  end
103
104
 
104
105
  def convert_to_seconds(ttl)
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module EbsSnapper
16
- VERSION = "0.0.2"
16
+ VERSION = "0.0.3"
17
17
  end
data/spec/lib/ebs_spec.rb CHANGED
@@ -46,6 +46,7 @@ describe EbsSnapper::Ebs do
46
46
  ttl = EbsSnapper::Ebs::TTL.new("1.day") # 1 day
47
47
  ttl.purge?(Time.now.utc.to_i - (86400 * 3)).should == true
48
48
  ttl.purge?(Time.now.utc.to_i - (86400 + 3601)).should == true
49
+ ttl.purge?("#{Time.now.utc.to_i - (86400 + 3601)}").should == true
49
50
  end
50
51
 
51
52
  it "shouldn't pruge new timestamps" do
@@ -140,4 +141,17 @@ describe EbsSnapper::Ebs do
140
141
  ebs.purge_old_snapshots(ttl, region, 2)
141
142
  end
142
143
 
144
+ it "should flow through snapshot and purge" do
145
+ ebs = EbsSnapper::Ebs.new
146
+ ebs.stub(:tagged_volumes).and_return([{
147
+ :ttl => EbsSnapper::Ebs::TTL.new("1.day"),
148
+ :region => 'us-east-1',
149
+ :volume_id => 1
150
+ }])
151
+
152
+ ebs.should_receive(:snapshot_volume).with(anything(), anything()).once.and_return()
153
+ ebs.should_receive(:purge_old_snapshots).with(anything(), anything(), anything()).once.and_return()
154
+
155
+ ebs.snapshot_and_purge()
156
+ end
143
157
  end
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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-21 00:00:00.000000000Z
12
+ date: 2012-07-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
- requirement: &2152830900 !ruby/object:Gem::Requirement
16
+ requirement: &2157108240 !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: *2152830900
24
+ version_requirements: *2157108240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &2152830480 !ruby/object:Gem::Requirement
27
+ requirement: &2157106140 !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: *2152830480
35
+ version_requirements: *2157106140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2152830060 !ruby/object:Gem::Requirement
38
+ requirement: &2157104840 !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: *2152830060
46
+ version_requirements: *2157104840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: fakeweb
49
- requirement: &2152829640 !ruby/object:Gem::Requirement
49
+ requirement: &2157103500 !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: *2152829640
57
+ version_requirements: *2157103500
58
58
  description: Manage snapshots of EBS volumes
59
59
  email:
60
60
  - ultradns@neustar.biz