diff --git a/lib/puppet/configuration.rb b/lib/puppet/configuration.rb index 574038338..a8f6e0c35 100644 --- a/lib/puppet/configuration.rb +++ b/lib/puppet/configuration.rb @@ -549,7 +549,9 @@ module Puppet setdefaults(:parser, :typecheck => [true, "Whether to validate types during parsing."], :paramcheck => [true, "Whether to validate parameters during parsing."], - :node_source => ["", "Where to look for node configuration information. + :node_source => ["none", "Where to look for node configuration information. + The default node source, ``none``, just returns a node with its facts + filled in, which is required for normal functionality. See the `NodeSourceReference`:trac: for more information."] ) diff --git a/lib/puppet/node_source/none.rb b/lib/puppet/node_source/none.rb new file mode 100644 index 000000000..ce188add5 --- /dev/null +++ b/lib/puppet/node_source/none.rb @@ -0,0 +1,10 @@ +Puppet::Network::Handler::Node.newnode_source(:none, :fact_merge => true) do + desc "Always return an empty node object. This is the node source you should + use when you don't have some other, functional source you want to use, + as the compiler will not work without this node information." + + # Just return an empty node. + def nodesearch(name) + newnode(name) + end +end diff --git a/test/network/handler/node.rb b/test/network/handler/node.rb index 02da9eef0..37b63db69 100755 --- a/test/network/handler/node.rb +++ b/test/network/handler/node.rb @@ -529,6 +529,24 @@ class TestNodeSources < Test::Unit::TestCase assert_equal(%w{one two three four five}.sort, node.classes.sort, "node classes were not set correctly with the top node") assert_equal({"base" => "true", "center" => "boo", "master" => "far"}, node.parameters, "node parameters were not set correctly with the top node") end + + # Make sure we always get a node back from the 'none' nodesource. + def test_nodesource_none + source = Node.node_source(:none) + assert(source, "Could not find 'none' node source") + searcher = mk_searcher(:none) + assert(searcher.fact_merge?, "'none' node source does not merge facts") + + # Run a couple of node names through it + node = nil + %w{192.168.0.1 0:0:0:3:a:f host host.domain.com}.each do |name| + assert_nothing_raised("Could not create an empty node with name '%s'" % name) do + node = searcher.nodesearch(name) + end + assert_instance_of(SimpleNode, node, "Did not get a simple node back for %s" % name) + assert_equal(name, node.name, "Name was not set correctly") + end + end end class LdapNodeTest < PuppetTest::TestCase