summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-20 12:57:57 -0500
committerLuke Kanies <luke@madstop.com>2007-09-20 12:57:57 -0500
commit46d69068fa7b2f3448294c5d3da21c69cef73d2f (patch)
tree8abf532af73d4fd7d68d894db639004e331318bc /lib
parent9fa2628a844c75b8f554f283dfece01667f20594 (diff)
downloadpuppet-46d69068fa7b2f3448294c5d3da21c69cef73d2f.tar.gz
puppet-46d69068fa7b2f3448294c5d3da21c69cef73d2f.tar.xz
puppet-46d69068fa7b2f3448294c5d3da21c69cef73d2f.zip
An intermediate commit so I can start working on a different
branch. The file recursion code actually works for the first time in a painful while, but there are still some quirks and design issues to resolve, particularly around creating implicit resources that then fail (i.e., the behaviour of the create_implicit_resource method in Configuration).
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/node/configuration.rb13
-rw-r--r--lib/puppet/pgraph.rb2
-rw-r--r--lib/puppet/type.rb2
-rw-r--r--lib/puppet/type/pfile.rb24
-rw-r--r--lib/puppet/util/config.rb2
5 files changed, 21 insertions, 22 deletions
diff --git a/lib/puppet/node/configuration.rb b/lib/puppet/node/configuration.rb
index c882e0ee1..de6e776c5 100644
--- a/lib/puppet/node/configuration.rb
+++ b/lib/puppet/node/configuration.rb
@@ -55,13 +55,13 @@ class Puppet::Node::Configuration < Puppet::PGraph
# Apply our configuration to the local host.
def apply
+ @applying = true
+
Puppet::Util::Storage.load if host_config?
transaction = Puppet::Transaction.new(self)
transaction.addtimes :config_retrieval => @retrieval_duration
- @applying = true
-
begin
transaction.evaluate
rescue Puppet::Error => detail
@@ -122,6 +122,7 @@ class Puppet::Node::Configuration < Puppet::PGraph
unless options.include?(:implicit)
options[:implicit] = true
end
+ # LAK:FIXME catch exceptions here and return nil when problems
if resource = create_resource(type, options)
resource.implicit = true
@@ -235,6 +236,7 @@ class Puppet::Node::Configuration < Puppet::PGraph
@resource_table = {}
@transient_resources = []
@applying = false
+ @relationship_graph = nil
if block_given?
yield(self)
@@ -245,11 +247,12 @@ class Puppet::Node::Configuration < Puppet::PGraph
# Create a graph of all of the relationships in our configuration.
def relationship_graph
unless defined? @relationship_graph and @relationship_graph
- relationships = self.class.new
+ relationships = Puppet::Node::Configuration.new
+ relationships.host_config = host_config?
# First create the dependency graph
self.vertices.each do |vertex|
- relationships.add_resource vertex
+ relationships.add_vertex! vertex
vertex.builddepends.each do |edge|
relationships.add_edge!(edge)
end
@@ -287,6 +290,7 @@ class Puppet::Node::Configuration < Puppet::PGraph
resources.each do |resource|
@resource_table.delete(resource.ref) if @resource_table.include?(resource.ref)
remove_vertex!(resource) if vertex?(resource)
+ @relationship_graph.remove_vertex!(resource) if @relationship_graph and @relationship_graph.vertex?(resource)
resource.remove
end
end
@@ -345,6 +349,7 @@ class Puppet::Node::Configuration < Puppet::PGraph
unless @transient_resources.empty?
remove_resource(*@transient_resources)
@transient_resources.clear
+ @relationship_graph = nil
end
end
end
diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb
index 7a3869dcf..70b466225 100644
--- a/lib/puppet/pgraph.rb
+++ b/lib/puppet/pgraph.rb
@@ -95,7 +95,7 @@ class Puppet::PGraph < GRATR::Digraph
adjacent(source, :direction => :out, :type => :edges).find_all do |edge|
edge.match?(event.event)
end
- end.flatten
+ end.compact.flatten
end
# Take container information from another graph and use it
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 1db435224..e55873c2b 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -318,7 +318,7 @@ class Type
# We should never have more than one parent, so let's just ignore
# it if we happen to.
- if parents = configuration.adjacent(self, :direction => :in)
+ if parents = configuration.relationship_graph.adjacent(self, :direction => :in)
return parents.shift
else
return nil
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index da345e5d6..f2fa6a14d 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -611,13 +611,14 @@ module Puppet
}
child = nil
-
+
# The child might already exist because 'localrecurse' runs
# before 'sourcerecurse'. I could push the override stuff into
# a separate method or something, but the work is the same other
# than this last bit, so it doesn't really make sense.
if child = configuration.resource(:file, path)
unless child.parent.object_id == self.object_id
+ puts("Parent is %s, I am %s" % [child.parent.ref, self.ref]) if child.parent
self.debug "Not managing more explicit file %s" %
path
return nil
@@ -643,22 +644,15 @@ module Puppet
args[:parent] = self
begin
return nil unless child = configuration.create_implicit_resource(:file, args)
- rescue Puppet::Error => detail
- self.notice(
- "Cannot manage: %s" %
- [detail.message]
- )
- self.debug args.inspect
- child = nil
rescue => detail
- self.notice(
- "Cannot manage: %s" %
- [detail]
- )
- self.debug args.inspect
- child = nil
+ puts detail.backtrace
+ self.notice "Cannot manage: %s" % [detail]
+ return nil
end
- configuration.relationship_graph.add_edge! self, child
+ end
+ configuration.relationship_graph.add_edge! self, child
+ unless child.parent
+ raise "Did not set parent of %s" % child.ref
end
return child
end
diff --git a/lib/puppet/util/config.rb b/lib/puppet/util/config.rb
index 3988b3fe0..4b6ae9e5b 100644
--- a/lib/puppet/util/config.rb
+++ b/lib/puppet/util/config.rb
@@ -1143,7 +1143,7 @@ Generated on #{Time.now}.
path = self.value
# Skip plain files that don't exist, since we won't be managing them anyway.
- return nil unless self.name.to_s =~ /dir$/ or File.exist?(path)
+ return nil unless self.name.to_s =~ /dir$/ or File.exist?(path) or self.create
obj = Puppet::TransObject.new(path, "file")
# Only create directories, or files that are specifically marked to