Class: Libvirt::Collection::StorageVolumeCollection
- Inherits:
-
AbstractCollection
- Object
- AbstractCollection
- Libvirt::Collection::StorageVolumeCollection
- Defined in:
- lib/libvirt/collection/storage_volume_collection.rb
Overview
Represents a collection of storage volumes, which belongs to a storage pool.
Instance Attribute Summary
Attributes inherited from AbstractCollection
Instance Method Summary collapse
-
#all ⇒ Array
Returns all storage volumes.
-
#create(spec) ⇒ StorageVolume
Creates a new storage volume from an XML specification.
-
#find(value) ⇒ StorageVolume
Searches for a storage volume.
-
#find_by_key(key) ⇒ StorageVolume
Searches for a storage volume by key.
-
#find_by_name(name) ⇒ StorageVolume
Searches for a storage volume by name.
-
#find_by_path(path) ⇒ StorageVolume
Searches for a storage volume by path.
Methods inherited from AbstractCollection
Constructor Details
This class inherits a constructor from Libvirt::Collection::AbstractCollection
Instance Method Details
#all ⇒ Array
Returns all storage volumes. Its unnecessary to call this directly
since the #all array is delegated for the various Array
-like
methods.
50 51 52 53 54 |
# File 'lib/libvirt/collection/storage_volume_collection.rb', line 50 def all read_array(:virStoragePoolListVolumes, :virStoragePoolNumOfVolumes, :string).collect do |name| find_by_name(name) end end |
#create(spec) ⇒ StorageVolume
Creates a new storage volume from an XML specification.
41 42 43 |
# File 'lib/libvirt/collection/storage_volume_collection.rb', line 41 def create(spec) nil_or_object(FFI::Libvirt.virStorageVolCreateXML(interface, spec, 0), StorageVolume) end |
#find(value) ⇒ StorageVolume
Searches for a storage volume. This will search by name, then by key, then finally by path. If no storage volume is found, nil will be returned.
11 12 13 14 15 |
# File 'lib/libvirt/collection/storage_volume_collection.rb', line 11 def find(value) result = find_by_name(value) rescue nil result ||= find_by_key(value) rescue nil result ||= find_by_path(value) rescue nil end |
#find_by_key(key) ⇒ StorageVolume
Searches for a storage volume by key.
27 28 29 |
# File 'lib/libvirt/collection/storage_volume_collection.rb', line 27 def find_by_key(key) nil_or_object(FFI::Libvirt.virStorageVolLookupByKey(interface.connection, key), StorageVolume) end |
#find_by_name(name) ⇒ StorageVolume
Searches for a storage volume by name.
20 21 22 |
# File 'lib/libvirt/collection/storage_volume_collection.rb', line 20 def find_by_name(name) nil_or_object(FFI::Libvirt.virStorageVolLookupByName(interface, name), StorageVolume) end |
#find_by_path(path) ⇒ StorageVolume
Searches for a storage volume by path.
34 35 36 |
# File 'lib/libvirt/collection/storage_volume_collection.rb', line 34 def find_by_path(path) nil_or_object(FFI::Libvirt.virStorageVolLookupByPath(interface.connection, path), StorageVolume) end |