Class: Fog::Rackspace::BlockStorage::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::Rackspace::BlockStorage::Volume
- 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 collapse
-
#attachments ⇒ Array<Hash>
readonly
Returns an array of hashes containing attachment information.
-
#availability_zone ⇒ String
readonly
Region of the volume.
-
#created_at ⇒ String
readonly
Volume creation date.
-
#display_description ⇒ String
Display description of volume.
-
#display_name ⇒ String
Display name of volume.
-
#id ⇒ String
readonly
The volume id.
-
#image_id ⇒ String
The ID of an image used to create a bootable volume.
-
#size ⇒ String
Size of the volume in GB (100 GB minimum).
-
#state ⇒ String
readonly
Volume status.
-
#volume_type ⇒ String
Type of volume.
Instance Method Summary collapse
-
#attached? ⇒ Boolean
Returns true if the volume is attached.
-
#create_snapshot(options = {}) ⇒ Fog::Rackspace::BlockStorage::Snapshot
Creates a snapshot from the current volume.
-
#destroy ⇒ Boolean
Destroys Volume.
-
#ready? ⇒ Boolean
Returns true if the volume is in a ready state.
-
#save ⇒ Boolean
Creates volume.
-
#snapshots ⇒ Fog::Rackspace::BlockStorage::Snapshots
Returns a list of snapshots associated with the volume.
Instance Attribute Details
#attachments ⇒ Array<Hash> (readonly)
Returns an array of hashes containing attachment information
41 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 41 attribute :attachments |
#availability_zone ⇒ String (readonly)
Returns region of the volume.
49 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 49 attribute :availability_zone |
#created_at ⇒ String (readonly)
Returns volume creation date.
21 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 21 attribute :created_at, :aliases => 'createdAt' |
#display_description ⇒ String
Returns display description of volume.
33 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 33 attribute :display_description |
#display_name ⇒ String
Returns display name of volume.
29 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 29 attribute :display_name |
#id ⇒ String (readonly)
Returns The volume id.
17 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 17 identity :id |
#image_id ⇒ String
Returns The ID of an image used to create a bootable volume.
53 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 53 attribute :image_id, :aliases => ['image', 'imageRef'], :squash => 'id' |
#size ⇒ String
Returns size of the volume in GB (100 GB minimum).
37 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 37 attribute :size |
#state ⇒ String (readonly)
Returns volume status.
25 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 25 attribute :state, :aliases => 'status' |
#volume_type ⇒ String
Returns type of volume.
45 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 45 attribute :volume_type |
Instance Method Details
#attached? ⇒ Boolean
Returns true if the volume is attached
63 64 65 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 63 def attached? state == IN_USE end |
#create_snapshot(options = {}) ⇒ Fog::Rackspace::BlockStorage::Snapshot
All writes to the volume should be flushed before creating the snapshot, either by un-mounting any file systems on the volume or by detaching the volume.
Creates a snapshot from the current volume
89 90 91 92 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 89 def create_snapshot(={}) requires :identity service.snapshots.create(.merge(:volume_id => identity)) end |
#destroy ⇒ Boolean
You cannot delete a volume until all of its dependent snaphosts have been deleted.
Destroys Volume
126 127 128 129 130 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 126 def destroy requires :identity service.delete_volume(identity) true end |
#ready? ⇒ Boolean
Returns true if the volume is in a ready state
57 58 59 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 57 def ready? state == AVAILABLE end |
#save ⇒ Boolean
A volume object cannot be updated
Creates volume
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 103 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, :snapshot_id => attributes[:snapshot_id], :image_id => attributes[:image_id] }) merge_attributes(data.body['volume']) true end |
#snapshots ⇒ Fog::Rackspace::BlockStorage::Snapshots
Returns a list of snapshots associated with the volume
73 74 75 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 73 def snapshots service.snapshots.select { |s| s.volume_id == identity } end |