Class: OvirtSDK4::StorageDomainsService

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

Instance Method Summary (collapse)

Instance Method Details

- (StorageDomain) add(storage_domain, opts = {})

Adds a new storage_domain.

Parameters:

Returns:



19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
# File 'lib/ovirtsdk4/services.rb', line 19922

def add(storage_domain, opts = {})
  if storage_domain.is_a?(Hash)
    storage_domain = OvirtSDK4::StorageDomain.new(storage_domain)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    StorageDomainWriter.write_one(storage_domain, writer, 'storage_domain')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 201, 202
    begin
      reader = XmlReader.new(response.body)
      return StorageDomainReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

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

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :case_sensitive (Boolean)

    Indicates if the search performed using the search parameter should be performed taking case into account. The default value is true, which means that case is taken into account. If you want to search ignoring case set it to false.

  • :filter (Boolean)

    Indicates if the results should be filtered according to the permissions of the user.

  • :max (Integer)

    Sets the maximum number of storage domains to return. If not specified all the storage domains are returned.

  • :search (String)

    A query string used to restrict the returned storage domains.

Returns:



19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
# File 'lib/ovirtsdk4/services.rb', line 19965

def list(opts = {})
  query = {}
  value = opts[:case_sensitive]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['case_sensitive'] = value
  end
  value = opts[:filter]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['filter'] = value
  end
  value = opts[:max]
  unless value.nil?
    value = Writer.render_integer(value)
    query['max'] = value
  end
  value = opts[:search]
  unless value.nil?
    query['search'] = 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 StorageDomainReader.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.



20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
# File 'lib/ovirtsdk4/services.rb', line 20019

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

- (StorageDomainService) storage_domain_service(id)

Locates the storage_domain service.

Parameters:

  • id (String)

    The identifier of the storage_domain.

Returns:



20008
20009
20010
# File 'lib/ovirtsdk4/services.rb', line 20008

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


20035
20036
20037
# File 'lib/ovirtsdk4/services.rb', line 20035

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