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