Class: Libvirt::Collection::NodeDeviceCollection

Inherits:
AbstractCollection show all
Defined in:
lib/libvirt/collection/node_device_collection.rb

Overview

Represents a collection of devices on a given node. Retrieve this collection using Node#devices.

Instance Attribute Summary

Attributes inherited from AbstractCollection

#interface

Instance Method Summary collapse

Methods inherited from AbstractCollection

#initialize

Constructor Details

This class inherits a constructor from Libvirt::Collection::AbstractCollection

Instance Method Details

#allArray<NodeDevice>

Returns all of the node devices for the given connection.

Returns:



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/libvirt/collection/node_device_collection.rb', line 16

def all
  # We can't use the `read_array` helper here due to the methods being
  # a bit different.
  count_max = FFI::Libvirt.virNodeNumOfDevices(interface, nil, 0)
  output_ptr = FFI::MemoryPointer.new(:pointer, count_max)
  count_returned = FFI::Libvirt.virNodeListDevices(interface, nil, output_ptr, count_max, 0)

  output_ptr.get_array_of_string(0, count_returned).collect do |name|
    nil_or_object(FFI::Libvirt.virNodeDeviceLookupByName(interface, name), NodeDevice)
  end
end

#create(spec) ⇒ NodeDevice

Create a node device on the host system.

Returns:



9
10
11
# File 'lib/libvirt/collection/node_device_collection.rb', line 9

def create(spec)
  nil_or_object(FFI::Libvirt.virNodeDeviceCreateXML(interface, spec, 0), NodeDevice)
end