Class: Aebus::EC2::Snapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/ec2/snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Snapshot

Returns a new instance of Snapshot.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ec2/snapshot.rb', line 16

def initialize(hash)

  raise(ArgumentError,"hash cannot be nil") unless hash
  @keep
  @id = hash.snapshotId
  @start_time = Time.parse(hash.startTime)
  @volume_id = hash.volumeId
  @tags = Hash.new
  if (hash.tagSet) then
    tag_array = hash.tagSet.item
    tag_array.each do |tag|
      @tags.store(tag["key"],tag["value"])
    end
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/ec2/snapshot.rb', line 14

def id
  @id
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



14
15
16
# File 'lib/ec2/snapshot.rb', line 14

def start_time
  @start_time
end

#tagsObject (readonly)

Returns the value of attribute tags.



14
15
16
# File 'lib/ec2/snapshot.rb', line 14

def tags
  @tags
end

#volume_idObject (readonly)

Returns the value of attribute volume_id.



14
15
16
# File 'lib/ec2/snapshot.rb', line 14

def volume_id
  @volume_id
end

Instance Method Details

#aebus_removable_snapshot?Boolean

Returns:

  • (Boolean)


47
48
49
50
# File 'lib/ec2/snapshot.rb', line 47

def aebus_removable_snapshot?
  return false unless aebus_snapshot?
  (aebus_tags & [AEBUS_MANUAL_TAG, AEBUS_KEEP_TAG]).count == 0
end

#aebus_snapshot?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/ec2/snapshot.rb', line 43

def aebus_snapshot?
  @tags.include?(AEBUS_TAG)
end

#aebus_tagsObject



52
53
54
# File 'lib/ec2/snapshot.rb', line 52

def aebus_tags
  @tags[AEBUS_TAG].split(',')
end

#aebus_tags_include?(label) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
# File 'lib/ec2/snapshot.rb', line 36

def aebus_tags_include?(label)
  if aebus_snapshot? then
    return aebus_tags.include? label
  end
  false
end

#keep=(value) ⇒ Object



56
57
58
# File 'lib/ec2/snapshot.rb', line 56

def keep= value
  @keep = value
end

#keep?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/ec2/snapshot.rb', line 60

def keep?
  @keep
end

#to_sObject



32
33
34
# File 'lib/ec2/snapshot.rb', line 32

def to_s
  "{snapshot_id => #{@id}, volume_id => #{@volume_id},  start_time => #{@start_time}, tags => #{@tags} "
end