Class: Elasticsnap::EbsSnapshot

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(security_group: nil, cluster_name: nil) ⇒ EbsSnapshot

Returns a new instance of EbsSnapshot.

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'lib/elasticsnap/ebs_snapshot.rb', line 10

def initialize(security_group: nil, cluster_name: nil)
  raise ArgumentError, 'security_group required' if security_group.nil?
  @security_group = security_group
  @cluster_name = cluster_name
end

Instance Attribute Details

#cluster_nameObject

Returns the value of attribute cluster_name.



8
9
10
# File 'lib/elasticsnap/ebs_snapshot.rb', line 8

def cluster_name
  @cluster_name
end

#security_groupObject

Returns the value of attribute security_group.



7
8
9
# File 'lib/elasticsnap/ebs_snapshot.rb', line 7

def security_group
  @security_group
end

Instance Method Details

#snapshotObject



16
17
18
19
20
21
22
# File 'lib/elasticsnap/ebs_snapshot.rb', line 16

def snapshot
  SecurityGroup.new(name: security_group).volumes(cluster_name: cluster_name).map do |volume|
    snapshot = volume.snapshot("Created by Elasticsnap from #{volume.id}")
    snapshot = wrap_snapshot(snapshot)
    snapshot.add_volume_tags(volume)
  end
end

#wrap_snapshot(snapshot) ⇒ Object



24
25
26
27
28
# File 'lib/elasticsnap/ebs_snapshot.rb', line 24

def wrap_snapshot(snapshot)
  snapshot = Fog::Compute::AWS::Snapshot.new(snapshot.body)
  snapshot.send(:extend, SnapshotVolumeTags)
  snapshot
end