summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-29 04:15:36 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-29 04:15:36 +0000
commitbb9c813feb3c6a27a3765d593cae56e800b46fb1 (patch)
treea26e20648532ee8bc0caf42682c2d4084a146a96 /lib
parent7ae62a5dd2323c38b2dd5ba662d8c140b0f9345c (diff)
downloadpuppet-bb9c813feb3c6a27a3765d593cae56e800b46fb1.tar.gz
puppet-bb9c813feb3c6a27a3765d593cae56e800b46fb1.tar.xz
puppet-bb9c813feb3c6a27a3765d593cae56e800b46fb1.zip
Did a short-cut on the graphing, since we currently only support one type of subscription. This solution still will not scale to all that many edges, but it works, although it will fail if we need to support different types of subcriptions.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1983 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/metatype/metaparams.rb16
-rw-r--r--lib/puppet/pgraph.rb31
-rw-r--r--lib/puppet/relationship.rb4
3 files changed, 38 insertions, 13 deletions
diff --git a/lib/puppet/metatype/metaparams.rb b/lib/puppet/metatype/metaparams.rb
index c9c3a694d..93fffc04c 100644
--- a/lib/puppet/metatype/metaparams.rb
+++ b/lib/puppet/metatype/metaparams.rb
@@ -288,15 +288,15 @@ class Puppet::Type
target = object
end
- # ok, both sides of the connection store some information
- # we store the method to call when a given subscription is
- # triggered, but the source object decides whether
- subargs = {
- :event => self.class.events
- }
-
if method = self.class.callback
- subargs[:callback] = method
+ subargs = {
+ :event => self.class.events,
+ :callback => method
+ }
+ else
+ # If there's no callback, there's no point in even adding
+ # a label.
+ subargs = nil
end
rel = Puppet::Relationship.new(source, target, subargs)
end
diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb
index de89e0a71..64f411a40 100644
--- a/lib/puppet/pgraph.rb
+++ b/lib/puppet/pgraph.rb
@@ -33,6 +33,23 @@ class Puppet::PGraph < GRATR::Digraph
end
end
+ # Make sure whichever edge has a label keeps the label
+ def copy_label(source, target, label)
+ # 'require' relationships will not have a label,
+ # and all 'subscribe' relationships have the same
+ # label, at least for now.
+
+ # Labels default to {}, so we can't just test for nil.
+ newlabel = label || {}
+ oldlabel = edge_label(source, target) || {}
+ if ! newlabel.empty? and oldlabel.empty?
+ edge_label_set(source, target, label)
+ # We should probably check to see if the labels both exist
+ # and don't match, but we'd just throw an error which the user
+ # couldn't do anyting about.
+ end
+ end
+
# Which resources a given resource depends upon.
def dependents(resource)
tree_from_vertex2(resource).keys
@@ -128,6 +145,7 @@ class Puppet::PGraph < GRATR::Digraph
s = child
t = neighbor
end
+
if s.is_a?(type)
raise "Source %s is still a container" % s
end
@@ -135,9 +153,16 @@ class Puppet::PGraph < GRATR::Digraph
raise "Target %s is still a container" % t
end
- # It *appears* that we're having a problem
- # with multigraphs.
- next if edge?(s, t)
+ # We don't want to add multiple copies of the
+ # same edge, but we *do* want to make sure we
+ # keep labels around.
+ # XXX This will *not* work when we support multiple
+ # types of labels, and only works now because
+ # you can only do simple subscriptions.
+ if edge?(s, t)
+ copy_label(s, t, edge.label)
+ next
+ end
add_edge!(s, t, edge.label)
if cyclic?
raise ArgumentError,
diff --git a/lib/puppet/relationship.rb b/lib/puppet/relationship.rb
index 879beeab7..15f67b384 100644
--- a/lib/puppet/relationship.rb
+++ b/lib/puppet/relationship.rb
@@ -46,9 +46,9 @@ class Puppet::Relationship < GRATR::Edge
# Does the passed event match our event? This is where the meaning
# of :NONE comes from.
def match?(event)
- if event == :NONE or self.event == :NONE
+ if self.event.nil? or event == :NONE or self.event == :NONE
return false
- elsif self.event == :ALL_EVENTS or event == :ALL_EVENTS or event == self.event
+ elsif self.event == :ALL_EVENTS or event == self.event
return true
else
return false