Adding a "none" node source, which will be the default node source and will just return an empty node.
This commit is contained in:
Родитель
90a9d09cd0
Коммит
65559af75e
|
@ -549,7 +549,9 @@ module Puppet
|
||||||
setdefaults(:parser,
|
setdefaults(:parser,
|
||||||
:typecheck => [true, "Whether to validate types during parsing."],
|
:typecheck => [true, "Whether to validate types during parsing."],
|
||||||
:paramcheck => [true, "Whether to validate parameters 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."]
|
See the `NodeSourceReference`:trac: for more information."]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
@ -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(%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")
|
assert_equal({"base" => "true", "center" => "boo", "master" => "far"}, node.parameters, "node parameters were not set correctly with the top node")
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
class LdapNodeTest < PuppetTest::TestCase
|
class LdapNodeTest < PuppetTest::TestCase
|
||||||
|
|
Загрузка…
Ссылка в новой задаче