Class: OvirtSDK4::StorageDomainVmsService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary (collapse)

Instance Method Details

- (Array<Vm>) list(opts = {})

Returns the representation of the object managed by this service.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :max (Integer)

    Sets the maximum number of virtual machines to return. If not specified all the virtual machines are returned.

Returns:

  • (Array<Vm>)


19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
# File 'lib/ovirtsdk4/services.rb', line 19837

def list(opts = {})
  query = {}
  value = opts[:max]
  unless value.nil?
    value = Writer.render_integer(value)
    query['max'] = value
  end
  request = Request.new(:method => :GET, :path => @path, :query => query)
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return VmReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Service) service(path)

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.



19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
# File 'lib/ovirtsdk4/services.rb', line 19877

def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return vm_service(path)
  end
  return vm_service(path[0..(index - 1)]).service(path[(index +1)..-1])
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


19893
19894
19895
# File 'lib/ovirtsdk4/services.rb', line 19893

def to_s
  return "#<#{StorageDomainVmsService}:#{@path}>"
end

- (StorageDomainVmService) vm_service(id)

Locates the vm service.

Parameters:

  • id (String)

    The identifier of the vm.

Returns:



19866
19867
19868
# File 'lib/ovirtsdk4/services.rb', line 19866

def vm_service(id)
  return StorageDomainVmService.new(@connection, "#{@path}/#{id}")
end