Parent

Class/Module Index [+]

Quicksearch

Fog::Compute::AWS::Volume

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/fog/aws/models/compute/volume.rb, line 24
def initialize(attributes = {})
  # assign server first to prevent race condition with persisted?
  self.server = attributes.delete(:server)
  super
end

Public Instance Methods

destroy() click to toggle source
# File lib/fog/aws/models/compute/volume.rb, line 30
def destroy
  requires :id

  service.delete_volume(id)
  true
end
force_detach() click to toggle source
# File lib/fog/aws/models/compute/volume.rb, line 95
def force_detach
  detach(true)
end
ready?() click to toggle source
# File lib/fog/aws/models/compute/volume.rb, line 37
def ready?
  state == 'available'
end
save() click to toggle source
# File lib/fog/aws/models/compute/volume.rb, line 41
def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
  requires :availability_zone
  requires_one :size, :snapshot_id

  if type == 'io1'
    requires :iops
  end

  data = service.create_volume(availability_zone, size, 'SnapshotId' => snapshot_id, 'VolumeType' => type, 'Iops' => iops).body
  new_attributes = data.reject {|key,value| key == 'requestId'}
  merge_attributes(new_attributes)

  if tags = self.tags
    # expect eventual consistency
    Fog.wait_for { self.reload rescue nil }
    for key, value in (self.tags = tags)
      service.tags.create(
        :key          => key,
        :resource_id  => self.identity,
        :value        => value
      )
    end
  end

  if @server
    self.server = @server
  end
  true
end
server() click to toggle source
# File lib/fog/aws/models/compute/volume.rb, line 72
def server
  requires :server_id
  service.servers('instance-id' => server_id)
end
server=(new_server) click to toggle source
# File lib/fog/aws/models/compute/volume.rb, line 77
def server=(new_server)
  if new_server
    attach(new_server)
  else
    detach
  end
end
snapshot(description) click to toggle source
# File lib/fog/aws/models/compute/volume.rb, line 90
def snapshot(description)
  requires :id
  service.create_snapshot(id, description)
end
snapshots() click to toggle source
# File lib/fog/aws/models/compute/volume.rb, line 85
def snapshots
  requires :id
  service.snapshots(:volume => self)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.