Class: Fog::AWS::EC2::Volume
Instance Attribute Summary
Attributes inherited from Model
#connection
Instance Method Summary
collapse
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
#destroy ⇒ Object
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
|
#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
36
37
38
39
40
41
42
|
# File 'lib/fog/aws/models/ec2/volume.rb', line 36
def server=(new_server)
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
|