summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-07-20 13:31:34 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-07-20 13:31:34 -0700
commit94edd404130b4236f0c65a579857e3a25c5ee17f (patch)
treeefbdb3b3f64d1e362b3c8c78c352a9340e914361 /lib/puppet
parent2af27160b94efa4755187efd99c86d1659683b29 (diff)
parentdb0b30dbde94d16ab1d7580be4dd32e18cff23dc (diff)
downloadpuppet-94edd404130b4236f0c65a579857e3a25c5ee17f.tar.gz
puppet-94edd404130b4236f0c65a579857e3a25c5ee17f.tar.xz
puppet-94edd404130b4236f0c65a579857e3a25c5ee17f.zip
Merge commit 'tags/2.6.0' into next
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/ast.rb14
-rw-r--r--lib/puppet/parser/ast/leaf.rb16
-rw-r--r--lib/puppet/parser/type_loader.rb2
-rw-r--r--lib/puppet/resource.rb9
-rw-r--r--lib/puppet/resource/catalog.rb2
-rw-r--r--lib/puppet/resource/type.rb18
-rw-r--r--lib/puppet/resource/type_collection.rb2
-rw-r--r--lib/puppet/type.rb4
-rw-r--r--lib/puppet/util/settings.rb21
9 files changed, 48 insertions, 40 deletions
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb
index 2773a240e..54e034acb 100644
--- a/lib/puppet/parser/ast.rb
+++ b/lib/puppet/parser/ast.rb
@@ -87,6 +87,20 @@ class Puppet::Parser::AST
def initialize(args)
set_options(args)
end
+
+ # evaluate ourselves, and match
+ def evaluate_match(value, scope)
+ obj = self.safeevaluate(scope)
+
+ obj = obj.downcase if obj.respond_to?(:downcase)
+ value = value.downcase if value.respond_to?(:downcase)
+
+ obj = Puppet::Parser::Scope.number?(obj) || obj
+ value = Puppet::Parser::Scope.number?(value) || value
+
+ # "" == undef for case/selector/if
+ obj == value or (obj == "" and value == :undef)
+ end
end
# And include all of the AST subclasses.
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index 49f430278..49cde63ca 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -10,20 +10,6 @@ class Puppet::Parser::AST
@value
end
- # evaluate ourselves, and match
- def evaluate_match(value, scope)
- obj = self.safeevaluate(scope)
-
- obj = obj.downcase if obj.respond_to?(:downcase)
- value = value.downcase if value.respond_to?(:downcase)
-
- obj = Puppet::Parser::Scope.number?(obj) || obj
- value = Puppet::Parser::Scope.number?(value) || value
-
- # "" == undef for case/selector/if
- obj == value or (obj == "" and value == :undef)
- end
-
def match(value)
@value == value
end
@@ -77,7 +63,7 @@ class Puppet::Parser::AST
class Concat < AST::Leaf
def evaluate(scope)
- @value.collect { |x| x.evaluate(scope) }.join
+ @value.collect { |x| x.evaluate(scope) }.collect{ |x| x == :undef ? '' : x }.join
end
def to_s
diff --git a/lib/puppet/parser/type_loader.rb b/lib/puppet/parser/type_loader.rb
index c33f90d11..35ad49593 100644
--- a/lib/puppet/parser/type_loader.rb
+++ b/lib/puppet/parser/type_loader.rb
@@ -88,7 +88,7 @@ class Puppet::Parser::TypeLoader
nil
end
if result = yield(filename)
- Puppet.info "Automatically imported #{name} from #{filename}"
+ Puppet.info "Automatically imported #{name} from #{filename} into #{environment}"
result.module_name = modname if modname and result.respond_to?(:module_name=)
return result
end
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 55874aec8..96d22e414 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -217,7 +217,11 @@ class Puppet::Resource
end
def uniqueness_key
- self.to_hash.values_at(*key_attributes.sort_by { |k| k.to_s })
+ # Temporary kludge to deal with inconsistant use patters
+ h = self.to_hash
+ h[namevar] ||= h[:name]
+ h[:name] ||= h[namevar]
+ h.values_at(*key_attributes.sort_by { |k| k.to_s })
end
def key_attributes
@@ -353,7 +357,8 @@ class Puppet::Resource
def find_resource_type(type)
# It still works fine without the type == 'class' short-cut, but it is a lot slower.
- find_builtin_resource_type(type) || find_defined_resource_type(type) unless type.to_s.downcase == 'class'
+ return nil if ["class", "node"].include? type.to_s.downcase
+ find_builtin_resource_type(type) || find_defined_resource_type(type)
end
def find_builtin_resource_type(type)
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb
index 4ac99eeea..4b4342d11 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -57,7 +57,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
end
def title_key_for_ref( ref )
- ref =~ /^(.+)\[(.*)\]/m
+ ref =~ /^([\w:]+)\[(.*)\]$/m
[$1, $2]
end
diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb
index c2b4271e6..85c0979c1 100644
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@ -145,7 +145,12 @@ class Puppet::Resource::Type
resource_type = type == :hostclass ? :class : :node
# Make sure our parent class has been evaluated, if we have one.
- parent_type.mk_plain_resource(scope) if parent and ! scope.catalog.resource(resource_type, parent)
+ if parent
+ parent_resource = scope.catalog.resource(resource_type, parent)
+ unless parent_resource
+ parent_type(scope).mk_plain_resource(scope)
+ end
+ end
# Do nothing if the resource already exists; this makes sure we don't
# get multiple copies of the class resource, which helps provide the
@@ -169,11 +174,14 @@ class Puppet::Resource::Type
@name.is_a?(Regexp)
end
- def parent_type
+ def parent_type(scope = nil)
return nil unless parent
- unless @parent_type ||= resource_type_collection.send(type, parent)
- fail Puppet::ParseError, "Could not find parent resource type '#{parent}' of type #{type}"
+ unless @parent_type
+ raise "Must pass scope to parent_type when called first time" unless scope
+ unless @parent_type = scope.environment.known_resource_types.send("find_#{type}", scope.namespaces, parent)
+ fail Puppet::ParseError, "Could not find parent resource type '#{parent}' of type #{type} in #{scope.environment}"
+ end
end
@parent_type
@@ -255,7 +263,7 @@ class Puppet::Resource::Type
end
def evaluate_parent_type(resource)
- return unless klass = parent_type and parent_resource = resource.scope.compiler.catalog.resource(:class, klass.name) || resource.scope.compiler.catalog.resource(:node, klass.name)
+ return unless klass = parent_type(resource.scope) and parent_resource = resource.scope.compiler.catalog.resource(:class, klass.name) || resource.scope.compiler.catalog.resource(:node, klass.name)
parent_resource.evaluate unless parent_resource.evaluated?
parent_scope(resource.scope, klass)
end
diff --git a/lib/puppet/resource/type_collection.rb b/lib/puppet/resource/type_collection.rb
index 9ed27332d..6a933362f 100644
--- a/lib/puppet/resource/type_collection.rb
+++ b/lib/puppet/resource/type_collection.rb
@@ -134,7 +134,7 @@ class Puppet::Resource::TypeCollection
loader.load_until(namespaces, name) { find(namespaces, name, type) }
end
- def find_node(name)
+ def find_node(namespaces, name)
find("", name, :node)
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 880711066..c3855a400 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -723,6 +723,10 @@ class Type
# Are we running in noop mode?
def noop?
+ # If we're not a host_config, we're almost certainly part of
+ # Settings, and we want to ignore 'noop'
+ return false if catalog and ! catalog.host_config?
+
if defined?(@noop)
@noop
else
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index cbb12a816..ca4ecda35 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -157,13 +157,6 @@ class Puppet::Util::Settings
set_value(str, value, :cli)
end
- def without_noop
- old_noop = value(:noop,:cli) and set_value(:noop, false, :cli) if valid?(:noop)
- yield
- ensure
- set_value(:noop, old_noop, :cli) if valid?(:noop)
- end
-
def include?(name)
name = name.intern if name.is_a? String
@config.include?(name)
@@ -635,14 +628,12 @@ if @config.include?(:run_mode)
return
end
- without_noop do
- catalog.host_config = false
- catalog.apply do |transaction|
- if transaction.any_failed?
- report = transaction.report
- failures = report.logs.find_all { |log| log.level == :err }
- raise "Got #{failures.length} failure(s) while initializing: #{failures.collect { |l| l.to_s }.join("; ")}"
- end
+ catalog.host_config = false
+ catalog.apply do |transaction|
+ if transaction.any_failed?
+ report = transaction.report
+ failures = report.logs.find_all { |log| log.level == :err }
+ raise "Got #{failures.length} failure(s) while initializing: #{failures.collect { |l| l.to_s }.join("; ")}"
end
end