Class: Fog::HP::BlockStorageV2::Volume
- Inherits:
-
Model
- Object
- Model
- Fog::HP::BlockStorageV2::Volume
- Defined in:
- lib/fog/hp/models/block_storage_v2/volume.rb
Instance Method Summary collapse
-
#attach(new_server_id, device) ⇒ Object
volume can be attached to only one server at a time.
- #backing_up? ⇒ Boolean
- #destroy ⇒ Object
- #detach ⇒ Object
-
#device ⇒ Object
a volume can be attached to only one server at a time.
-
#has_attachments? ⇒ Boolean
a volume can be attached to only one server at a time.
- #image_id ⇒ Object
-
#image_id=(new_image_id) ⇒ Object
used for creating bootable volumes.
- #in_use? ⇒ Boolean (also: #attached?)
-
#initialize(attributes = {}) ⇒ Volume
constructor
A new instance of Volume.
- #ready? ⇒ Boolean
- #restoring? ⇒ Boolean
- #save ⇒ Object
-
#server_id ⇒ Object
a volume can be attached to only one server at a time.
Constructor Details
#initialize(attributes = {}) ⇒ Volume
Returns a new instance of Volume.
23 24 25 26 27 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 23 def initialize(attributes = {}) # assign these attributes first to prevent race condition with new_record? self.image_id = attributes.delete(:image_id) super end |
Instance Method Details
#attach(new_server_id, device) ⇒ Object
volume can be attached to only one server at a time
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 71 def attach(new_server_id, device) requires :id unless in_use? data = service.compute.attach_volume(new_server_id, id, device) merge_attributes(:attachments => << data.body['volumeAttachment']) true else false end end |
#backing_up? ⇒ Boolean
58 59 60 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 58 def backing_up? self.status == 'backing-up' end |
#destroy ⇒ Object
90 91 92 93 94 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 90 def destroy requires :id service.delete_volume(id) true end |
#detach ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 82 def detach requires :id if service.compute.detach_volume(self.server_id, id) end true end |
#device ⇒ Object
a volume can be attached to only one server at a time
30 31 32 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 30 def device [0]['device'] if end |
#has_attachments? ⇒ Boolean
a volume can be attached to only one server at a time
49 50 51 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 49 def !(.nil? || .empty? || [0].empty?) end |
#image_id ⇒ Object
44 45 46 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 44 def image_id @image_id = ['image_id'] if end |
#image_id=(new_image_id) ⇒ Object
used for creating bootable volumes
40 41 42 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 40 def image_id=(new_image_id) @image_id = new_image_id end |
#in_use? ⇒ Boolean Also known as: attached?
53 54 55 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 53 def in_use? self.status == 'in-use' end |
#ready? ⇒ Boolean
66 67 68 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 66 def ready? self.status == 'available' end |
#restoring? ⇒ Boolean
62 63 64 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 62 def restoring? self.status == 'restoring-backup' end |
#save ⇒ Object
96 97 98 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 96 def save identity ? update : create end |
#server_id ⇒ Object
a volume can be attached to only one server at a time
35 36 37 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 35 def server_id [0]['server_id'] if end |