summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-12 18:40:54 -0500
committerLuke Kanies <luke@madstop.com>2007-09-12 18:40:54 -0500
commit3632926089cb27b93ff075c05ba21e2340a562ac (patch)
tree358905669eec4eef70e1f7997c35f3ecec82c1f5 /lib
parent43f22a2414048b180d2c0e2a421fa8d905c4d8eb (diff)
downloadpuppet-3632926089cb27b93ff075c05ba21e2340a562ac.tar.gz
puppet-3632926089cb27b93ff075c05ba21e2340a562ac.tar.xz
puppet-3632926089cb27b93ff075c05ba21e2340a562ac.zip
Moving the resource container behaviour to the Configuration object, rather than the base PGraph class. I expect I will just do away with PGraph, but for now, I am at least going to keep configuration-related code in that class.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/node/configuration.rb27
-rw-r--r--lib/puppet/pgraph.rb26
-rw-r--r--lib/puppet/transportable.rb2
3 files changed, 27 insertions, 28 deletions
diff --git a/lib/puppet/node/configuration.rb b/lib/puppet/node/configuration.rb
index 4f93fdbe5..be30ddb68 100644
--- a/lib/puppet/node/configuration.rb
+++ b/lib/puppet/node/configuration.rb
@@ -4,7 +4,7 @@ require 'puppet/external/gratr/digraph'
# meant to be passed from server to client, and it contains all
# of the information in the configuration, including the resources
# and the relationships between them.
-class Puppet::Node::Configuration < GRATR::Digraph
+class Puppet::Node::Configuration < Puppet::PGraph
attr_accessor :name, :version
attr_reader :extraction_format
@@ -18,6 +18,25 @@ class Puppet::Node::Configuration < GRATR::Digraph
tag(*classes)
end
+ # Add a resource to our graph and to our resource table.
+ def add_resource(resource)
+ unless resource.respond_to?(:ref)
+ raise ArgumentError, "Can only add objects that respond to :ref"
+ end
+
+ ref = resource.ref
+ if @resource_table.include?(ref)
+ raise ArgumentError, "Resource %s is already defined" % ref
+ else
+ @resource_table[ref] = resource
+ end
+ end
+
+ def clear
+ super
+ @resource_table.clear
+ end
+
def classes
@classes.dup
end
@@ -100,6 +119,12 @@ class Puppet::Node::Configuration < GRATR::Digraph
@extraction_format ||= :transportable
@tags = []
@classes = []
+ @resource_table = {}
+ end
+
+ # Look a resource up by its reference (e.g., File[/etc/passwd]).
+ def resource(ref)
+ @resource_table[ref]
end
# Add a tag.
diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb
index ddecc731d..7a3869dcf 100644
--- a/lib/puppet/pgraph.rb
+++ b/lib/puppet/pgraph.rb
@@ -19,20 +19,6 @@ class Puppet::PGraph < GRATR::Digraph
super
end
- # Add a resource to our graph and to our resource table.
- def add_resource(resource)
- unless resource.respond_to?(:ref)
- raise ArgumentError, "Can only add objects that respond to :ref"
- end
-
- ref = resource.ref
- if @resource_table.include?(ref)
- raise ArgumentError, "Resource %s is already defined" % ref
- else
- @resource_table[ref] = resource
- end
- end
-
def add_vertex!(*args)
@reversal = nil
super
@@ -40,7 +26,6 @@ class Puppet::PGraph < GRATR::Digraph
def clear
@vertex_dict.clear
- #@resource_table.clear
if defined? @edge_number
@edge_number.clear
end
@@ -86,12 +71,6 @@ class Puppet::PGraph < GRATR::Digraph
def edge_class()
Puppet::Relationship
end
-
- def initialize(*args)
- super
- # Create a table to keep references to all of our resources.
- @resource_table = {}
- end
# Determine all of the leaf nodes below a given vertex.
def leaves(vertex, type = :dfs)
@@ -118,11 +97,6 @@ class Puppet::PGraph < GRATR::Digraph
end
end.flatten
end
-
- # Look a resource up by its reference (e.g., File["/etc/passwd"]).
- def resource(ref)
- @resource_table[ref]
- end
# Take container information from another graph and use it
# to replace any container vertices with their respective leaves.
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb
index 7a04e1f63..782ba2467 100644
--- a/lib/puppet/transportable.rb
+++ b/lib/puppet/transportable.rb
@@ -201,7 +201,7 @@ module Puppet
# Create a resource graph from our structure.
def to_graph
- graph = Puppet::PGraph.new
+ graph = Puppet::Node::Configuration.new(Facter.value(:hostname))
delver = proc do |obj|
obj.each do |child|