Class: Libvirt::Collection::StoragePoolCollection
- Inherits:
-
AbstractCollection
- Object
- AbstractCollection
- Libvirt::Collection::StoragePoolCollection
- Defined in:
- lib/libvirt/collection/storage_pool_collection.rb
Overview
Represents a collection of storage pools.
Instance Attribute Summary
Attributes inherited from AbstractCollection
Instance Method Summary collapse
-
#active ⇒ Array<StoragePool>
Returns the active storage pools.
-
#all ⇒ Array<StoragePool>
Returns all storage pools.
-
#find(value) ⇒ StoragePool
Search for a storage pool.
-
#find_by_name(name) ⇒ StoragePool
Search for a storage pool by name.
-
#find_by_uuid(uuid) ⇒ StoragePool
Search for a storage pool by UUID.
-
#inactive ⇒ Array<StoragePool>
Returns the inactive storage pools.
Methods inherited from AbstractCollection
Constructor Details
This class inherits a constructor from Libvirt::Collection::AbstractCollection
Instance Method Details
#active ⇒ Array<StoragePool>
Returns the active storage pools.
40 41 42 43 44 |
# File 'lib/libvirt/collection/storage_pool_collection.rb', line 40 def active read_array(:virConnectListStoragePools, :virConnectNumOfStoragePools, :string).collect do |name| find_by_name(name) end end |
#all ⇒ Array<StoragePool>
Returns all storage pools.
49 50 51 52 53 54 55 |
# File 'lib/libvirt/collection/storage_pool_collection.rb', line 49 def all inactive + active rescue Exception::LibvirtError # If inactive isn't supported, then we just return the active # storage pools. active end |
#find(value) ⇒ StoragePool
Search for a storage pool. This will first search by name and then by UUID, returning the first result returned.
9 10 11 12 |
# File 'lib/libvirt/collection/storage_pool_collection.rb', line 9 def find(value) result = find_by_name(value) rescue nil result ||= find_by_uuid(value) rescue nil end |
#find_by_name(name) ⇒ StoragePool
Search for a storage pool by name.
17 18 19 |
# File 'lib/libvirt/collection/storage_pool_collection.rb', line 17 def find_by_name(name) nil_or_object(FFI::Libvirt.virStoragePoolLookupByName(interface, name), StoragePool) end |
#find_by_uuid(uuid) ⇒ StoragePool
Search for a storage pool by UUID.
24 25 26 |
# File 'lib/libvirt/collection/storage_pool_collection.rb', line 24 def find_by_uuid(uuid) nil_or_object(FFI::Libvirt.virStoragePoolLookupByUUIDString(interface, uuid), StoragePool) end |
#inactive ⇒ Array<StoragePool>
Returns the inactive storage pools.
31 32 33 34 35 |
# File 'lib/libvirt/collection/storage_pool_collection.rb', line 31 def inactive read_array(:virConnectListDefinedStoragePools, :virConnectNumOfDefinedStoragePools, :string).collect do |name| find_by_name(name) end end |