Sha256: 9805967424708a1cc6e7e15a86b36e74655032d3cd888cb6d9f18e7b03f5592b

Contents?: true

Size: 1.56 KB

Versions: 24

Compression:

Stored size: 1.56 KB

Contents

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

Version data entries

24 entries across 24 versions & 6 rubygems

Version Path
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/pools.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/libvirt/models/compute/pools.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/pools.rb
fog-1.3.1 lib/fog/libvirt/models/compute/pools.rb
fog-1.3.0 lib/fog/libvirt/models/compute/pools.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/pools.rb
fog-1.2.0 lib/fog/libvirt/models/compute/pools.rb
ktheory-fog-1.1.2 lib/fog/libvirt/models/compute/pools.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/pools.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/pools.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/pools.rb
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/pools.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/pools.rb
fog-1.1.2 lib/fog/libvirt/models/compute/pools.rb
fog_tractical-1.1.4 lib/fog/libvirt/models/compute/pools.rb
fog_tractical-1.1.3 lib/fog/libvirt/models/compute/pools.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/pools.rb
fog-1.1.1 lib/fog/libvirt/models/compute/pools.rb
fog-1.1.0 lib/fog/libvirt/models/compute/pools.rb
brightbox-cli-0.15.0 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/pools.rb