Class: Fog::Rackspace::BlockStorage::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::Rackspace::BlockStorage::Volume
show all
- Defined in:
- lib/fog/rackspace/models/block_storage/volume.rb
Constant Summary
collapse
- AVAILABLE =
'available'
- ATTACHING =
'attaching'
- CREATING =
'creating'
- DELETING =
'deleting'
- ERROR =
'error'
- ERROR_DELETING =
'error_deleting'
- IN_USE =
'in-use'
Instance Attribute Summary
Attributes inherited from Model
#collection, #service
Instance Method Summary
collapse
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#connection, #connection=, #prepare_service_value
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#attached? ⇒ Boolean
30
31
32
|
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 30
def attached?
state == IN_USE
end
|
#create_snapshot(options = {}) ⇒ Object
38
39
40
41
|
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 38
def create_snapshot(options={})
requires :identity
service.snapshots.create(options.merge(:volume_id => identity))
end
|
#destroy ⇒ Object
56
57
58
59
60
|
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 56
def destroy
requires :identity
service.delete_volume(identity)
true
end
|
#ready? ⇒ Boolean
26
27
28
|
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 26
def ready?
state == AVAILABLE
end
|
#save ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 43
def save
requires :size
raise IdentifierTaken.new('Resaving may cause a duplicate volume to be created') if persisted?
data = service.create_volume(size, {
:display_name => display_name,
:display_description => display_description,
:volume_type => volume_type,
:availability_zone => availability_zone
})
merge_attributes(data.body['volume'])
true
end
|
#snapshots ⇒ Object
34
35
36
|
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 34
def snapshots
service.snapshots.select { |s| s.volume_id == identity }
end
|