Class: Fog::AWS::EC2::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::AWS::EC2::Volume
show all
- Defined in:
- lib/fog/aws/models/ec2/volume.rb
Instance Attribute Summary
Attributes inherited from Model
#connection
Instance Method Summary
collapse
Methods inherited from Model
#_dump, _load, aliases, attribute, attributes, #attributes, #collection, identity, #identity, #inspect, #merge_attributes, #new_record?, #reload, #requires, #wait_for
Constructor Details
#initialize(attributes = {}) ⇒ Volume
Returns a new instance of Volume.
20
21
22
23
24
25
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 20
def initialize(attributes = {})
if attributes['attachmentSet']
attributes.merge!(attributes.delete('attachmentSet').first || {})
end
super
end
|
Instance Method Details
#destroy ⇒ Object
27
28
29
30
31
32
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 27
def destroy
requires :id
connection.delete_volume(@id)
true
end
|
#save ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 44
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
34
35
36
37
38
39
40
41
42
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 34
def server=(new_server)
requires :device
if new_server
attach(new_server)
else
detach
end
end
|
#snapshots ⇒ Object
56
57
58
59
60
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 56
def snapshots
requires :id
connection.snapshots(:volume => self)
end
|