Class: Puppet::Provider::NetworkDevice

Inherits:
Puppet::Provider show all
Defined in:
lib/vendor/puppet/provider/network_device.rb

Overview

This is the base class of all prefetched network device provider

Direct Known Subclasses

Cisco

Constant Summary

Constants included from Util

Util::AbsolutePathPosix, Util::AbsolutePathWindows

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Instance Attribute Summary collapse

Attributes inherited from Puppet::Provider

#model, #resource

Attributes included from Util::Docs

#doc, #nodoc

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Puppet::Provider

#<=>, #clear, command, #command, commands, declared_feature?, default?, defaultfor, #get, initvars, make_command_methods, mk_resource_methods, mkmodelmethods, #name, optional_commands, #set, specificity, supports_parameter?, #to_s

Methods included from Util::Logging

#clear_deprecation_warnings, #deprecation_warning, #send_log

Methods included from Util

absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, #execfail, #execpipe, execute, execute_posix, execute_windows, logmethods, memory, path_to_uri, proxy, replace_file, safe_posix_fork, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, uri_to_path, wait_for_output, which, withumask

Methods included from Util::POSIX

#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Methods included from Util::Docs

#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub

Methods included from Util::Warnings

clear_warnings, notice_once, warnonce

Methods included from Confiner

#confine, #confine_collection, #suitable?

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail

Constructor Details

#initialize(device, *args) ⇒ NetworkDevice

Returns a new instance of NetworkDevice.



31
32
33
34
35
36
37
38
39
# File 'lib/vendor/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

Instance Attribute Details

#deviceObject

Returns the value of attribute device.



29
30
31
# File 'lib/vendor/puppet/provider/network_device.rb', line 29

def device
  @device
end

Class Method Details

.device(url) ⇒ Object



5
6
7
# File 'lib/vendor/puppet/provider/network_device.rb', line 5

def self.device(url)
  raise "This provider doesn't implement the necessary device method"
end

.instancesObject



58
59
# File 'lib/vendor/puppet/provider/network_device.rb', line 58

def self.instances
end

.lookup(device, name) ⇒ Object



9
10
11
# File 'lib/vendor/puppet/provider/network_device.rb', line 9

def self.lookup(device, name)
  raise "This provider doesn't implement the necessary lookup method"
end

.prefetch(resources) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/vendor/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

Instance Method Details

#createObject



41
42
43
44
45
46
47
48
# File 'lib/vendor/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

#destroyObject



50
51
52
# File 'lib/vendor/puppet/provider/network_device.rb', line 50

def destroy
  @property_hash[:ensure] = :absent
end

#exists?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/vendor/puppet/provider/network_device.rb', line 25

def exists?
  @property_hash[:ensure] != :absent
end

#flushObject



54
55
56
# File 'lib/vendor/puppet/provider/network_device.rb', line 54

def flush
  @property_hash.clear
end

#former_propertiesObject



61
62
63
# File 'lib/vendor/puppet/provider/network_device.rb', line 61

def former_properties
  @properties.dup
end

#propertiesObject



65
66
67
# File 'lib/vendor/puppet/provider/network_device.rb', line 65

def properties
  @property_hash.dup
end