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



7
8
9
10
11
# File 'lib/puppet/resource_api/puppet_context.rb', line 7

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



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

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

#transportObject



13
14
15
# File 'lib/puppet/resource_api/puppet_context.rb', line 13

def transport
  device.transport
end