class Fog::Compute::Vsphere::Volumes

Public Instance Methods

all(filters = {}) click to toggle source
# File lib/fog/vsphere/models/compute/volumes.rb, line 12
def all(filters = {})
  requires :server

  case server
    when Fog::Compute::Vsphere::Server
      load service.list_vm_volumes(server.id)
    when Fog::Compute::Vsphere::Template
      load service.list_template_volumes(server.id)
    else
      raise 'volumes should have vm or template'
    end

  self.each { |volume| volume.server_id = server.id }
  self
end
get(id) click to toggle source
# File lib/fog/vsphere/models/compute/volumes.rb, line 28
def get(id)
  new service.get_volume(id)
end
new(attributes = {}) click to toggle source
Calls superclass method
# File lib/fog/vsphere/models/compute/volumes.rb, line 32
def new(attributes = {})
  if server
    # Default to the root volume datastore if one is not configured.
    datastore = ! attributes.key?(:datastore) && self.any? ? self.first.datastore : nil

    super({ :server_id => server.id, :datastore => datastore }.merge!(attributes))
  else
    super
  end
end