Class: Libvirt::StoragePool
- Inherits:
-
Object
- Object
- Libvirt::StoragePool
- Defined in:
- lib/libvirt/storage_pool.rb
Class Method Summary collapse
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(pointer) ⇒ StoragePool
constructor
A new instance of StoragePool.
- #list_all_volumes ⇒ Object
- #list_all_volumes_qty ⇒ Object
- #name ⇒ Object
- #to_ptr ⇒ Object
- #uuid ⇒ Object
- #xml_desc(options_or_flags = nil) ⇒ Object
Constructor Details
#initialize(pointer) ⇒ StoragePool
Returns a new instance of StoragePool.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/libvirt/storage_pool.rb', line 12 def initialize(pointer) @ptr = pointer free = ->(obj_id) do dbg { "Finalize Libvirt::StoragePool 0x#{obj_id.to_s(16)} @ptr=#{@ptr}," } return unless @ptr fr_result = FFI::Storage.virStoragePoolFree(@ptr) warn "Couldn't free Libvirt::StoragePool (0x#{obj_id.to_s(16)}) pointer #{@ptr.address}" if fr_result.negative? end ObjectSpace.define_finalizer(self, free) end |
Class Method Details
Instance Method Details
#info ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/libvirt/storage_pool.rb', line 29 def info info_ptr = ::FFI::MemoryPointer.new(FFI::Storage::PoolInfoStruct.by_value) result = FFI::Storage.virStoragePoolGetInfo(@ptr, info_ptr) raise Errors::LibError, "Couldn't get storage pool info" if result.negative? StoragePoolInfo.new(info_ptr) end |
#list_all_volumes ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/libvirt/storage_pool.rb', line 52 def list_all_volumes size = list_all_volumes_qty return [] if size.zero? storage_volumes_ptr = ::FFI::MemoryPointer.new(:pointer, size) result = FFI::Storage.virStoragePoolListAllVolumes(@ptr, storage_volumes_ptr, 0) raise Errors::LibError, "Couldn't retrieve volumes list" if result.negative? ptr = storage_volumes_ptr.read_pointer ptr.get_array_of_pointer(0, size).map { |stv_ptr| StorageVolume.new(stv_ptr) } end |
#list_all_volumes_qty ⇒ Object
45 46 47 48 49 50 |
# File 'lib/libvirt/storage_pool.rb', line 45 def list_all_volumes_qty result = FFI::Storage.virStoragePoolListAllVolumes(@ptr, nil, 0) raise Errors::LibError, "Couldn't retrieve volumes qty" if result.negative? result end |
#name ⇒ Object
72 73 74 75 76 77 |
# File 'lib/libvirt/storage_pool.rb', line 72 def name result = FFI::Storage.virStoragePoolGetName(@ptr) raise Errors::LibError, "Couldn't retrieve storage pool name" if result.nil? result end |
#to_ptr ⇒ Object
25 26 27 |
# File 'lib/libvirt/storage_pool.rb', line 25 def to_ptr @ptr end |
#uuid ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/libvirt/storage_pool.rb', line 64 def uuid buff = ::FFI::MemoryPointer.new(:char, Util::UUID_STRING_BUFLEN) result = FFI::Storage.virStoragePoolGetUUIDString(@ptr, buff) raise Errors::LibError, "Couldn't get storage pool uuid" if result.negative? buff.read_string end |
#xml_desc(options_or_flags = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/libvirt/storage_pool.rb', line 37 def xml_desc( = nil) flags = Util.parse_flags , FFI::Storage.enum_type(:xml_flags) result = FFI::Storage.virStoragePoolGetXMLDesc(@ptr, flags) raise Errors::LibError, "Couldn't get storage pool xml desc" if result.nil? result end |