class Fog::HP::BlockStorageV2::Volume
Public Class Methods
new(attributes = {})
click to toggle source
Calls superclass method
# 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
Public Instance Methods
attach(new_server_id, device)
click to toggle source
volume can be attached to only one server at a time
# 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 => attachments << data.body['volumeAttachment']) true else false end end
backing_up?()
click to toggle source
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 58 def backing_up? self.status == 'backing-up' end
destroy()
click to toggle source
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 90 def destroy requires :id service.delete_volume(id) true end
detach()
click to toggle source
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 82 def detach requires :id if has_attachments? service.compute.detach_volume(self.server_id, id) end true end
device()
click to toggle source
a volume can be attached to only one server at a time
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 30 def device attachments[0]['device'] if has_attachments? end
has_attachments?()
click to toggle source
a volume can be attached to only one server at a time
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 49 def has_attachments? !(attachments.nil? || attachments.empty? || attachments[0].empty?) end
image_id()
click to toggle source
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 44 def image_id @image_id = image_metadata['image_id'] if image_metadata end
image_id=(new_image_id)
click to toggle source
used for creating bootable volumes
# 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?()
click to toggle source
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 53 def in_use? self.status == 'in-use' end
Also aliased as: attached?
ready?()
click to toggle source
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 66 def ready? self.status == 'available' end
restoring?()
click to toggle source
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 62 def restoring? self.status == 'restoring-backup' end
save()
click to toggle source
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 96 def save identity ? update : create end
server_id()
click to toggle source
a volume can be attached to only one server at a time
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 35 def server_id attachments[0]['server_id'] if has_attachments? end
Private Instance Methods
create()
click to toggle source
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 102 def create options = { 'display_name' => name, 'display_description' => description, 'size' => size, 'metadata' => metadata, 'snapshot_id' => snapshot_id, 'imageRef' => @image_id, 'availability_zone' => availability_zone, 'source_volid' => source_volid, 'volume_type' => type # this parameter is currently ignored } options = options.reject {|_, value| value.nil?} data = service.create_volume(options) merge_attributes(data.body['volume']) true end
update()
click to toggle source
# File lib/fog/hp/models/block_storage_v2/volume.rb, line 120 def update requires :id options = { 'display_name' => name, 'display_description' => description, 'metadata' => metadata } options = options.reject {|_, value| value.nil?} data = service.update_volume(id, options) merge_attributes(data.body['volume']) true end