Class: Puppet::Util::NetworkDevice::Simple::Device

Inherits:
Object
  • Object
show all
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

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, _options = {})
  @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

#configObject



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

#factsObject



14
15
16
# File 'lib/puppet/util/network_device/simple/device.rb', line 14

def facts
  {}
end