Parent

Class/Module Index [+]

Quicksearch

Fog::HP::BlockStorage::Volume

Attributes

device[R]
server_id[R]

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/fog/hp/models/block_storage/volume.rb, line 26
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/volume.rb, line 59
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
destroy() click to toggle source
# File lib/fog/hp/models/block_storage/volume.rb, line 78
def destroy
  requires :id
  service.delete_volume(id)
  true
end
detach() click to toggle source
# File lib/fog/hp/models/block_storage/volume.rb, line 70
def detach
  requires :id
  if has_attachments?
    service.compute.detach_volume(server_id, id)
  end
  true
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/volume.rb, line 46
def has_attachments?
  !(attachments.nil? || attachments.empty? || attachments[0].empty?)
end
image_id=(new_image_id) click to toggle source

used for creating bootable volumes

# File lib/fog/hp/models/block_storage/volume.rb, line 41
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/volume.rb, line 50
def in_use?
  self.status == 'in-use'
end
ready?() click to toggle source
# File lib/fog/hp/models/block_storage/volume.rb, line 54
def ready?
  self.status == 'available'
end
save() click to toggle source
# File lib/fog/hp/models/block_storage/volume.rb, line 84
def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
  requires :name, :size
  options = {
    'metadata'          => metadata,
    'snapshot_id'       => snapshot_id,
    'imageRef'          => @image_id
  }
  options = options.reject {|key, value| value.nil?}
  data = service.create_volume(name, description, size, options)
  merge_attributes(data.body['volume'])
  true
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.