# class Puppet::Provider::NetworkDevice

This is the base class of all prefetched network device provider

### Attributes

device[RW]

### Public Class Methods

device(url) click to toggle source

    # File lib/puppet/provider/network_device.rb, line 5
    def self.device(url)
      raise "This provider doesn't implement the necessary device method"
    end

instances() click to toggle source

    # File lib/puppet/provider/network_device.rb, line 58
    def self.instances
    end

lookup(device, name) click to toggle source

    # File lib/puppet/provider/network_device.rb, line 9
    def self.lookup(device, name)
      raise "This provider doesn't implement the necessary lookup method"
    end

new(device, *args) click to toggle source
Calls superclass method Puppet::Provider.new

    # File lib/puppet/provider/network_device.rb, line 31
    def initialize(device, *args)
      super(*args)

      @device = device

      # Make a duplicate, so that we have a copy for comparison
      # at the end.
      @properties = @property_hash.dup
    end

prefetch(resources) click to toggle source

    # File lib/puppet/provider/network_device.rb, line 13
    def self.prefetch(resources)
      resources.each do |name, resource|
        device = Puppet::Util::NetworkDevice.current || device(resource[:device_url])
        if result = lookup(device, name)
          result[:ensure] = :present
          resource.provider = new(device, result)
        else
          resource.provider = new(device, :ensure => :absent)
        end
      end
    end

### Public Instance Methods

create() click to toggle source

    # File lib/puppet/provider/network_device.rb, line 41
    def create
      @property_hash[:ensure] = :present
      self.class.resource_type.validproperties.each do |property|
        if val = resource.should(property)
          @property_hash[property] = val
        end
      end
    end

destroy() click to toggle source

    # File lib/puppet/provider/network_device.rb, line 50
    def destroy
      @property_hash[:ensure] = :absent
    end

exists?() click to toggle source

    # File lib/puppet/provider/network_device.rb, line 25
    def exists?
      @property_hash[:ensure] != :absent
    end

flush() click to toggle source

    # File lib/puppet/provider/network_device.rb, line 54
    def flush
      @property_hash.clear
    end

former_properties() click to toggle source

    # File lib/puppet/provider/network_device.rb, line 61
    def former_properties
      @properties.dup
    end

properties() click to toggle source

    # File lib/puppet/provider/network_device.rb, line 65
    def properties
      @property_hash.dup
    end