Class: Fog::AWS::Compute::Volume
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
deprecate
Methods inherited from Model
#inspect, #reload, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires
Constructor Details
#initialize(attributes = {}) ⇒ Volume
Returns a new instance of Volume.
23
24
25
26
27
|
# File 'lib/fog/aws/models/compute/volume.rb', line 23
def initialize(attributes = {})
self.server = attributes.delete(:server)
super
end
|
Instance Method Details
#destroy ⇒ Object
29
30
31
32
33
34
|
# File 'lib/fog/aws/models/compute/volume.rb', line 29
def destroy
requires :id
connection.delete_volume(@id)
true
end
|
#ready? ⇒ Boolean
36
37
38
|
# File 'lib/fog/aws/models/compute/volume.rb', line 36
def ready?
state == 'available'
end
|
#save ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/fog/aws/models/compute/volume.rb', line 40
def save
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
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
53
54
55
56
57
58
59
|
# File 'lib/fog/aws/models/compute/volume.rb', line 53
def server=(new_server)
if new_server
attach(new_server)
else
detach
end
end
|
#snapshots ⇒ Object
61
62
63
64
|
# File 'lib/fog/aws/models/compute/volume.rb', line 61
def snapshots
requires :id
connection.snapshots(:volume => self)
end
|