Class: Fog::HP::BlockStorageV2::Volume
- Defined in:
- lib/fog/hp/models/block_storage_v2/volume.rb
Instance Attribute Summary
Attributes inherited from Model
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.
Methods inherited from Model
#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
#initialize(attributes = {}) ⇒ Volume
Returns a new instance of Volume.
25 26 27 28 29 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 25 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
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 73 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
60 61 62 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 60 def backing_up? self.status == 'backing-up' end |
#destroy ⇒ Object
92 93 94 95 96 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 92 def destroy requires :id service.delete_volume(id) true end |
#detach ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 84 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
32 33 34 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 32 def device [0]['device'] if end |
#has_attachments? ⇒ Boolean
a volume can be attached to only one server at a time
51 52 53 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 51 def !(.nil? || .empty? || [0].empty?) end |
#image_id ⇒ Object
46 47 48 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 46 def image_id @image_id = ['image_id'] if end |
#image_id=(new_image_id) ⇒ Object
used for creating bootable volumes
42 43 44 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 42 def image_id=(new_image_id) @image_id = new_image_id end |
#in_use? ⇒ Boolean Also known as: attached?
55 56 57 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 55 def in_use? self.status == 'in-use' end |
#ready? ⇒ Boolean
68 69 70 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 68 def ready? self.status == 'available' end |
#restoring? ⇒ Boolean
64 65 66 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 64 def restoring? self.status == 'restoring-backup' end |
#save ⇒ Object
98 99 100 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 98 def save identity ? update : create end |
#server_id ⇒ Object
a volume can be attached to only one server at a time
37 38 39 |
# File 'lib/fog/hp/models/block_storage_v2/volume.rb', line 37 def server_id [0]['server_id'] if end |