Class: Puppet::ResourceApi::PuppetContext

Inherits:
BaseContext
  • Object
show all
Defined in:
lib/puppet/resource_api/puppet_context.rb

Overview

Implement Resource API Context to log through Puppet facilities and access/expose the puppet process’ current device/transport

Instance Attribute Summary

Attributes inherited from BaseContext

#type

Instance Method Summary collapse

Methods inherited from BaseContext

#attribute_changed, #failed, #failed?, #failing, #feature_support?, #initialize, #processed, #processing, #reset_failed

Constructor Details

This class inherits a constructor from Puppet::ResourceApi::BaseContext

Instance Method Details

#deviceObject



9
10
11
12
13
14
# File 'lib/puppet/resource_api/puppet_context.rb', line 9

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

#log_exception(exception, message: 'Error encountered', trace: false) ⇒ Object



20
21
22
# File 'lib/puppet/resource_api/puppet_context.rb', line 20

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

#transportObject



16
17
18
# File 'lib/puppet/resource_api/puppet_context.rb', line 16

def transport
  device.transport
end