Parent

Files

Class/Module Index [+]

Quicksearch

Fog::Compute::Libvirt::Pool

Public Class Methods

new(attributes={} ) click to toggle source

Can be created by passing in XML

# File lib/fog/libvirt/models/compute/pool.rb, line 17
def initialize(attributes={} )
  self.xml  ||= nil unless attributes[:xml]
  self.create_persistent  ||= true unless attributes[:create_persistent]
  self.create_auto_build ||= true unless attributes[:create_auto_build]
  super
end

Public Instance Methods

active?() click to toggle source

Is the pool active or not?

# File lib/fog/libvirt/models/compute/pool.rb, line 96
def active?
  requires :raw

  @raw.active?
end
allocation() click to toggle source

Retrieves the allocated disk space of the pool

# File lib/fog/libvirt/models/compute/pool.rb, line 136
def allocation
  requires :raw
  @raw.info.allocation
end
auto_start=(flag) click to toggle source

Set autostart value of the storage pool (true|false)

# File lib/fog/libvirt/models/compute/pool.rb, line 89
def auto_start=(flag)
  requires :raw

  @raw.auto_start(flag)
end
auto_start?() click to toggle source

Will the pool autostart or not?

# File lib/fog/libvirt/models/compute/pool.rb, line 103
def auto_start?
  requires :raw

  @raw.autostart?
end
build() click to toggle source

Build this storage pool

# File lib/fog/libvirt/models/compute/pool.rb, line 67
def build
  requires :raw

  @raw.build unless @raw.nil?
end
capacity() click to toggle source

Retrieves the capacity of disk space of the pool

# File lib/fog/libvirt/models/compute/pool.rb, line 142
def capacity
  requires :raw
  @raw.info.capacity
end
destroy( destroy_options={}) click to toggle source

Destroys the storage pool

# File lib/fog/libvirt/models/compute/pool.rb, line 74
def destroy( destroy_options={})
  requires :raw

  # Shutdown pool if active
  @raw.destroy if @raw.active?

  # Delete corresponding data in this pool
  # @raw.delete

  # If this is a persistent domain we need to undefine it
  @raw.undefine if @raw.persistent?

end
name() click to toggle source

Retrieves the name of the pool

# File lib/fog/libvirt/models/compute/pool.rb, line 124
def name
  requires :raw
  @raw.name
end
num_of_volumes() click to toggle source

Retrieves the number of volumes available in this pool

# File lib/fog/libvirt/models/compute/pool.rb, line 148
def num_of_volumes
  requires :raw
  @raw.num_of_volumes
end
persistent?() click to toggle source

Is the pool persistent or not?

# File lib/fog/libvirt/models/compute/pool.rb, line 110
def persistent?
  requires :raw
  @raw.persistent?
end
save() click to toggle source
# File lib/fog/libvirt/models/compute/pool.rb, line 24
def save
  requires :xml
  unless xml.nil?
    pool=nil
    if self.create_persistent
      pool=connection.raw.define_storage_pool_xml(xml)
    else
      pool=connection.raw.create_storage_pool_xml(xml)
    end
    self.raw=pool
    true
  else
    raise Fog::Errors::Error.new('Creating a new pool requires proper xml')
    false
  end
end
shutdown() click to toggle source

Shuts down the pool

# File lib/fog/libvirt/models/compute/pool.rb, line 59
def shutdown
  requires :raw

  @raw.destroy
  true
end
start() click to toggle source

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

# File lib/fog/libvirt/models/compute/pool.rb, line 44
def start
  requires :raw

  @raw.create
end
state() click to toggle source
# File lib/fog/libvirt/models/compute/pool.rb, line 153
def state
  requires :raw

  #INACTIVE = INT2NUM(VIR_STORAGE_POOL_INACTIVE)     virStoragePoolState
  #BUILDING = INT2NUM(VIR_STORAGE_POOL_BUILDING)
  #RUNNING  = INT2NUM(VIR_STORAGE_POOL_RUNNING)
  #DEGRADED = INT2NUM(VIR_STORAGE_POOL_DEGRADED)
  #INACCESSIBLE = INT2NUM(VIR_STORAGE_POOL_INACCESSIBLE)
  states=[:inactive, :building,:running,:degrated,:inaccessible]

  return states[@raw.info.state]

end
stop() click to toggle source

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

# File lib/fog/libvirt/models/compute/pool.rb, line 52
def stop
  requires :raw

  @raw.destroy
end
uuid() click to toggle source

Retrieves the uuid of the pool

# File lib/fog/libvirt/models/compute/pool.rb, line 130
def uuid
  requires :raw
  @raw.uuid
end
volumes() click to toggle source

Retrieves the volumes of this pool

# File lib/fog/libvirt/models/compute/pool.rb, line 168
def volumes

  volumes=Array.new
  @raw.list_volumes.each do |volume|
    fog_volume=connection.volumes.all(:name => volume).first
    volumes << fog_volume
  end
  return volumes
end
xml_desc() click to toggle source

Returns the xml description of the current pool

# File lib/fog/libvirt/models/compute/pool.rb, line 116
def xml_desc
  requires :raw

  @raw.xml_desc unless @raw.nil?
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.