Class: Libvirt::StoragePool
- Inherits:
-
Object
- Object
- Libvirt::StoragePool
- Defined in:
- lib/libvirt/storage_pool.rb
Overview
Represents a single storage pool.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Provide a meaningful equality check for two storage pools by comparing UUID.
-
#active? ⇒ Boolean
Deterine if the storage pool is active or not.
-
#allocation ⇒ Fixnum
Returns the current allocation in bytes.
-
#available ⇒ Fixnum
Returns the available free space in bytes.
-
#build ⇒ Boolean
Build the underlying storage pool.
-
#capacity ⇒ Fixnum
Returns the capacity in bytes.
-
#connection ⇒ Connection
Returns the connection of this storage pool.
-
#create ⇒ Boolean
(also: #start)
Starts an inactive storage pool.
-
#delete(type = nil) ⇒ Boolean
Delete the underlying pool resources.
-
#destroy ⇒ Boolean
(also: #stop)
Stops an active storage pool.
-
#initialize(pointer) ⇒ StoragePool
constructor
Initializes a new StoragePool object given a
virStoragePoolPtr
. -
#name ⇒ String
Returns the name of the network as a string.
-
#persistent? ⇒ Boolean
Determine if the storage pool is persistent or not.
-
#state ⇒ Symbol
Returns the state of the storage pool as a symbol.
-
#to_ptr ⇒ FFI::Pointer
Returns the actual
virStoragePoolPtr
underlying this structure. -
#undefine ⇒ Boolean
Undefines the storage pool.
-
#uuid ⇒ String
Returns the UUID of the storage pool as a string.
-
#volumes ⇒ Collection::StorageVolumeCollection
Returns the volumes associated with this storage pool.
-
#xml ⇒ String
Returns the XML description of this storage pool.
Constructor Details
#initialize(pointer) ⇒ StoragePool
Initializes a new Libvirt::StoragePool object given a virStoragePoolPtr
.
Do not call this directly. Instead, use the Connection#storage_pools
object to retrieve a specific Libvirt::StoragePool.
7 8 9 10 |
# File 'lib/libvirt/storage_pool.rb', line 7 def initialize(pointer) @pointer = pointer ObjectSpace.define_finalizer(self, method(:finalize)) end |
Instance Method Details
#==(other) ⇒ Boolean
Provide a meaningful equality check for two storage pools by comparing UUID.
137 138 139 |
# File 'lib/libvirt/storage_pool.rb', line 137 def ==(other) other.is_a?(StoragePool) && other.uuid == uuid end |
#active? ⇒ Boolean
Deterine if the storage pool is active or not.
45 46 47 |
# File 'lib/libvirt/storage_pool.rb', line 45 def active? FFI::Libvirt.virStoragePoolIsActive(self) == 1 end |
#allocation ⇒ Fixnum
Returns the current allocation in bytes.
115 116 117 |
# File 'lib/libvirt/storage_pool.rb', line 115 def allocation info[:allocation] end |
#available ⇒ Fixnum
Returns the available free space in bytes.
122 123 124 |
# File 'lib/libvirt/storage_pool.rb', line 122 def available info[:available] end |
#build ⇒ Boolean
Build the underlying storage pool.
59 60 61 |
# File 'lib/libvirt/storage_pool.rb', line 59 def build FFI::Libvirt.virStoragePoolBuild(self, 0) == 0 end |
#capacity ⇒ Fixnum
Returns the capacity in bytes.
108 109 110 |
# File 'lib/libvirt/storage_pool.rb', line 108 def capacity info[:capacity] end |
#connection ⇒ Connection
Returns the connection of this storage pool.
15 16 17 |
# File 'lib/libvirt/storage_pool.rb', line 15 def connection Connection.new(FFI::Libvirt.virStoragePoolGetConnect(self)) end |
#create ⇒ Boolean Also known as: start
Starts an inactive storage pool.
66 67 68 69 |
# File 'lib/libvirt/storage_pool.rb', line 66 def create return true if active? FFI::Libvirt.virStoragePoolCreate(self, 0) == 0 end |
#delete(type = nil) ⇒ Boolean
Delete the underlying pool resources. This is a non-recoverable operation. This won't undefine the pool.
76 77 78 79 |
# File 'lib/libvirt/storage_pool.rb', line 76 def delete(type=nil) type ||= :normal FFI::Libvirt.virStoragePoolDelete(self, type) == 0 end |
#destroy ⇒ Boolean Also known as: stop
Stops an active storage pool.
84 85 86 |
# File 'lib/libvirt/storage_pool.rb', line 84 def destroy FFI::Libvirt.virStoragePoolDestroy(self) == 0 end |
#name ⇒ String
Returns the name of the network as a string.
22 23 24 |
# File 'lib/libvirt/storage_pool.rb', line 22 def name FFI::Libvirt.virStoragePoolGetName(self) end |
#persistent? ⇒ Boolean
Determine if the storage pool is persistent or not.
52 53 54 |
# File 'lib/libvirt/storage_pool.rb', line 52 def persistent? FFI::Libvirt.virStoragePoolIsPersistent(self) == 1 end |
#state ⇒ Symbol
Returns the state of the storage pool as a symbol.
101 102 103 |
# File 'lib/libvirt/storage_pool.rb', line 101 def state info[:state] end |
#to_ptr ⇒ FFI::Pointer
Returns the actual virStoragePoolPtr
underlying this structure.
144 145 146 |
# File 'lib/libvirt/storage_pool.rb', line 144 def to_ptr @pointer end |
#undefine ⇒ Boolean
Undefines the storage pool. This requires that the storage pool be inactive. This won't delete the underlying resources of the storage pool, however. Run #delete for that.
94 95 96 |
# File 'lib/libvirt/storage_pool.rb', line 94 def undefine FFI::Libvirt.virStoragePoolUndefine(self) == 0 end |
#uuid ⇒ String
Returns the UUID of the storage pool as a string.
29 30 31 32 33 |
# File 'lib/libvirt/storage_pool.rb', line 29 def uuid output_ptr = FFI::MemoryPointer.new(:char, 36) FFI::Libvirt.virStoragePoolGetUUIDString(self, output_ptr) output_ptr.read_string end |
#volumes ⇒ Collection::StorageVolumeCollection
Returns the volumes associated with this storage pool.
129 130 131 |
# File 'lib/libvirt/storage_pool.rb', line 129 def volumes Collection::StorageVolumeCollection.new(self) end |