Sha256: 95b97759fe947f9115f34f22c6d87040092b9c0c709ee47bd995d064bb1efc06

Contents?: true

Size: 827 Bytes

Versions: 13

Compression:

Stored size: 827 Bytes

Contents

require 'puppet/resource_api/base_context'
require 'puppet/util/logging'

# Implement Resource API Context to log through Puppet facilities
# and access/expose the puppet process' current device/transport
class Puppet::ResourceApi::PuppetContext < Puppet::ResourceApi::BaseContext
  def device
    # TODO: evaluate facter_url setting for loading config if there is no `current` NetworkDevice
    raise 'no device configured' unless Puppet::Util::NetworkDevice.current
    Puppet::Util::NetworkDevice.current
  end

  def transport
    device.transport
  end

  def log_exception(exception, message: 'Error encountered', trace: false)
    super(exception, message: message, trace: trace || Puppet[:trace])
  end

  protected

  def send_log(level, message)
    Puppet::Util::Log.create(level: level, message: message)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
puppet-resource_api-1.8.13 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.9 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.8 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.12 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.11 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.10 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.7 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.6 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.4 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.3 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.2 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.1 lib/puppet/resource_api/puppet_context.rb
puppet-resource_api-1.8.0 lib/puppet/resource_api/puppet_context.rb