class Puppet::Indirector::Exec

Public Instance Methods

find(request) click to toggle source

Look for external node definitions.

   # File lib/puppet/indirector/exec.rb
 7 def find(request)
 8   name = request.key
 9   external_command = command
10 
11   # Make sure it's an array
12   raise Puppet::DevError, _("Exec commands must be an array") unless external_command.is_a?(Array)
13 
14   # Make sure it's fully qualified.
15   raise ArgumentError, _("You must set the exec parameter to a fully qualified command") unless Puppet::Util.absolute_path?(external_command[0])
16 
17   # Add our name to it.
18   external_command << name
19   begin
20     output = execute(external_command, :failonfail => true, :combine => false)
21   rescue Puppet::ExecutionFailure => detail
22     raise Puppet::Error, _("Failed to find %{name} via exec: %{detail}") % { name: name, detail: detail }, detail.backtrace
23   end
24 
25   if output =~ /\A\s*\Z/ # all whitespace
26     Puppet.debug { "Empty response for #{name} from #{self.name} terminus" }
27     return nil
28   else
29     return output
30   end
31 end

Private Instance Methods

execute(command, arguments) click to toggle source

Proxy the execution, so it's easier to test.

   # File lib/puppet/indirector/exec.rb
36 def execute(command, arguments)
37   Puppet::Util::Execution.execute(command,arguments)
38 end