diff options
author | Luke Kanies <luke@madstop.com> | 2007-08-13 14:50:22 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-08-13 14:50:22 -0500 |
commit | ab42534ae243c24c8c702e38195a954ab52eaed9 (patch) | |
tree | ab7f4320da1b9c4c7510fd576b1b84b24d2f3139 | |
parent | 24e7b4d034bf5e50996846494949fd90ec617b4d (diff) | |
download | puppet-ab42534ae243c24c8c702e38195a954ab52eaed9.tar.gz puppet-ab42534ae243c24c8c702e38195a954ab52eaed9.tar.xz puppet-ab42534ae243c24c8c702e38195a954ab52eaed9.zip |
Applying patch by Adam Jacob to make external node tools able to handle command-line arguments
-rw-r--r-- | lib/puppet/parser/interpreter.rb | 9 | ||||
-rwxr-xr-x | test/language/interpreter.rb | 18 |
2 files changed, 22 insertions, 5 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index 9da1928b3..3ba9c0c7a 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -480,9 +480,14 @@ class Puppet::Parser::Interpreter # Look for external node definitions. def nodesearch_external(name) return nil unless Puppet[:external_nodes] != "none" - + + # This is a very cheap way to do this, since it will break on + # commands that have spaces in the arguments. But it's good + # enough for most cases. + external_node_command = Puppet[:external_nodes].split + external_node_command << name begin - output = Puppet::Util.execute([Puppet[:external_nodes], name]) + output = Puppet::Util.execute(external_node_command) rescue Puppet::ExecutionFailure => detail if $?.exitstatus == 1 return nil diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb index 6352a147e..75800cc41 100755 --- a/test/language/interpreter.rb +++ b/test/language/interpreter.rb @@ -440,15 +440,15 @@ class TestInterpreter < PuppetTest::TestCase File.open(mapper, "w") { |f| f.puts "#!#{ruby} require 'yaml' - name = ARGV[0].chomp + name = ARGV.last.chomp result = {} if name =~ /a/ - result[:parameters] = {'one' => ARGV[0] + '1', 'two' => ARGV[0] + '2'} + result[:parameters] = {'one' => ARGV.last + '1', 'two' => ARGV.last + '2'} end if name =~ /p/ - result['classes'] = [1,2,3].collect { |n| ARGV[0] + n.to_s } + result['classes'] = [1,2,3].collect { |n| ARGV.last + n.to_s } end puts YAML.dump(result) @@ -496,6 +496,18 @@ class TestInterpreter < PuppetTest::TestCase assert_nil(node) end + # Make sure a nodesearch with arguments works + def test_nodesearch_external_arguments + mapper = mk_node_mapper + Puppet[:external_nodes] = "#{mapper} -s something -p somethingelse" + interp = mkinterp + node = nil + assert_nothing_raised do + node = interp.nodesearch("apple") + end + assert_instance_of(NodeDef, node, "did not create node") + end + # A wrapper test, to make sure we're correctly calling the external search method. def test_nodesearch_external_functional mapper = mk_node_mapper |