summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-08-15 13:55:55 -0500
committerLuke Kanies <luke@madstop.com>2007-08-15 13:55:55 -0500
commit65559af75e3da6522f4c3e952a73d80e0040609c (patch)
tree3a7856db465f4f796fbdad9cac5880dbce563165
parent90a9d09cd08ec072530e2f000e9f7b65f1c41095 (diff)
downloadpuppet-65559af75e3da6522f4c3e952a73d80e0040609c.tar.gz
puppet-65559af75e3da6522f4c3e952a73d80e0040609c.tar.xz
puppet-65559af75e3da6522f4c3e952a73d80e0040609c.zip
Adding a "none" node source, which will be the default node source and will just return an empty node.
-rw-r--r--lib/puppet/configuration.rb4
-rw-r--r--lib/puppet/node_source/none.rb10
-rwxr-xr-xtest/network/handler/node.rb18
3 files changed, 31 insertions, 1 deletions
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