Class: OvirtSDK4::VmNumaNodesService

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

Instance Method Summary (collapse)

Instance Method Details

- (VirtualNumaNode) add(node, opts = {})

Adds a new node.

Parameters:

Returns:



25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
# File 'lib/ovirtsdk4/services.rb', line 25713

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

- (Array<VirtualNumaNode>) 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 nodes to return. If not specified all the nodes are returned.

Returns:



25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
# File 'lib/ovirtsdk4/services.rb', line 25748

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

- (VmNumaNodeService) node_service(id)

Locates the node service.

Parameters:

  • id (String)

    The identifier of the node.

Returns:



25777
25778
25779
# File 'lib/ovirtsdk4/services.rb', line 25777

def node_service(id)
  return VmNumaNodeService.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.



25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
# File 'lib/ovirtsdk4/services.rb', line 25788

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


25804
25805
25806
# File 'lib/ovirtsdk4/services.rb', line 25804

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