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.
-
#cores ⇒ Integer
Returns the number of cores per socket.
-
#cpu_model ⇒ String
Returns the CPU model of the node.
-
#cpus ⇒ Integer
Returns the number of active CPUs.
-
#devices ⇒ Collection::NodeDeviceCollection
Returns the devices connected to this node.
-
#free_memory ⇒ Integer
Returns the free memory available on the node.
-
#initialize(pointer) ⇒ Node
constructor
Initializes a node object with the given Connection pointer.
-
#memory ⇒ Integer
Returns the memory size in kilobytes.
-
#mhz ⇒ Integer
Returns the expected CPU frequency in MHz.
-
#nodes ⇒ Integer
Returns the number of NUMA cell, 1 for uniform memory access.
-
#sockets ⇒ Integer
Returns the number of CPU sockets per node.
-
#threads ⇒ Integer
Returns the number of threads per core.
Constructor Details
#initialize(pointer) ⇒ Node
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 |
#cores ⇒ Integer
Returns the number of cores per socket.
88 89 90 |
# File 'lib/libvirt/node.rb', line 88 def cores info[:cores] end |
#cpu_model ⇒ String
Returns the CPU model of the node.
46 47 48 |
# File 'lib/libvirt/node.rb', line 46 def cpu_model info[:model] end |
#cpus ⇒ Integer
Returns the number of active CPUs.
60 61 62 |
# File 'lib/libvirt/node.rb', line 60 def cpus info[:cpus] end |
#devices ⇒ Collection::NodeDeviceCollection
Returns the devices connected to this node.
31 32 33 |
# File 'lib/libvirt/node.rb', line 31 def devices Collection::NodeDeviceCollection.new(connection) end |
#free_memory ⇒ Integer
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 |
#memory ⇒ Integer
Returns the memory size in kilobytes.
53 54 55 |
# File 'lib/libvirt/node.rb', line 53 def memory info[:memory] end |
#mhz ⇒ Integer
Returns the expected CPU frequency in MHz.
67 68 69 |
# File 'lib/libvirt/node.rb', line 67 def mhz info[:mhz] end |
#nodes ⇒ Integer
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 |
#sockets ⇒ Integer
Returns the number of CPU sockets per node.
81 82 83 |
# File 'lib/libvirt/node.rb', line 81 def sockets info[:sockets] end |
#threads ⇒ Integer
Returns the number of threads per core.
95 96 97 |
# File 'lib/libvirt/node.rb', line 95 def threads info[:threads] end |