Class: Fog::Libvirt::Compute::Pool

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/libvirt/models/compute/pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Pool

Returns a new instance of Pool.



20
21
22
23
24
# File 'lib/fog/libvirt/models/compute/pool.rb', line 20

def initialize(attributes={} )
  # Can be created by passing in XML
  @xml = attributes.delete(:xml)
  super(attributes)
end

Instance Attribute Details

#xmlObject (readonly)

Returns the value of attribute xml.



7
8
9
# File 'lib/fog/libvirt/models/compute/pool.rb', line 7

def xml
  @xml
end

Instance Method Details

#active?Boolean

Is the pool active or not?

Returns:

  • (Boolean)


63
64
65
# File 'lib/fog/libvirt/models/compute/pool.rb', line 63

def active?
  active
end

#auto_start?Boolean

Will the pool autostart or not?

Returns:

  • (Boolean)


68
69
70
# File 'lib/fog/libvirt/models/compute/pool.rb', line 68

def auto_start?
  autostart
end

#buildObject

Build this storage pool



50
51
52
# File 'lib/fog/libvirt/models/compute/pool.rb', line 50

def build
  service.pool_action uuid, :build
end

#destroyObject

Destroys the storage pool



55
56
57
58
59
60
# File 'lib/fog/libvirt/models/compute/pool.rb', line 55

def destroy
  # Shutdown pool if active
  service.pool_action uuid, :destroy if active?
  # If this is a persistent domain we need to undefine it
  service.pool_action uuid, :undefine if persistent?
end

#persistent?Boolean

Is the pool persistent or not?

Returns:

  • (Boolean)


73
74
75
# File 'lib/fog/libvirt/models/compute/pool.rb', line 73

def persistent?
  persistent
end

#saveObject

Raises:

  • (Fog::Errors::Error)


26
27
28
29
30
# File 'lib/fog/libvirt/models/compute/pool.rb', line 26

def save
  raise Fog::Errors::Error.new('Creating a new pool requires proper xml') unless xml
  self.uuid = (persistent ? service.define_pool(xml) : service.create_pool(xml)).uuid
  reload
end

#shutdownObject

Shuts down the pool



45
46
47
# File 'lib/fog/libvirt/models/compute/pool.rb', line 45

def shutdown
  stop
end

#startObject

Start the pool = make it active Performs a libvirt create (= start)



34
35
36
# File 'lib/fog/libvirt/models/compute/pool.rb', line 34

def start
  service.pool_action uuid, :create
end

#stopObject

Stop the pool = make it non-active Performs a libvirt destroy (= stop)



40
41
42
# File 'lib/fog/libvirt/models/compute/pool.rb', line 40

def stop
  service.pool_action uuid, :destroy
end

#volumesObject

Retrieves the volumes of this pool



78
79
80
# File 'lib/fog/libvirt/models/compute/pool.rb', line 78

def volumes
  service.list_pool_volumes uuid
end