Class: Fog::Compute::AWS::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::AWS::Volume
- Defined in:
- lib/fog/aws/models/compute/volume.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #force_detach ⇒ Object
-
#initialize(attributes = {}) ⇒ Volume
constructor
A new instance of Volume.
- #ready? ⇒ Boolean
- #save ⇒ Object
- #server ⇒ Object
- #server=(new_server) ⇒ Object
- #snapshot(description) ⇒ Object
- #snapshots ⇒ Object
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 = {}) # assign server first to prevent race condition with persisted? 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 service.delete_volume(id) true end |
#force_detach ⇒ Object
91 92 93 |
# File 'lib/fog/aws/models/compute/volume.rb', line 91 def force_detach detach(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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# 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 persisted? requires :availability_zone requires_one :size, :snapshot_id if type == 'io1' requires :iops end data = service.create_volume(availability_zone, size, 'SnapshotId' => snapshot_id, 'VolumeType' => type, 'Iops' => iops, 'Encrypted' => encrypted).body new_attributes = data.reject {|key,value| key == 'requestId'} merge_attributes(new_attributes) if = self. # expect eventual consistency Fog.wait_for { self.reload rescue nil } service.( self.identity, ) end if @server self.server = @server end true end |
#server ⇒ Object
68 69 70 71 |
# File 'lib/fog/aws/models/compute/volume.rb', line 68 def server requires :server_id service.servers.get(server_id) end |
#server=(new_server) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/fog/aws/models/compute/volume.rb', line 73 def server=(new_server) if new_server attach(new_server) else detach end end |
#snapshot(description) ⇒ Object
86 87 88 89 |
# File 'lib/fog/aws/models/compute/volume.rb', line 86 def snapshot(description) requires :id service.create_snapshot(id, description) end |
#snapshots ⇒ Object
81 82 83 84 |
# File 'lib/fog/aws/models/compute/volume.rb', line 81 def snapshots requires :id service.snapshots(:volume => self) end |