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.



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

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.



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

def devices
  @devices
end

Class Method Details

.devicesObject



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

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

.mainObject



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

def self.main
  @main ||= self.new
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


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

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

#read(force = false) ⇒ Object

Read the configuration file.



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

def read(force = false)
  return unless exists?

  parse if force or @file.changed?
end