aebus 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/aebus.rb +14 -11
  2. data/lib/aebus/version.rb +1 -1
  3. metadata +10 -10
@@ -62,7 +62,7 @@ module Aebus
62
62
  vs.delay = to_be_run[0]
63
63
  vs.tags = to_be_run[1]
64
64
 
65
- if (vs.needs_backup?) then
65
+ if vs.needs_backup?
66
66
  logger.info("Volume #{target} needs to be backed up. Tags: #{vs.tags.join(',')}, max delay #{vs.delay}")
67
67
  to_backup += 1
68
68
  else
@@ -105,6 +105,9 @@ module Aebus
105
105
  :server => EC2::zone_to_url(@config.defaults["zone"]))
106
106
 
107
107
  target_volumes = target_volumes(args)
108
+
109
+ abort("Configuration contains invalid volumes") unless validate_target_volumes(target_volumes)
110
+
108
111
  if (options.manual) then
109
112
 
110
113
  target_volumes.each do |volume|
@@ -124,7 +127,7 @@ module Aebus
124
127
  to_be_run = volume.backups_to_be_run(snap_map[target], @current_time_utc)
125
128
  max_delay = [max_delay, to_be_run[0]].max
126
129
  tags = to_be_run[1]
127
- if (tags.count > 0) then
130
+ if tags.count > 0
128
131
  tags << EC2::AEBUS_AUTO_TAG
129
132
  logger.info("Creating backup for volume #{target} with tags #{tags.join(',')}, max delay #{max_delay}")
130
133
  to_backup +=1
@@ -137,7 +140,7 @@ module Aebus
137
140
  end
138
141
 
139
142
  snap_map = get_snapshots_map # we reload the map since we may have created more snapshots
140
- if (options.purge) then
143
+ if options.purge then
141
144
  target_volumes.each do |target|
142
145
  volume = @config.volumes[target]
143
146
  purgeable_snapshot_ids = volume.purgeable_snapshot_ids(snap_map[target])
@@ -153,10 +156,10 @@ module Aebus
153
156
 
154
157
  end
155
158
 
156
- message = "Backup Completed at #{Time.now}. Checked #{target_volumes.count} volume(s), backed up #{backed_up}, max delay detected #{max_delay}, #{to_purge} purgeable snapshot(s), #{purged} purged"
159
+ message = "Backup Completed at #{Time.now}. Checked #{target_volumes.count} volume(s), #{to_backup} to be backed up, #{backed_up} actually backed up, max delay detected #{max_delay}s, #{to_purge} purgeable snapshot(s), #{purged} purged"
157
160
  logger.info(message)
158
161
  puts(message)
159
- if to_backup > 0 or to_backup > 0 then
162
+ if to_backup > 0 or to_purge > 0 then
160
163
  send_report message
161
164
  end
162
165
  end
@@ -164,7 +167,7 @@ module Aebus
164
167
  def target_volumes(args)
165
168
 
166
169
  result = @config.volume_ids
167
- if (args && (args.count > 0)) then
170
+ if args && (args.count > 0) then
168
171
  result &= args
169
172
  end
170
173
 
@@ -225,7 +228,7 @@ module Aebus
225
228
  name = "backup_#{utc_time.strftime("%Y%m%d")}_#{volume_id}"
226
229
  volume_name = volume_id
227
230
  tags.each do |tag|
228
- if tag["key"].eql?(AWS_NAME_TAG) then
231
+ if tag["key"].eql?(AWS_NAME_TAG)
229
232
  volume_name = tag["value"]
230
233
  break
231
234
  end
@@ -244,7 +247,7 @@ module Aebus
244
247
  result = Hash.new
245
248
  snap_array.each do |snap|
246
249
  snapshot = EC2::Snapshot.new(snap)
247
- if (result.include?(snapshot.volume_id)) then
250
+ if result.include?(snapshot.volume_id)
248
251
  vol_array = result[snapshot.volume_id]
249
252
  index = vol_array.index{ |s| snapshot.start_time > s.start_time}
250
253
  index ||= vol_array.count
@@ -262,7 +265,7 @@ module Aebus
262
265
  def purge_snapshot(snapshot_id)
263
266
  begin
264
267
  response = @ec2.delete_snapshot(:snapshot_id => snapshot_id)
265
- if (response["return"]) then
268
+ if response["return"]
266
269
  logger.info("Purged snapshot #{snapshot_id}")
267
270
  true
268
271
  else
@@ -288,13 +291,13 @@ module Aebus
288
291
  end
289
292
 
290
293
  def send_report(message)
291
- if message.nil? then
294
+ if message.nil?
292
295
  logger.warn("Tried to send a message, but no message was specified")
293
296
  return
294
297
  end
295
298
  to_address = @config.defaults["to_address"]
296
299
  from_address = @config.defaults["from_address"]
297
- if to_address.nil? or from_address.nil? then
300
+ if to_address.nil? or from_address.nil?
298
301
  logger.warn("Tried to send a message but either to or from address where missing from configuration")
299
302
  return
300
303
  end
@@ -1,3 +1,3 @@
1
1
  module Aebus
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aebus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
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: 2011-12-02 00:00:00.000000000Z
12
+ date: 2012-02-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
16
- requirement: &70244299589980 !ruby/object:Gem::Requirement
16
+ requirement: &70205690834260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.0.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70244299589980
24
+ version_requirements: *70205690834260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: parse-cron
27
- requirement: &70244299589460 !ruby/object:Gem::Requirement
27
+ requirement: &70205690826400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.1.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70244299589460
35
+ version_requirements: *70205690826400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: amazon-ec2
38
- requirement: &70244299589000 !ruby/object:Gem::Requirement
38
+ requirement: &70205690825740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.17
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70244299589000
46
+ version_requirements: *70205690825740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: aws-ses
49
- requirement: &70244299588540 !ruby/object:Gem::Requirement
49
+ requirement: &70205690824640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.4.4
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70244299588540
57
+ version_requirements: *70205690824640
58
58
  description: A tool to automate snapshot management in EC2
59
59
  email:
60
60
  - nessche@gmail.com