Class: Libvirt::Node
- Inherits:
-
Object
- Object
- Libvirt::Node
- Defined in:
- lib/libvirt/node.rb
Overview
Represents a node which libvirt resides on.
Instance Method Summary (collapse)
-
- (Connection) connection
Returns the connection this node belongs to as a Connection object.
-
- (Integer) cores
Returns the number of cores per socket.
-
- (String) cpu_model
Returns the CPU model of the node.
-
- (Integer) cpus
Returns the number of active CPUs.
-
- (Collection::NodeDeviceCollection) devices
Returns the devices connected to this node.
-
- (Integer) free_memory
Returns the free memory available on the node.
-
- (Node) initialize(pointer)
constructor
Initializes a node object with the given Connection pointer.
-
- (Integer) memory
Returns the memory size in kilobytes.
-
- (Integer) mhz
Returns the expected CPU frequency in MHz.
-
- (Integer) nodes
Returns the number of NUMA cell, 1 for uniform memory access.
-
- (Integer) sockets
Returns the number of CPU sockets per node.
-
- (Integer) threads
Returns the number of threads per core.
Constructor Details
- (Node) initialize(pointer)
Initializes a node object with the given Connection pointer. This shouldn't be called directly. Instead, retrieve the node using Connection#node.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/libvirt/node.rb', line 7 def initialize(pointer) # This pointer can either be a `virConnectPtr` directly or a # {Connection} since it implements `to_ptr`. @pointer = pointer # We increase the reference count on the connection while this # node object is in use. FFI::Libvirt.virConnectRef(connection) # Register finalizer for reference cleanup ObjectSpace.define_finalizer(self, method(:finalize)) end |
Instance Method Details
- (Connection) connection
Returns the connection this node belongs to as a Connection object.
24 25 26 |
# File 'lib/libvirt/node.rb', line 24 def connection @connection ||= @pointer.is_a?(Connection) ? @pointer : Connection.new(@pointer) end |
- (Integer) cores
Returns the number of cores per socket.
88 89 90 |
# File 'lib/libvirt/node.rb', line 88 def cores info[:cores] end |
- (String) cpu_model
Returns the CPU model of the node.
46 47 48 |
# File 'lib/libvirt/node.rb', line 46 def cpu_model info[:model] end |
- (Integer) cpus
Returns the number of active CPUs.
60 61 62 |
# File 'lib/libvirt/node.rb', line 60 def cpus info[:cpus] end |
- (Collection::NodeDeviceCollection) devices
Returns the devices connected to this node.
31 32 33 |
# File 'lib/libvirt/node.rb', line 31 def devices Collection::NodeDeviceCollection.new(connection) end |
- (Integer) free_memory
Returns the free memory available on the node. This is returned in bytes.
39 40 41 |
# File 'lib/libvirt/node.rb', line 39 def free_memory FFI::Libvirt.virNodeGetFreeMemory(connection) end |
- (Integer) memory
Returns the memory size in kilobytes.
53 54 55 |
# File 'lib/libvirt/node.rb', line 53 def memory info[:memory] end |
- (Integer) mhz
Returns the expected CPU frequency in MHz.
67 68 69 |
# File 'lib/libvirt/node.rb', line 67 def mhz info[:mhz] end |
- (Integer) nodes
Returns the number of NUMA cell, 1 for uniform memory access.
74 75 76 |
# File 'lib/libvirt/node.rb', line 74 def nodes info[:nodes] end |
- (Integer) sockets
Returns the number of CPU sockets per node.
81 82 83 |
# File 'lib/libvirt/node.rb', line 81 def sockets info[:sockets] end |
- (Integer) threads
Returns the number of threads per core.
95 96 97 |
# File 'lib/libvirt/node.rb', line 95 def threads info[:threads] end |