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.
- #modification_in_progress? ⇒ Boolean
- #modifications ⇒ Object
- #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.
22 23 24 25 26 |
# File 'lib/fog/aws/models/compute/volume.rb', line 22 def initialize(attributes = {}) # assign server first to prevent race condition with persisted? self.server = attributes.delete(:server) super end |
Instance Method Details
#destroy ⇒ Object
28 29 30 31 32 33 |
# File 'lib/fog/aws/models/compute/volume.rb', line 28 def destroy requires :id service.delete_volume(id) true end |
#force_detach ⇒ Object
108 109 110 |
# File 'lib/fog/aws/models/compute/volume.rb', line 108 def force_detach detach(true) end |
#modification_in_progress? ⇒ Boolean
39 40 41 |
# File 'lib/fog/aws/models/compute/volume.rb', line 39 def modification_in_progress? modifications.any? { |m| m['modificationState'] != 'completed' } end |
#modifications ⇒ Object
43 44 45 46 |
# File 'lib/fog/aws/models/compute/volume.rb', line 43 def modifications requires :identity service.describe_volumes_modifications('volume-id' => self.identity).body['volumeModificationSet'] end |
#ready? ⇒ Boolean
35 36 37 |
# File 'lib/fog/aws/models/compute/volume.rb', line 35 def ready? state == 'available' end |
#save ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/fog/aws/models/compute/volume.rb', line 48 def save if identity update_params = { 'Size' => self.size, 'Iops' => self.iops, 'VolumeType' => self.type } service.modify_volume(self.identity, update_params) true else requires :availability_zone requires_one :size, :snapshot_id if type == 'io1' requires :iops end data = service.create_volume(availability_zone, size, create_params).body merge_attributes(data) if = self. # expect eventual consistency Fog.wait_for { self.reload rescue nil } service.( self.identity, ) end if @server self.server = @server end true end end |
#server ⇒ Object
85 86 87 88 |
# File 'lib/fog/aws/models/compute/volume.rb', line 85 def server requires :server_id service.servers.get(server_id) end |
#server=(new_server) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/fog/aws/models/compute/volume.rb', line 90 def server=(new_server) if new_server attach(new_server) else detach end end |
#snapshot(description) ⇒ Object
103 104 105 106 |
# File 'lib/fog/aws/models/compute/volume.rb', line 103 def snapshot(description) requires :id service.create_snapshot(id, description) end |
#snapshots ⇒ Object
98 99 100 101 |
# File 'lib/fog/aws/models/compute/volume.rb', line 98 def snapshots requires :id service.snapshots(:volume => self) end |