Class: AWS::EC2::Volume
- Inherits:
-
Resource
- Object
- Resource
- AWS::EC2::Volume
- Includes:
- TaggedItem
- Defined in:
- lib/aws/ec2/volume.rb
Overview
Represents an Amazon EBS volume.
Instance Attribute Summary collapse
-
#availability_zone ⇒ AvailabilityZone
readonly
Availability Zone in which the volume was created.
-
#create_time ⇒ Time
readonly
The time at which the volume was created.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#size ⇒ Integer
readonly
The size of the volume in gigabytes.
-
#status ⇒ Symbol
(also: #state)
readonly
The status of the volume.
Instance Method Summary collapse
-
#attach_to(instance, device) ⇒ Attachment
(also: #attach)
Attaches the volume to an instance.
-
#attachments ⇒ AttachmentCollection
The collection of attachments that involve this volume.
-
#create_snapshot(description = nil) ⇒ Snapshot
A new snapshot created from the volume.
-
#delete ⇒ Object
Deletes the volume.
-
#detach_from(instance, device, opts = {}) ⇒ Object
Detaches the volume from an instance.
-
#exists? ⇒ Boolean
True if the volume exists.
-
#snapshot ⇒ Snapshot
Snapshot from which the volume was created (may be nil).
Methods included from TaggedItem
Instance Attribute Details
#availability_zone ⇒ AvailabilityZone (readonly)
Availability Zone in which the volume was created.
56 57 58 |
# File 'lib/aws/ec2/volume.rb', line 56 def availability_zone @availability_zone end |
#create_time ⇒ Time (readonly)
The time at which the volume was created.
56 57 58 |
# File 'lib/aws/ec2/volume.rb', line 56 def create_time @create_time end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
60 61 62 |
# File 'lib/aws/ec2/volume.rb', line 60 def id @id end |
#size ⇒ Integer (readonly)
The size of the volume in gigabytes.
56 57 58 |
# File 'lib/aws/ec2/volume.rb', line 56 def size @size end |
#status ⇒ Symbol (readonly) Also known as: state
The status of the volume. Possible values:
-
:creating
-
:available
-
:in_use
-
:deleting
-
:deleted
-
:error
56 57 58 |
# File 'lib/aws/ec2/volume.rb', line 56 def status @status end |
Instance Method Details
#attach_to(instance, device) ⇒ Attachment Also known as: attach
Attaches the volume to an instance.
95 96 97 98 99 100 101 102 103 |
# File 'lib/aws/ec2/volume.rb', line 95 def attach_to(instance, device) resp = client.attach_volume(:volume_id => id, :instance_id => instance.id, :device => device) Attachment.new(self, Instance.new(resp.instance_id), resp.device, :config => config) end |
#attachments ⇒ AttachmentCollection
Returns The collection of attachments that involve this volume.
135 136 137 |
# File 'lib/aws/ec2/volume.rb', line 135 def AttachmentCollection.new(self, :config => config) end |
#create_snapshot(description = nil) ⇒ Snapshot
Returns A new snapshot created from the volume.
77 78 79 80 81 82 |
# File 'lib/aws/ec2/volume.rb', line 77 def create_snapshot(description = nil) opts = { :volume => self } opts[:description] = description if description SnapshotCollection.new(:config => config). create(opts) end |
#delete ⇒ Object
Deletes the volume.
69 70 71 |
# File 'lib/aws/ec2/volume.rb', line 69 def delete client.delete_volume(:volume_id => id) end |
#detach_from(instance, device, opts = {}) ⇒ Object
Detaches the volume from an instance.
124 125 126 127 128 129 130 131 |
# File 'lib/aws/ec2/volume.rb', line 124 def detach_from(instance, device, opts = {}) a = Attachment.new(self, Instance.new(instance.id), device, :config => config) a.delete a end |
#exists? ⇒ Boolean
Returns True if the volume exists.
140 141 142 143 144 145 |
# File 'lib/aws/ec2/volume.rb', line 140 def exists? resp = client.describe_volumes(:filters => [{ :name => 'volume-id', :values => [id] }]) and resp.volume_index.key?(id) end |