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.
18
19
20
21
22
23
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 18
def initialize(attributes = {})
if attributes['attachmentSet']
attributes.merge!(attributes.delete('attachmentSet').first || {})
end
super
end
|
Instance Method Details
#destroy ⇒ Object
25
26
27
28
29
30
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 25
def destroy
requires :id
connection.delete_volume(@id)
true
end
|
#instance=(new_instance) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 32
def instance=(new_instance)
if new_instance
attach(new_instance)
else
detach
end
end
|
#save ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 40
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 @instance
self.instance = @instance
end
true
end
|
#snapshots ⇒ Object
52
53
54
55
56
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 52
def snapshots
requires :id
connection.snapshots(:volume => self)
end
|