class Fog::Compute::Cloudstack::Volume

Attributes

project_id[RW]
snapshot_id[RW]

Public Instance Methods

attach(instance_or_id, mountpoint=nil) click to toggle source
# File lib/fog/cloudstack/models/compute/volume.rb, line 87
def attach(instance_or_id, mountpoint=nil)
  requires :id
  instance_id = instance_or_id.is_a?(Server) ? instance_or_id.id : instance_or_id
  unless instance_id
    raise ArgumentError, "Missing required argument: instance_or_id"
  end

  options = {
    'id'               => id,
    'virtualmachineid' => instance_id,
  }
  options.merge!('deviceid' => mountpoint) if mountpoint

  data = service.attach_volume(options)

                                service.jobs.new(data["attachvolumeresponse"])
end
destroy() click to toggle source
# File lib/fog/cloudstack/models/compute/volume.rb, line 113
def destroy
  requires :id
  service.delete_volume('id' => id)
  true
end
detach() click to toggle source
# File lib/fog/cloudstack/models/compute/volume.rb, line 105
def detach
  requires :id

  data = service.detach_volume('id' => id)

  service.jobs.new(data["detachvolumeresponse"])
end
disk_offering()
Alias for: flavor
flavor() click to toggle source
# File lib/fog/cloudstack/models/compute/volume.rb, line 52
def flavor
  service.disk_offerings.get(self.disk_offering_id)
end
Also aliased as: disk_offering
ready?() click to toggle source
# File lib/fog/cloudstack/models/compute/volume.rb, line 48
def ready?
  state == 'Allocated' || state == 'Ready'
end
reload() click to toggle source
# File lib/fog/cloudstack/models/compute/volume.rb, line 68
def reload
  requires :identity

  return unless data = begin
                         collection.get(identity)
                       rescue Excon::Errors::SocketError
                         nil
                       end

  new_attributes = {
    'virtualmachineid' => nil,
    'vmname' => nil,
    'vmdisplayname' => nil
  }.merge(data.attributes)

  merge_attributes(new_attributes)
  self
end
save() click to toggle source
# File lib/fog/cloudstack/models/compute/volume.rb, line 32
def save
  requires :name, :disk_offering_id, :zone_id

  options = {
    'size'           => size,
    'name'           => name,
    'diskofferingid' => disk_offering_id,
    'zoneid'         => zone_id,
    'snapshotid'     => snapshot_id,
    'projectid'      => project_id
  }

  data = service.create_volume(options)
  merge_attributes(data['createvolumeresponse'])
end
server() click to toggle source
# File lib/fog/cloudstack/models/compute/volume.rb, line 57
def server
  if server_id
    service.servers.get(server_id)
  end
end
snapshots() click to toggle source
# File lib/fog/cloudstack/models/compute/volume.rb, line 63
def snapshots
  requires :id
  service.snapshots.all('volumeid' => id)
end