Clarifying the errors a bit when nodes come from external sources.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2324 980ebf18-57e1-0310-9a29-db15c13687c0
This commit is contained in:
Родитель
1f8b768e4e
Коммит
9b5833a63c
|
@ -22,12 +22,14 @@ module Puppet # :nodoc:
|
|||
|
||||
def to_s
|
||||
str = nil
|
||||
if defined? @file and defined? @line and @file and @line
|
||||
if self.file and self.line
|
||||
str = "%s at %s:%s" %
|
||||
[@message.to_s, @file, @line]
|
||||
elsif defined? @line and @line
|
||||
elsif self.line
|
||||
str = "%s at line %s" %
|
||||
[@message.to_s, @line]
|
||||
elsif self.file
|
||||
str = "%s in %s" % [@message.to_s, self.file]
|
||||
else
|
||||
str = @message.to_s
|
||||
end
|
||||
|
|
|
@ -113,13 +113,19 @@ module Functions
|
|||
! klasses.include?(klass)
|
||||
end
|
||||
|
||||
# Throw an error if we didn't evaluate all of the classes.
|
||||
if missing.length == 1
|
||||
self.fail Puppet::ParseError,
|
||||
"Could not find class %s" % missing
|
||||
elsif missing.length > 1
|
||||
self.fail Puppet::ParseError,
|
||||
"Could not find classes %s" % missing.join(", ")
|
||||
unless missing.empty?
|
||||
# Throw an error if we didn't evaluate all of the classes.
|
||||
str = "Could not find class"
|
||||
if missing.length > 1
|
||||
str += "es"
|
||||
end
|
||||
|
||||
str += " " + missing.join(", ")
|
||||
|
||||
if n = namespaces and ! n.empty? and n != [""]
|
||||
str += " in namespaces %s" % @namespaces.join(", ")
|
||||
end
|
||||
self.fail Puppet::ParseError, str
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -635,11 +635,11 @@ end
|
|||
# available.
|
||||
def ast(klass, hash = nil)
|
||||
hash ||= {}
|
||||
unless hash[:line]
|
||||
unless hash.include?(:line)
|
||||
hash[:line] = @lexer.line
|
||||
end
|
||||
|
||||
unless hash[:file]
|
||||
unless hash.include?(:file)
|
||||
if file = @lexer.file
|
||||
hash[:file] = file
|
||||
end
|
||||
|
|
|
@ -314,7 +314,7 @@ class Puppet::Parser::Interpreter
|
|||
end
|
||||
|
||||
# Create a new node, just from a list of names, classes, and an optional parent.
|
||||
def gennode(name, hash)
|
||||
def gennode(name, hash, source = nil)
|
||||
facts = hash[:facts]
|
||||
classes = hash[:classes]
|
||||
parent = hash[:parentnode]
|
||||
|
@ -348,7 +348,14 @@ class Puppet::Parser::Interpreter
|
|||
end
|
||||
|
||||
# Create the node
|
||||
return @parser.ast(AST::Node, arghash)
|
||||
if source
|
||||
arghash[:file] = source
|
||||
else
|
||||
arghash[:file] = nil
|
||||
end
|
||||
arghash[:line] = nil
|
||||
node = @parser.ast(AST::Node, arghash)
|
||||
return node
|
||||
end
|
||||
|
||||
# create our interpreter
|
||||
|
@ -716,7 +723,7 @@ class Puppet::Parser::Interpreter
|
|||
Puppet.warning "Somehow got a node with no information"
|
||||
return nil
|
||||
else
|
||||
return gennode(name, args)
|
||||
return gennode(name, args, Puppet[:external_nodes])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -727,7 +734,7 @@ class Puppet::Parser::Interpreter
|
|||
args = {}
|
||||
args[:classes] = classes if classes
|
||||
args[:parentnode] = parent if parent
|
||||
return gennode(node, args)
|
||||
return gennode(node, args, "ldap")
|
||||
else
|
||||
return nil
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ module Puppet
|
|||
|
||||
class Parser < Racc::Parser
|
||||
|
||||
module_eval <<'..end grammar.ra modeval..id729500608d', 'grammar.ra', 603
|
||||
module_eval <<'..end grammar.ra modeval..idde6e0009a9', 'grammar.ra', 603
|
||||
require 'puppet/parser/functions'
|
||||
|
||||
attr_reader :file, :interp
|
||||
|
@ -65,11 +65,11 @@ end
|
|||
# available.
|
||||
def ast(klass, hash = nil)
|
||||
hash ||= {}
|
||||
unless hash[:line]
|
||||
unless hash.include?(:line)
|
||||
hash[:line] = @lexer.line
|
||||
end
|
||||
|
||||
unless hash[:file]
|
||||
unless hash.include?(:file)
|
||||
if file = @lexer.file
|
||||
hash[:file] = file
|
||||
end
|
||||
|
@ -254,7 +254,7 @@ end
|
|||
|
||||
# $Id$
|
||||
|
||||
..end grammar.ra modeval..id729500608d
|
||||
..end grammar.ra modeval..idde6e0009a9
|
||||
|
||||
##### racc 1.4.5 generates ###
|
||||
|
||||
|
|
|
@ -444,6 +444,13 @@ class TestLangFunctions < Test::Unit::TestCase
|
|||
assert(scope.classlist.include?(c),
|
||||
"class %s was not evaluated" % c)
|
||||
end
|
||||
|
||||
# Now try a scoped class
|
||||
interp.newclass("os::redhat")
|
||||
|
||||
assert_nothing_raised("Could not include qualified class name") do
|
||||
scope.function_include("os::redhat")
|
||||
end
|
||||
end
|
||||
|
||||
def test_file
|
||||
|
|
Загрузка…
Ссылка в новой задаче