Class: OvirtSDK4::VmPoolsService

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

Instance Method Summary (collapse)

Instance Method Details

- (VmPool) add(pool, opts = {})

Adds a new pool.

Parameters:

Returns:



25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
# File 'lib/ovirtsdk4/services.rb', line 25993

def add(pool, opts = {})
  if pool.is_a?(Hash)
    pool = OvirtSDK4::VmPool.new(pool)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    VmPoolWriter.write_one(pool, writer, 'pool')
    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 VmPoolReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Array<VmPool>) 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 pools to return. If this value is not specified, all of the pools are returned.

  • :search (String)

    A query string used to restrict the returned pools.

Returns:



26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
# File 'lib/ovirtsdk4/services.rb', line 26036

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 VmPoolReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (VmPoolService) pool_service(id)

Locates the pool service.

Parameters:

  • id (String)

    The identifier of the pool.

Returns:



26079
26080
26081
# File 'lib/ovirtsdk4/services.rb', line 26079

def pool_service(id)
  return VmPoolService.new(@connection, "#{@path}/#{id}")
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.



26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
# File 'lib/ovirtsdk4/services.rb', line 26090

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


26106
26107
26108
# File 'lib/ovirtsdk4/services.rb', line 26106

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