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_or_config, _options = {}) ⇒ Device

Returns a new instance of Device.



14
15
16
17
18
19
20
21
# File 'lib/puppet/util/network_device/simple/device.rb', line 14

def initialize(url_or_config, _options = {})
  if url_or_config.is_a? String
    @url = URI.parse(url_or_config)
    raise "Unexpected url '#{url_or_config}' found. Only file:/// URLs for configuration supported at the moment." unless @url.scheme == 'file'
  else
    @config = url_or_config
  end
end

Instance Method Details

#configObject



27
28
29
30
# File 'lib/puppet/util/network_device/simple/device.rb', line 27

def config
  raise "Trying to load config from '#{@url.path}, but file does not exist." if @url && !File.exist?(@url.path)
  @config ||= Hocon.load(@url.path, syntax: Hocon::ConfigSyntax::HOCON)
end

#factsObject



23
24
25
# File 'lib/puppet/util/network_device/simple/device.rb', line 23

def facts
  {}
end