Class: Libvirt::Interface
- Inherits:
-
Object
- Object
- Libvirt::Interface
- Defined in:
- lib/libvirt/interface.rb
Class Method Summary collapse
Instance Method Summary collapse
- #active? ⇒ Boolean
- #destroy ⇒ Object
-
#initialize(pointer) ⇒ Interface
constructor
A new instance of Interface.
- #mac ⇒ String
- #name ⇒ String
- #start ⇒ Object
- #to_ptr ⇒ FFI::Pointer
- #undefine ⇒ Object
- #xml_desc(options_or_flags = nil) ⇒ Object
Constructor Details
#initialize(pointer) ⇒ Interface
Returns a new instance of Interface.
14 15 16 17 18 19 20 21 22 23 24 |
# 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 |
Class Method Details
Instance Method Details
#active? ⇒ Boolean
61 62 63 64 65 66 |
# 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 ⇒ Object
75 76 77 78 |
# 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 ⇒ String
42 43 44 45 46 47 |
# 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 ⇒ String
33 34 35 36 37 38 |
# 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 ⇒ Object
69 70 71 72 |
# 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 ⇒ FFI::Pointer
27 28 29 |
# File 'lib/libvirt/interface.rb', line 27 def to_ptr @ptr end |
#undefine ⇒ Object
81 82 83 84 |
# 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) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/libvirt/interface.rb', line 51 def xml_desc( = nil) flags = Util.parse_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 |