Sha256: 524ce98f3ff7ede53ce63c96d6d201f30c37fce14ade981b1bf78e5180e36c80

Contents?: true

Size: 1.65 KB

Versions: 24

Compression:

Stored size: 1.65 KB

Contents

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

module Fog
  module Compute
    class Libvirt

      class Interfaces < Fog::Collection

        model Fog::Compute::Libvirt::Interface

        def all(filter=nil)
          data=[]
          if filter.nil?
            connection.raw.list_interfaces.each do |ifname|
              interface=connection.raw.lookup_interface_by_name(ifname)
              data << { :raw => interface }
            end
            connection.raw.list_defined_interfaces.each do |ifname|
              interface=connection.raw.lookup_interface_by_name(ifname)
              data << { :raw => interface }
            end

          else
            interface=nil
            begin
              interface=get_by_name(filter[:name]) if filter.has_key?(:name)
              interface=get_by_mac(filter[:mac]) if filter.has_key?(:mac)
            rescue ::Libvirt::RetrieveError
              return nil
            end
            data << { :raw => interface}
          end

          load(data)
        end

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

        #private # Making these private, screws up realod
        # Retrieve the interface by name
        def get_by_name(name)
          interface=connection.raw.lookup_interface_by_name(name)
          return interface
          #          new(:raw => interface)
        end

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