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

- (Pool) initialize(options = {})

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

- (Object) name (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

- (Object) create_vol(vol)



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

- (Boolean) new?

Returns:

  • (Boolean)


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

def new?
  @pool.nil?
end

- (Object) path



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

def path
  document "pool/target/path"
end

- (Object) save



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

def save
  raise "not implemented"
end

- (Object) volumes



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

def volumes
  @pool.list_volumes
end