class ForemanAP::StoragePool

A storage pool containing disk volumes.

Public Class Methods

new(conn, name) click to toggle source

Create a new object.

conn

A libvirt connection handle.

name

The name of the storage pool.

# File lib/foreman_vm/storage_pool.rb, line 23
def initialize(conn, name)
  @sph = conn.lookup_storage_pool_by_name(name)
end

Public Instance Methods

create_volume(path,capacity) click to toggle source

Create a new volume within the storage pool.

path

the full path to the volume

capacity

the disk capacity, in bytes

# File lib/foreman_vm/storage_pool.rb, line 31
def create_volume(path,capacity)
  xml = "<volume>
           <name>#{File.basename(path)}</name>
           <key>#{path}</key>
           <source>
           </source>
           <capacity unit='bytes'>#{capacity}</capacity>
           <allocation unit='bytes'>197120</allocation>
           <target>
             <path>#{path}</path>
             <format type='raw'/>
             <permissions>
               <mode>0660</mode>
               <owner>107</owner>
               <group>107</group>
             </permissions>
           </target>
         </volume>
  "
  #TODO: @log.debug "creating volume: #{xml}"
  @sph.create_volume_xml(xml)
 end
refresh() click to toggle source

Scan the pool for changes. This is useful for pools that are shared across multiple hosts in a cluster.

# File lib/foreman_vm/storage_pool.rb, line 8
def refresh
  @sph.refresh
  true
end
volume(name) click to toggle source

Lookup a volume by name, and return an object handle.

# File lib/foreman_vm/storage_pool.rb, line 14
def volume(name)
  Volume.new(@sph, name)
end