Class: Virt::Pool

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/virt/pool.rb

Overview

implements Libvirt pool, at the moment it is assumed to be a file based pool.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#to_gb, #xml

Constructor Details

#initialize(options = {}) ⇒ Pool

Returns a new instance of Pool.



6
7
8
9
10
# File 'lib/virt/pool.rb', line 6

def initialize options = {}
  @name = options[:name] || raise("Must Provide a pool name")
  @connection = Virt.connection
  fetch_pool
end

Instance Attribute Details

#nameObject (readonly) Also known as: to_s

Returns the value of attribute name.



5
6
7
# File 'lib/virt/pool.rb', line 5

def name
  @name
end

Instance Method Details

#create_vol(vol) ⇒ Object



39
40
41
42
43
# File 'lib/virt/pool.rb', line 39

def create_vol vol
  raise "Must provide a Virt::Volume object" unless vol.is_a?(Virt::Volume)
  raise "Pool not saved, cant create volume" if new?
  @pool.create_vol_xml vol.xml
end

#new?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/virt/pool.rb', line 18

def new?
  @pool.nil?
end

#pathObject



35
36
37
# File 'lib/virt/pool.rb', line 35

def path
  document "pool/target/path"
end

#saveObject



14
15
16
# File 'lib/virt/pool.rb', line 14

def save
  raise "not implemented"
end

#volumesObject



22
23
24
# File 'lib/virt/pool.rb', line 22

def volumes
  @pool.list_volumes
end