Class: Puppet::Util::NetworkDevice::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/network_device/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



22
23
24
25
26
27
28
# File 'lib/puppet/util/network_device/config.rb', line 22

def initialize
  @file = Puppet::Util::WatchedFile.new(Puppet[:deviceconfig])

  @devices = {}

  read(true) # force reading at start
end

Instance Attribute Details

#devicesObject (readonly)

Returns the value of attribute devices.



16
17
18
# File 'lib/puppet/util/network_device/config.rb', line 16

def devices
  @devices
end

Class Method Details

.devicesObject



12
13
14
# File 'lib/puppet/util/network_device/config.rb', line 12

def self.devices
  main.devices || []
end

.mainObject



8
9
10
# File 'lib/puppet/util/network_device/config.rb', line 8

def self.main
  @main ||= new
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/puppet/util/network_device/config.rb', line 18

def exists?
  Puppet::FileSystem.exist?(@file.to_str)
end

#read(force = false) ⇒ Object

Read the configuration file.



31
32
33
34
35
# File 'lib/puppet/util/network_device/config.rb', line 31

def read(force = false)
  return unless exists?

  parse if force or @file.changed?
end