Sha256: 5515ad4a26091e945533a4b474bc5b168c33a10e40ad825d6be50fb95832ed15
Contents?: true
Size: 857 Bytes
Versions: 1
Compression:
Stored size: 857 Bytes
Contents
require 'hocon' require 'hocon/config_syntax' require 'puppet/util/network_device/base' module Puppet::Util::NetworkDevice::Simple # A basic device class, that reads its configuration from the provided URL. # The URL has to be a local file URL. class Device 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 def facts {} end 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
puppet-resource_api-1.4.0 | lib/puppet/util/network_device/simple/device.rb |