Class: 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.
-
#size ⇒ String
Size of the volume in GB (100 GB minimum).
-
#state ⇒ String
readonly
Volume status.
-
#volume_type ⇒ String
Type of volume.
Attributes inherited from Model
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.
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
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 |
#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
59 60 61 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 59 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
86 87 88 89 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 86 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
121 122 123 124 125 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 121 def destroy requires :identity service.delete_volume(identity) true end |
#ready? ⇒ Boolean
Returns true if the volume is in a ready state
53 54 55 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 53 def ready? state == AVAILABLE end |
#save ⇒ Boolean
A volume object cannot be updated
Creates volume
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 100 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 ⇒ Fog::Rackspace::BlockStorage::Snapshots
Returns a list of snapshots associated with the volume
69 70 71 |
# File 'lib/fog/rackspace/models/block_storage/volume.rb', line 69 def snapshots service.snapshots.select { |s| s.volume_id == identity } end |