Sha256: de27f483d739cecb13747e8249c6fecf9b132ee6a33c07e67171c7fa83196c4e

Contents?: true

Size: 1.61 KB

Versions: 24

Compression:

Stored size: 1.61 KB

Contents

require 'fog/core/collection'
require 'fog/libvirt/models/compute/network'

module Fog
  module Compute
    class Libvirt

      class Networks < Fog::Collection

        model Fog::Compute::Libvirt::Network

        def all(filter=nil)
          data=[]
          if filter.nil?
            connection.list_networks.each do |networkname|
              network=connection.lookup_network_by_name(networkname)
              data << { :raw => network }
            end
            connection.list_defined_networks.each do |networkname|
              network=connection.lookup_network_by_name(networkname)
              data << { :raw => network}
            end
          else
            network=nil
            begin
              network=get_by_uuid(filter[:uuid]) if filter.has_key?(:uuid)
              network=get_by_name(filter[:name]) if filter.has_key?(:name)
            rescue ::Libvirt::RetrieveError
              return nil
            end
            data << { :raw => network}
          end

          load(data)
        end

        def get(uuid)
          self.all(:uuid => uuid).first
        end

        #private # Making these private, screws up realod
        # Retrieve the network by uuid
        def get_by_uuid(uuid)
          network=connection.lookup_network_by_uuid(uuid)
          return network
          #          new(:raw => network)
        end

        # Retrieve the network by name
        def get_by_name(name)
          network=connection.lookup_network_by_name(name)
          return network
          #          new(:raw => network)
        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/networks.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/libvirt/models/compute/networks.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/networks.rb
fog-1.3.1 lib/fog/libvirt/models/compute/networks.rb
fog-1.3.0 lib/fog/libvirt/models/compute/networks.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/networks.rb
fog-1.2.0 lib/fog/libvirt/models/compute/networks.rb
ktheory-fog-1.1.2 lib/fog/libvirt/models/compute/networks.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/networks.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/networks.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/networks.rb
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/networks.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/networks.rb
fog-1.1.2 lib/fog/libvirt/models/compute/networks.rb
fog_tractical-1.1.4 lib/fog/libvirt/models/compute/networks.rb
fog_tractical-1.1.3 lib/fog/libvirt/models/compute/networks.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/networks.rb
fog-1.1.1 lib/fog/libvirt/models/compute/networks.rb
fog-1.1.0 lib/fog/libvirt/models/compute/networks.rb
brightbox-cli-0.15.0 lib/brightbox-cli/vendor/fog/lib/fog/libvirt/models/compute/networks.rb