class Libvirt::Interface
Public Class Methods
load_ref(pointer)
click to toggle source
@param pointer [FFI::Pointer]
# File lib/libvirt/interface.rb, line 6 def self.load_ref(pointer) result = FFI::Interface.virInterfaceRef(pointer) raise Errors::LibError, "Couldn't retrieve interface reference" if result.negative? new(pointer) end
new(pointer)
click to toggle source
@param pointer [FFI::Pointer]
# File lib/libvirt/interface.rb, line 14 def initialize(pointer) @ptr = pointer free = ->(obj_id) do dbg { "Finalize Libvirt::Interface object_id=0x#{obj_id.to_s(16)}, pointer=0x#{@ptr.address.to_s(16)}" } return unless @ptr warn "Couldn't free Libvirt::Interface object_id=0x#{obj_id.to_s(16)}, pointer=0x#{@ptr.address.to_s(16)}" if FFI::Interface.virInterfaceFree(@ptr).negative? end ObjectSpace.define_finalizer(self, free) end
Public Instance Methods
active?()
click to toggle source
@return [Boolean] @raise [Libvirt::Errors::LibError]
# File lib/libvirt/interface.rb, line 61 def active? result = FFI::Interface.virInterfaceIsActive(@ptr) raise Errors::LibError, "Couldn't get interface is active" if result.nil? result == 1 end
destroy()
click to toggle source
@raise [Libvirt::Errors::LibError]
# File lib/libvirt/interface.rb, line 75 def destroy result = FFI::Interface.virInterfaceDestroy(@ptr, 0) raise Errors::LibError, "Couldn't destroy interface" if result.negative? end
mac()
click to toggle source
@return [String] @raise [Libvirt::Errors::LibError]
# File lib/libvirt/interface.rb, line 42 def mac result = FFI::Interface.virInterfaceGetMACString(@ptr) raise Errors::LibError, "Couldn't get interface mac" if result.nil? result end
name()
click to toggle source
@return [String] @raise [Libvirt::Errors::LibError]
# File lib/libvirt/interface.rb, line 33 def name result = FFI::Interface.virInterfaceGetName(@ptr) raise Errors::LibError, "Couldn't get interface name" if result.nil? result end
start()
click to toggle source
@raise [Libvirt::Errors::LibError]
# File lib/libvirt/interface.rb, line 69 def start result = FFI::Interface.virInterfaceCreate(@ptr, 0) raise Errors::LibError, "Couldn't start interface" if result.negative? end
to_ptr()
click to toggle source
@return [FFI::Pointer]
# File lib/libvirt/interface.rb, line 27 def to_ptr @ptr end
undefine()
click to toggle source
@raise [Libvirt::Errors::LibError]
# File lib/libvirt/interface.rb, line 81 def undefine result = FFI::Interface.virInterfaceUndefine(@ptr) raise Errors::LibError, "Couldn't undefine interface" if result.negative? end
xml_desc(options_or_flags = nil)
click to toggle source
@param options_or_flags [Array<Symbol>,Hash{Symbol=>Boolean},Integer,Symbol,nil] @raise [Libvirt::Errors::LibError]
# File lib/libvirt/interface.rb, line 51 def xml_desc(options_or_flags = nil) flags = Util.parse_flags options_or_flags, FFI::Interface.enum_type(:xml_flags) result = FFI::Interface.virInterfaceGetXMLDesc(@ptr, flags) raise Errors::LibError, "Couldn't get interface xml desc" if result.nil? result end
Private Instance Methods
dbg(&block)
click to toggle source
# File lib/libvirt/interface.rb, line 88 def dbg(&block) Util.log(:debug, 'Libvirt::Network', &block) end