class Fog::Vsphere::Compute::Volumes

Public Instance Methods

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

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

  each { |volume| volume.server = server }
  self
end
get(id) click to toggle source
# File lib/fog/vsphere/models/compute/volumes.rb, line 27
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 31
def new(attributes = {})
  if server_id
    # Default to the root volume datastore if one is not configured.
    datastore = !attributes.key?(:datastore) && any? ? first.datastore : nil

    super({ server_id: server_id, datastore: datastore }.merge!(attributes))
  else
    super
  end
end
server() click to toggle source
# File lib/fog/vsphere/models/compute/volumes.rb, line 42
def server
  return nil if server_id.nil?
  service.servers.get(server_id)
end
server=(new_server) click to toggle source
# File lib/fog/vsphere/models/compute/volumes.rb, line 47
def server=(new_server)
  server_id = new_server.id
end