Sha256: 7985afab6d22dd77ed2f9a88ab344b7a5c1f098393cb4e00f4fe565d7c113fe4

Contents?: true

Size: 945 Bytes

Versions: 23

Compression:

Stored size: 945 Bytes

Contents

require 'hocon'
require 'hocon/config_syntax'

# avoid loading puppet code base
module Puppet::Util; end
# avoid loading puppet code base
class Puppet::Util::NetworkDevice; end
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

23 entries across 23 versions & 1 rubygems

Version Path
puppet-resource_api-1.8.13 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.9 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.8 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.12 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.11 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.10 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.7 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.6 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.6.5 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.4 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.3 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.2 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.6.4 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.6.3 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.7.0 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.1 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.8.0 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.6.2 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.6.1 lib/puppet/util/network_device/simple/device.rb
puppet-resource_api-1.6.0 lib/puppet/util/network_device/simple/device.rb