Class: Fog::AWS::EC2::Volume

Inherits:
Model
  • Object
show all
Extended by:
Deprecation
Defined in:
lib/fog/aws/models/ec2/volume.rb

Instance Attribute Summary

Attributes inherited from Model

#connection

Instance Method Summary collapse

Methods included from Deprecation

deprecate

Methods inherited from Model

#_dump, _load, aliases, attribute, attributes, #attributes, #collection, identity, #identity, #inspect, #merge_attributes, #new_record?, #reload, #requires, #to_json, #wait_for

Constructor Details

#initialize(attributes = {}) ⇒ Volume

Returns a new instance of Volume.



22
23
24
25
26
27
# File 'lib/fog/aws/models/ec2/volume.rb', line 22

def initialize(attributes = {})
  if attributes['attachmentSet']
    attributes.merge!(attributes.delete('attachmentSet').first || {})
  end
  super
end

Instance Method Details

#destroyObject



29
30
31
32
33
34
# File 'lib/fog/aws/models/ec2/volume.rb', line 29

def destroy
  requires :id

  connection.delete_volume(@id)
  true
end

#saveObject



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fog/aws/models/ec2/volume.rb', line 46

def save
  requires :availability_zone, :size

  data = connection.create_volume(@availability_zone, @size, @snapshot_id).body
  new_attributes = data.reject {|key,value| key == 'requestId'}
  merge_attributes(new_attributes)
  if @server
    self.server = @server
  end
  true
end

#server=(new_server) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/fog/aws/models/ec2/volume.rb', line 36

def server=(new_server)
  requires :device

  if new_server
    attach(new_server)
  else
    detach
  end
end

#snapshotsObject



58
59
60
61
62
# File 'lib/fog/aws/models/ec2/volume.rb', line 58

def snapshots
  requires :id

  connection.snapshots(:volume => self)
end