Class: Puppet::Util::NetworkDevice::Simple::Device
- Inherits:
-
Object
- Object
- Puppet::Util::NetworkDevice::Simple::Device
- Defined in:
- lib/puppet/util/network_device/simple/device.rb
Overview
A basic device class, that reads its configuration from the provided URL. The URL has to be a local file URL.
Instance Method Summary collapse
- #config ⇒ Object
- #facts ⇒ Object
-
#initialize(url, _options = {}) ⇒ Device
constructor
A new instance of Device.
Constructor Details
#initialize(url, _options = {}) ⇒ Device
Returns a new instance of Device.
9 10 11 12 |
# File 'lib/puppet/util/network_device/simple/device.rb', line 9 def initialize(url, = {}) @url = URI.parse(url) raise "Unexpected url '#{url}' found. Only file:/// URLs for configuration supported at the moment." unless @url.scheme == 'file' end |
Instance Method Details
#config ⇒ Object
18 19 20 21 |
# File 'lib/puppet/util/network_device/simple/device.rb', line 18 def config raise "Trying to load config from '#{@url.path}, but file does not exist." unless File.exist? @url.path @config ||= Hocon.load(@url.path, syntax: Hocon::ConfigSyntax::HOCON) end |
#facts ⇒ Object
14 15 16 |
# File 'lib/puppet/util/network_device/simple/device.rb', line 14 def facts {} end |