1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/libvirt/models/compute/pools.rb
Patrick Debois 4740174f12 [Libvirt] renamed 'raw' connection to raw in the Fog Connection
Because the initial provider was copied from the virtualbox example we ended up with a notation
connection.connection for the raw provider

The function of the raw are injected on the connection object. Still in analogy with the raw
for server , volume, ... it makes sense to rename connection.connection to connection.raw

Also all calls to the raw connection are now explicit
2011-09-13 07:34:18 +02:00

60 lines
1.6 KiB
Ruby

require 'fog/core/collection'
require 'fog/libvirt/models/compute/pool'
module Fog
module Compute
class Libvirt
class Pools < Fog::Collection
model Fog::Compute::Libvirt::Pool
def all(filter=nil)
data=[]
if filter.nil?
connection.raw.list_storage_pools.each do |poolname|
pool=connection.raw.lookup_storage_pool_by_name(poolname)
data << { :raw => pool }
end
connection.raw.list_defined_storage_pools.each do |poolname|
data << {
:raw => connection.raw.lookup_storage_pool_by_name(poolname)
}
end
else
pool=nil
begin
pool=get_by_uuid(filter[:uuid]) if filter.has_key?(:uuid)
pool=get_by_name(filter[:name]) if filter.has_key?(:name)
rescue ::Libvirt::RetrieveError
return nil
end
data << { :raw => pool}
end
load(data)
end
def get(uuid)
self.all(:uuid => uuid).first
end
#private # Making these private, screws up realod
# Retrieve the pool by uuid
def get_by_uuid(uuid)
pool=connection.raw.lookup_storage_pool_by_uuid(uuid)
return pool
end
# Retrieve the pool by name
def get_by_name(name)
pool=connection.raw.lookup_storage_pool_by_name(name)
return pool
# new(:raw => pool)
end
end #class
end #Class
end #module
end #module