Class: Libvirt::StorageVolume

Inherits:
Object
  • Object
show all
Defined in:
lib/libvirt/storage_volume.rb

Overview

Represents a single storage volume.

Instance Method Summary collapse

Constructor Details

#initialize(pointer) ⇒ StorageVolume

Initializes a new Libvirt::StorageVolume object given a virStorageVolPtr. Do not call this directly. Instead, use the Libvirt::StoragePool#volumes collection object to retrieve a specific Libvirt::StorageVolume.



7
8
9
10
# File 'lib/libvirt/storage_volume.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 so that two storage volumes can eaisly be checked for equality.

Returns:

  • (Boolean)


87
88
89
# File 'lib/libvirt/storage_volume.rb', line 87

def ==(other)
  other.is_a?(StorageVolume) && other.uuid == uuid
end

#allocationInteger

Returns the currently allocated number of bytes.

Returns:

  • (Integer)


51
52
53
# File 'lib/libvirt/storage_volume.rb', line 51

def allocation
  info[:allocation]
end

#capacityInteger

Returns the capacity of this volume in bytes.

Returns:

  • (Integer)


44
45
46
# File 'lib/libvirt/storage_volume.rb', line 44

def capacity
  info[:capacity]
end

#deleteBoolean

Delete the storage volume rom the pool.

Returns:

  • (Boolean)


65
66
67
# File 'lib/libvirt/storage_volume.rb', line 65

def delete
  FFI::Libvirt.virStorageVolDelete(self, 0) == 0
end

#keyString Also known as: uuid

Returns a key for this storage volume. The key is a unique identifier.

Returns:

  • (String)


15
16
17
# File 'lib/libvirt/storage_volume.rb', line 15

def key
  FFI::Libvirt.virStorageVolGetKey(self)
end

#nameString

Returns the name of this storage volume.

Returns:

  • (String)


23
24
25
# File 'lib/libvirt/storage_volume.rb', line 23

def name
  FFI::Libvirt.virStorageVolGetName(self)
end

#pathString

Returns the path of this storage volume.

Returns:

  • (String)


30
31
32
# File 'lib/libvirt/storage_volume.rb', line 30

def path
  FFI::Libvirt.virStorageVolGetPath(self)
end

#to_ptrFFI::Pointer

Returns the actual virStorageVolPtr underlying this structure.

Returns:

  • (FFI::Pointer)


79
80
81
# File 'lib/libvirt/storage_volume.rb', line 79

def to_ptr
  @pointer
end

#typeSymbol

Returns the type of this storage volume.

Returns:

  • (Symbol)


37
38
39
# File 'lib/libvirt/storage_volume.rb', line 37

def type
  info[:type]
end

#wipeBoolean

Wipe the contents of a volume so it is not readable in the future.

Returns:

  • (Boolean)


58
59
60
# File 'lib/libvirt/storage_volume.rb', line 58

def wipe
  FFI::Libvirt.virStorageVolWipe(self, 0) == 0
end

#xmlString

Returns the XML description of this storage volume.

Returns:

  • (String)


72
73
74
# File 'lib/libvirt/storage_volume.rb', line 72

def xml
  FFI::Libvirt.virStorageVolGetXMLDesc(self, 0)
end