Class: Appshot::EBS_Snapshot

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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ EBS_Snapshot

Returns a new instance of EBS_Snapshot.



5
6
7
8
9
10
11
# File 'lib/appshot/volume/ebs_snapshot.rb', line 5

def initialize(opts={})
  @volume_id             = opts[:volume_id] || ""
  @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] || ""
  @description           = opts[:description] || "Standard Snapshot #{Time.now.utc}"
end

Instance Method Details

#call(call_chain = []) ⇒ Object



13
14
15
16
17
# File 'lib/appshot/volume/ebs_snapshot.rb', line 13

def call(call_chain=[])
  next_action = call_chain.shift
  ebs_volume.snap(@volume_id, @description) if valid?
  next_action.call(call_chain) unless next_action.nil?
end

#valid?Boolean

Returns:

  • (Boolean)


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

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