Class: OvirtSDK4::SchedulingPolicyService

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

Instance Method Summary (collapse)

Instance Method Details

- (BalancesService) balances_service

Locates the balances service.

Returns:



16961
16962
16963
# File 'lib/ovirtsdk4/services.rb', line 16961

def balances_service
  return BalancesService.new(@connection, "#{@path}/balances")
end

- (FiltersService) filters_service

Locates the filters service.

Returns:



16969
16970
16971
# File 'lib/ovirtsdk4/services.rb', line 16969

def filters_service
  return FiltersService.new(@connection, "#{@path}/filters")
end

- (SchedulingPolicy) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :filter (Boolean)

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

Returns:



16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
# File 'lib/ovirtsdk4/services.rb', line 16884

def get(opts = {})
  query = {}
  value = opts[:filter]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['filter'] = 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 SchedulingPolicyReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Object) remove(opts = {})

Deletes the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.



16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
# File 'lib/ovirtsdk4/services.rb', line 16913

def remove(opts = {})
  query = {}
  value = opts[:async]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['async'] = value
  end
  request = Request.new(:method => :DELETE, :path => @path, :query => query)
  response = @connection.send(request)
  unless response.code == 200
    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.

Raises:

  • (Error)


16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
# File 'lib/ovirtsdk4/services.rb', line 16988

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'balances'
    return balances_service
  end
  if path.start_with?('balances/')
    return balances_service.service(path[9..-1])
  end
  if path == 'filters'
    return filters_service
  end
  if path.start_with?('filters/')
    return filters_service.service(path[8..-1])
  end
  if path == 'weights'
    return weights_service
  end
  if path.start_with?('weights/')
    return weights_service.service(path[8..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


17018
17019
17020
# File 'lib/ovirtsdk4/services.rb', line 17018

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

- (Object) update(policy)

Updates the object managed by this service.



16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
# File 'lib/ovirtsdk4/services.rb', line 16930

def update(policy)
  if policy.is_a?(Hash)
    policy = OvirtSDK4::SchedulingPolicy.new(policy)
  end
  request = Request.new(:method => :PUT, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    SchedulingPolicyWriter.write_one(policy, writer, 'policy')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return SchedulingPolicyReader.read_one(reader)
    ensure
      reader.close
    end
    return result
  else
    check_fault(response)
  end
end

- (WeightsService) weights_service

Locates the weights service.

Returns:



16977
16978
16979
# File 'lib/ovirtsdk4/services.rb', line 16977

def weights_service
  return WeightsService.new(@connection, "#{@path}/weights")
end