Class: Appshot::EBS_Prune

Inherits:
Object
  • Object
show all
Defined in:
lib/appshot/volume/ebs_prune.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ EBS_Prune

Returns a new instance of EBS_Prune.



3
4
5
6
7
8
9
10
# File 'lib/appshot/volume/ebs_prune.rb', line 3

def initialize(opts={})
  @volume_id = opts[:volume_id] || ""
  @snapshots_to_keep = opts[:snapshots_to_keep] || 5
  @minimum_retention_days = opts[:minimum_retention_days] || 3
  @region                = opts[:region] unless opts[:region].nil?
  @aws_secret_access_key = opts[:aws_secret_access_key] || ""
  @aws_access_key_id     = opts[:aws_access_key_id] || ""
end

Instance Method Details

#call(call_chain = []) ⇒ Object



12
13
14
15
16
# File 'lib/appshot/volume/ebs_prune.rb', line 12

def call(call_chain=[])
  next_action = call_chain.shift
  prune_snapshots if valid?
  next_action.call(call_chain) unless next_action.nil?
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/appshot/volume/ebs_prune.rb', line 18

def valid?
  raise ArgumentError.new "volume_id must be specified for an ebs_prune" if @volume_id.empty?
  raise ArgumentError.new "aws_access_key_id must be specified for an ebs_prune" if @aws_access_key_id.empty?
  raise ArgumentError.new "aws_secret_access_key must be specified for an ebs_prune" if @aws_secret_access_key.empty?
  true
end